-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Bug]: When snapshot testing, jest throws Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'VectorIcons' could not be found
#1681
Comments
I can get a different error message if I mock out the Turbo Modules as described in this StackOverflow post: https://stackoverflow.com/a/77498117/14765128
|
I'm getting this error, but not as a test failure, as an error when running the app. Any immediate fix? Downgrade? |
I suspect you either need to add |
RNVI works fine on the device itself. The error highlighted in this issue only arises when running Jest tests, which are JS only, no native component. Typically, when I face this sort of error, I simply mock out the native calls, but even that approach is not working here (see Unsuccessful Workarounds) |
Unfortunately, already had
Ended up going back to the old way of doing it for now. |
@thehale Apologies I didn't have time to look at this properly during the week. I think the real answer will be the change we are considering in #1682 I suspect there is some way to mock this away as a workaround, but I don't have enough jest experience to help. |
@johnf No worries! I'll keep trying to find a workaround too. |
I have the same problem, did u found a solution ? @thehale |
Which package are you using?
@react-native-vector-icons/*
What platform(s) does this occur on?
Android, iOS
What happened?
After scaffolding a new react native app, the default tests pass.
But, upon installing
react-native-vector-icons
and using them in a component, the test suite crashes with:Unsuccessful Workarounds
Mocking out RNVI: https://github.com/thehale/reproduction-react-native-vector-icons-with-jest-invariant-violation/tree/NOT_A_FIX_mocks
Using
moduleNameMapper
: https://github.com/thehale/reproduction-react-native-vector-icons-with-jest-invariant-violation/tree/NOT_A_FIX_moduleNameMapperRelevant log output
Minimal reproducible example
https://github.com/thehale/reproduction-react-native-vector-icons-with-jest-invariant-violation
A newly scaffolded app passes tests
git checkout HEAD~
yarn
yarn test
Adding
react-native-vector-icons
causes the test suite to crashgit checkout main
yarn
yarn test
Your computer environment
The text was updated successfully, but these errors were encountered: