Fix Errors.test.tsx failing with Reanimated 4.6.0 - #4474
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change adds a test-only ChangesGesture test support
Merge Risk: ⚪ Minimal · up to This change isolates the affected Jest test from Reanimated import behavior without altering production code; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR stabilizes the Errors.test.tsx Jest suite against react-native-reanimated@4.6.0+ import-time failures by mocking reanimatedWrapper, ensuring tests continue to exercise the Reanimated detector path without depending on Reanimated’s real module evaluation under Jest.
Changes:
- Mock
../handlers/gestures/reanimatedWrapperinErrors.test.tsxto avoid importing real Reanimated under Jest. - Extend the mock to include
useComposedEventHandler, which is required byInterceptingGestureDetector.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // Reanimated 4.6.0 throws on import under Jest (`setCSSEventHandler` is not | ||
| // available in JSReanimated), which reanimatedWrapper silently turns into | ||
| // `Reanimated = undefined`. Mock the wrapper so gestures with worklet | ||
| // callbacks still take the Reanimated detector path these tests rely on. | ||
| // | ||
| // TODO: Remove after fixed in Reanimated | ||
| jest.mock('../handlers/gestures/reanimatedWrapper', () => ({ |
Description
Since Reanimated 4.6.0 (software-mansion/react-native-reanimated#10107), importing
react-native-reanimatedunder Jest throws during module evaluation:Under
Jest,Reanimatedselects itsJSReanimatedmodule (IS_JESTcheck inreanimatedModuleInstance.native.ts), whosesetCSSEventHandlerstub throws, andinitializers.native.tscalls it unconditionally as an import side effect. OurreanimatedWrappercatches the error and silently falls back toReanimated = undefined.This PR mocks
reanimatedWrapperinErrors.test.tsx(same pattern asrunOnJSReanimatedHandlers.test.tsx), which makes the suite independent of whether the real Reanimated can be imported under Jest. The mock additionally providesuseComposedEventHandler, whichInterceptingGestureDetectorcalls.Test plan