I am using Jest for testing.
What I want, is to stop executing the current test suite when a test in that test suite fails.
The option --bail
is not what I need, since it stop other test suites after one test suite fails.
I am using Jest for testing.
What I want, is to stop executing the current test suite when a test in that test suite fails.
The option --bail
is not what I need, since it stop other test suites after one test suite fails.
I guess that other tests in that suite depend on all previous tests be successful. This is a bad practice in unit testing. Try using
beforeEach
andafterEach
to decouple individual test cases within a suite, so that they don't rely on each other.I've made some kludge but it works for me.
stopOnFirstFailed.js
:Imports that file before all tests (before first
test(...)
), for ex myindex.test.js
:That code marks all next tests
failed
with labelglobalFailure is TRUE
when first error happens.If you want to exclude
failing
, for ex. some cleanup tests you can do like this:It excludes whole group from
failing
.Tested with Node 8.9.1 and Jest 23.6.0