I am currently studying AngularJS, and part of this covers creating tests. I am currently trying to figure out how to create more useful error messages for failed tests. For example, if I were in Java-land and wrote down JUnit tests, I would do something similar to this:
assertTrue( "The foo value should be true at this point", bar.isFoo() );
This way, I will get this first parameter in the log if the verification fails.
For boolean checks in mocha (with chai and sinon, in case that matters), I ...
expect(broadcastSpy.calledWith('order.add')).to.be.true;
If this fails, I get the following:
expected false to be true
AssertionError: expected false to be true
Is there any way to reproduce this useful error message while testing my application?
source
share