I'm familiar with python unittest tests where if an assertion fails, that test is marked as "failed" and it moves on to other tests. Jasmine on the other hand will continue through all expects even if the one of them fails. How can I make Jasmine stop processing a test after the first expectation fails?
it ("shouldn't need to test other expects if the first fails", function() {
expect(array.length).toBe(1);
// don't need to check this if the first failed.
expect(array[0]).toBe("foo");
});
Am I thinking about it wrong? I have some tests with lots of expect
's and it seems like a waste to show all the stack traces when only the first is wrong really.
undefined
elements, in which case you could either assert that none of the elements areundefined
, or that the array's length is not greater than a specific number. This way, assertions will complete each other. – Interference