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
I recently noticed that Jest seems to ignore errors thrown by async functions in certain cases.
I discovered this while writing some tests for a React component that calls an async function from componentDidMount. If the async function calls setState- and the component un-mounts before that happens- the resulting warning/error issued by React is silently swallowed.
git clone [email protected]:bvaughn/jest-uncaught-error-repro.git
cd ./jest-uncaught-error-repro
yarn install
yarn test
In my repro, throwing the error within an expect(...).not.toThrow() block "fixes" things so that the test fails, but that is not the case within the test that first uncovered this issue. It's also not a great solution, since errors aren't guaranteed to be thrown within such a block.
Am I missing or overlooking something?
The text was updated successfully, but these errors were encountered:
Maybe related to #5311, #3251 - although I added logging (to my local Jasmine Env) to verify that my error is thrown before the uncaught error handler is removed FWIW.
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.
I recently noticed that Jest seems to ignore errors thrown by async functions in certain cases.
I discovered this while writing some tests for a React component that calls an async function from
componentDidMount
. If the async function callssetState
- and the component un-mounts before that happens- the resulting warning/error issued by React is silently swallowed.Here is an annotated example of what I'm describing (but without React):
https://github.com/bvaughn/jest-uncaught-error-repro/blob/master/index.test.js
To repro this false positive:
In my repro, throwing the error within an
expect(...).not.toThrow()
block "fixes" things so that the test fails, but that is not the case within the test that first uncovered this issue. It's also not a great solution, since errors aren't guaranteed to be thrown within such a block.Am I missing or overlooking something?
The text was updated successfully, but these errors were encountered: