Jest: `--bail` does not work

Created on 18 Jan 2017  路  9Comments  路  Source: facebook/jest

Do you want to request a feature or report a bug?

bug

What is the current behavior?

All tests are run even though --bail was used.

What is the expected behavior?

No other tests should be run after an error.

See https://github.com/julien-f/issue-jest-bail

Environment

My system is Debian Stretch.

> npm version
{ npm: '4.0.5',
  ares: '1.10.1-DEV',
  http_parser: '2.7.0',
  icu: '57.1',
  modules: '48',
  node: '6.9.4',
  openssl: '1.0.2j',
  uv: '1.9.1',
  v8: '5.1.281.89',
  zlib: '1.2.8' }

Most helpful comment

According to documentation https://jestjs.io/docs/en/api#describename-fn, a describe is a test suite.

But --bail is not really working when first test suite fails.
Is there a reason this is still closed?

All 9 comments

Running Jest with --bail will prevent other test _suites_ from executing.
In your case there's only 1 test suite (1 file), that's why it checks all other cases.

@cpojer I think we should stress this better in the documentation, right?

Oh, I see, thanks for the info :)

I have jest v 18.1.0 and have --bail on the command line _and_ "bail":true in my package.json, and Jest still runs all the tests in all the files.

This should be fixed in master, we fixed yet another issue with bail.

Actually, I just realized that this was because a script in my "setupFiles" had an error. It looks like if a test suite fails to run, that doesn't trigger the "bail" and it moves on to the next suite (which will re-run the "setupFiles" scripts and fail for the same reason...)

is there any way to skip current describe and all nested describe on first failure but still run other describes? Like bail-describe for example.

According to documentation https://jestjs.io/docs/en/api#describename-fn, a describe is a test suite.

But --bail is not really working when first test suite fails.
Is there a reason this is still closed?

I've made some temporary kludge for it: https://stackoverflow.com/a/53615538/2051938

I'm hitting the same issue. Also, should coverage still be running on a bail? I'd think it'd just halt everything

Was this page helpful?
0 / 5 - 0 ratings