fix: avoid unhandled promise rejections when concurrent tests fail#11987
fix: avoid unhandled promise rejections when concurrent tests fail#11987SimenB merged 6 commits intojestjs:mainfrom dmitri-gb:uncaught-rejection-fix
Conversation
| const promise = mutex(() => testFn()); | ||
| // Avoid triggering the uncaught promise rejection handler in case the test errors before | ||
| // being awaited on. | ||
| promise.catch(() => {}); |
There was a problem hiding this comment.
Note that this doesn't mean promise will never reject, that is only true for the promise returned by catch(...).
Codecov Report
@@ Coverage Diff @@
## main #11987 +/- ##
==========================================
- Coverage 68.77% 68.76% -0.01%
==========================================
Files 324 324
Lines 16670 16672 +2
Branches 4814 4814
==========================================
Hits 11465 11465
- Misses 5172 5174 +2
Partials 33 33
Continue to review full report at Codecov.
|
SimenB
left a comment
There was a problem hiding this comment.
thanks! I've been meaning to dig into these, thanks for taking the time 👍
|
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
This change fixes an issue where a failing
concurrenttest could trigger the global unhandled promise rejection handler, which would then attribute this failure to a different test (the one that was currently "running" i.e. the one that Jest was currently awaiting on). The issue is present in both jest-jasmine2 and jest-circus.You can also check existing bug reports (#11691, #11231) for examples.
Fixes #11691
Fixes #11231
Test plan
There is a new integration test that demonstrates the issue.