Stop jasmine test after first expect fails

@Gregg’s answer was correct for the latest version of Jasmine at that time (v2.0.0). However, since then, this new feature was added in v2.3.0: Allow user to stop a specs execution when an expectation fails (Fixes #577) It’s activated by adding throwFailures=true to the query string of the runner page, eg: http://localhost:8000/?throwFailures=true

Testing promise in Angular 2 ngOnInit

IMO the best solution for this use case is to just make a synchronous mock service . You can’t use fakeAsync for this particular case because of the XHR call for templateUrl. And personally I don’t think the “hack” to make ngOnInit return a promise is very elegant. And you should not have to call … Read more

How do I focus on one spec in jasmine.js?

When using Karma, you can enable only one test with fit or fdescribe (iit and ddescribe in Jasmine before 2.1). This only runs Spec1: // or “ddescribe” in Jasmine prior 2.1 fdescribe(‘Spec1’, function () { it(‘should do something’, function () { // … }); }); describe(‘Spec2’, function () { it(‘should do something’, function () { … Read more