You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an it block returns a promise, but then there's an uncaught exception before the promise resolves, an internal jest error occurs.
If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install and yarn test.
When this test is run with jest it results in the following output:
$ jest --config jest.config.js myTest.js
(node:27482) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'addExpectationResult' of undefined
(node:27482) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
FAIL myTest.js
✕ should foo (14ms)
● should foo
argh
1 | it('should foo', function () {
2 | setImmediate(() => {
> 3 | throw new Error('argh');
4 | });
5 | return new Promise((resolve, reject) => setTimeout(() => reject(new Error('foo')), 10));
6 | });
at Immediate.setImmediate (myTest.js:3:15)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 0.281s, estimated 1s
Ran all test suites matching /myTest.js/i.
We should improve the error here (saying something like "error caught after test environment was torn down"). I think the underlying issue is the same as #5311 though (we remove error handlers between specs), so I'll close this as a dupe of that
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When an
it
block returns a promise, but then there's an uncaught exception before the promise resolves, an internal jest error occurs.If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can
yarn install
andyarn test
.When this test is run with jest it results in the following output:
A bit of poking around reveals that the error comes from here: https://github.com/facebook/jest/blob/f014d92f1a16c19ca18a2d9023f1fb148149aa38/packages/jest-jasmine2/src/jasmine/Env.js#L556
What is the expected behavior?
That the internal jest error doesn't appear. Ideally I think I would like both the uncaught exception and the promise rejection to be rendered.
Please provide your exact Jest configuration
Run
npx envinfo --preset jest
in your project directory and paste theresults here
Also happens with 22.4.3
The text was updated successfully, but these errors were encountered: