I want the runner to stop after the first failure rather than running all the tests.
Excluding Tests / Specs If you want to exclude a specific test, simply use xit() instead of it() . The x means exclude. describe('description', function () { xit('description', function () {}); }); If you want to exclude an entire describe block, use xdescribe() instead of describe() .
If the function passed to Jasmine takes an argument (traditionally called done ), Jasmine will pass a function to be invoked when asynchronous work has been completed.
var throwMeAnError = function() { //throw new Error(); }; describe("Different Methods of Expect Block",function() { var exp = 25; it("Hey this will throw an Error ", function() { expect(throwMeAnError). toThrow(); }); }); As can be seen, we have commented that line from where our method was throwing the exception.
Jasmine doesn't actually support parallel execution. It runs one spec (or before/after) function at a time.
It's a hack, but you can do this by inserting this script before your first test;
<script type="text/javascript">
// after every test has run
afterEach(function () {
// check if any have failed
if(this.results_.failedCount > 0) {
// if so, change the function which should move to the next test
jasmine.Queue.prototype.next_ = function () {
// to instead skip to the end
this.onComplete();
}
}
});
</script>
Jasmine's latest commit at the time of applying this was https://github.com/pivotal/jasmine/commit/8b02bf731b193e135ccb486e99b3ecd7165bf95c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With