Failure Assignment for Call Waiting

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?

+4
source share
1 answer

. Chai, , , , : :

expect(foo).to.be.true;

, true , getter. , , :

expect(foo).to.equal(true, "foo should be true");

, .

Chai assert , :

assert.isTrue(foo, "foo should be true");
+10

Source: https://habr.com/ru/post/1541287/


All Articles