Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does jasmine have soft assertion using expect()?

In my tests, there are lots of expects. But some of them may not be severe enough to stop the tests. Could I ignore the error at a moment and throw them at the end of the test?

like image 832
isian8814 Avatar asked Feb 07 '23 23:02

isian8814


1 Answers

The jasmine expectations are kind of "soft" by default. In a sense that the test execution continues after a failure.

In other words, if you have the following code:

expect(true).toBe(false);
expect(false).toBe(true);

you would get a test failure with 2 unmet expectations.


A common problem is an exact opposite of what you are asking about - how to turn the behavior off so that jasmine would fail the test after the very first expect fails - this is now solved by stopSpecOnExpectationFailure option which is false by default.

like image 93
alecxe Avatar answered Feb 11 '23 01:02

alecxe