jest
jest copied to clipboard
Jest should fail fast and exit early (change request for --bail)
🚀 Feature Proposal
Jest should not run subsequent hooks or tests associated with that hook if an exception is thrown in a hook.
Motivation
When setup/teardown is broken up into small chunks (open browser, navigate to url, login, etc) and one of those hooks fails, all subsequent hooks and tests may fail and the output is clogged.
Example
When using Jest with puppeteer, I need to do the following before running any tests:
- open browser
- navigate to URL
- login
- wait for selector/page to be loaded
If any of those steps fail, the subsequent steps and tests are likely to fail as well.
Pitch
I'm using jest because of the detailed reporter, especially when a test fails. But failure reports can become needlessly long when it's only the first item that needs to be fixed to prevent a long subsequent list of failures/errors
I do not believe this is considered a change to the default reporter, as --bail does not behave the way I expect it to (it does stop after the first failing test, but if the test has 5 hooks, it still tries to run subsequent hooks and then the test fails).