-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: stop printing the same error for each individual test caused by beforeAll when it fails #10004
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has broken 2 tests. To run with circus locally, do JEST_CIRCUS=1 yarn jest
.
Also, I think we should have better messages. Instead of unhandled
we can have a new hookErrors
field or something? That might be considered breaking for people consuming our events though, not sure.
This also needs to be covered by explicit tests 🙂
This PR is stale because it has been open 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
@vldmrkl any chance you could finalize this? :) |
Closing this PR in favour of #13273 |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Closes #9901
From my research, I found that the call of
addErrorToEachTestUnderDescribe
was causing this bug (line 160):https://github.com/facebook/jest/blob/0a4e4a1657b42b21ebf3a969fbf3bbdd28ca930f/packages/jest-circus/src/eventHandler.ts#L154-L170
Removing this function call would stop printing error messages from beforeAll failure for each individual test, however, test suit would pass even though
beforeAll
failed. That's why I had to add an error tostate.unhandledErrors
, so it fails the test suit and prints an error message forbeforeAll
failure.Since the code is the same as as-if statement for
afterAll
type, I joinedtype === 'beforeAll'
andtype === 'afterAll'
.These changes haven't broken any existing test in the project, and it looks like it is much less confusing comparing to the previous version, though I would like to get confirmation that this is the expected behaviour.
Test plan
Let's reuse the example from the issue description and see a new behaviour that this bug fix provides.
Example:
New behaviour: