Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Stop testcase execution on failure in beforeEach #577

FrankyBoy opened this Issue · 4 comments

4 participants


I think it would be very useful to stop execution of a testcase if the beforeEach fails (i.e. throws an exception or similar).

Example: precondition is used for login -> if the login does not succeed, it does not make any sense to run the actual test.

I already tried to expect() something in the beforeEach (or in a function that it calls, to be more exact), and throwing an exception. The first did not work at all for my purposes (as other steps in the beforeEach were still executed), the 2nd at least registers as an error but the execution still continues.

Or maybe something like an option to stop executing the testcase as soon as one expectation fails could work, but I didn't find any such option.


Having a manual way of stopping a test case execution would be really handy. For example when creating tests for Selenium Webdriver and during the flow for example login fails thus I cannot perform rest of my steps I could fail the test with predefined message and skip the rest of the execution and jump to next one.


Is a manual fail method sufficient? If so, we have this in our backlog.


I don't think the manual fail method solves this by itself. It sounds to me like the desired behavior is that a single spec stops execution upon encountering its first expectation failure or exception and proceeds straight to the next spec. This would probably need to be some other kind of option to jasmine similar to whats requested in #414 but for a single spec instead of the whole suite.

I'm not sure what we would want to do as far as afterEach calls in this mode as well.


I've created a set of stories in tracker that detail how we want to address this issue.

Story for core:
Story to update npm:
Story to update gem:
Story to update py:

We'd be happy to review pull requests for this functionality.

Thanks for using jasmine!

@slackersoft slackersoft referenced this issue from a commit
Gregg Van Hove and Molly Trombley-McCann Allow user to stop a specs execution when an expectation fails
[finish #1165916] #577
@sdemjanenko sdemjanenko referenced this issue from a commit in meraki/jasmine
Gregg Van Hove and Molly Trombley-McCann Allow user to stop a specs execution when an expectation fails
[finish #1165916] #577
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.