-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Add mocks to fix: handleException is not a function (#29849) #30027
Conversation
|
Base commit: abff021 |
Base commit: abff021 |
It'll result in
|
@@ -23,6 +23,9 @@ import type { | |||
import parseErrorStack from '../../Core/Devtools/parseErrorStack'; | |||
import type {ExtendedError} from '../../Core/Devtools/parseErrorStack'; | |||
import NativeLogBox from '../../NativeModules/specs/NativeLogBox'; | |||
|
|||
const ExceptionsManager = require('../../Core/ExceptionsManager'); |
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 was originally in reportLogBoxError to avoid a circular dependency. If you move it back into reportLogBoxError, but keep the mock in jest/setup, does it still solve the issue?
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.
Thanks for taking a look. In my experience this change is necessary to avoid Jest throwing:
ReferenceError: You are trying to
import
a file after the Jest environment has been torn down.
I'm not sure how to resolve the circular dependency issue :\
I can confirm that this fixes the issue, how can we follow in which version of RN this fix will land? |
It would be great to get this error blocks a lot of apps that have testing infrastructure set up to upgrade. |
@rickhanlonii could you take a look at this? |
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.
Is there any update or workaround on this bug? |
@semcelik Yes, this workaround is correcting the issue for us. |
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This PR was closed because it has been stalled for 7 days with no activity. |
Summary
This solves two problems:
require
call that is removed in this commit is also incompatible with running a test suite (at least in react-native-testing-library) because the on-the-fly require fails. This throws the error:See issue: #29849
Changelog
[General] [Fix] - Fix issue where exceptions thrown during test runs could get swallowed and result in these messages:
import
a file after the Jest environment has been torn down.Test Plan
Before: an exception generated during our test suite is swallowed and shows the errors above
After: no longer repros. exceptions logged during a test run output their messages to the console as expected
(I def would like verification from a code owner here, this code makes it work but I can't guarantee it's optimal. Thanks!)