Skip to content

Fix Errors.test.tsx failing with Reanimated 4.6.0 - #4474

Merged
m-bert merged 1 commit into
mainfrom
@mbert/rea-ci
Aug 26, 2026
Merged

Fix Errors.test.tsx failing with Reanimated 4.6.0#4474
m-bert merged 1 commit into
mainfrom
@mbert/rea-ci

Conversation

@m-bert

@m-bert m-bert commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Description

Since Reanimated 4.6.0 (software-mansion/react-native-reanimated#10107), importing react-native-reanimated under Jest throws during module evaluation:

    [Reanimated] `setCSSEventHandler` is not available in JSReanimated.
      at initializeReanimatedModule (src/initializers.native.ts:22)
      at Object.<anonymous> (src/index.ts:11)

Under Jest, Reanimated selects its JSReanimated module (IS_JEST check in reanimatedModuleInstance.native.ts), whose setCSSEventHandler stub throws, and initializers.native.ts calls it unconditionally as an import side effect. Our reanimatedWrapper catches the error and silently falls back to Reanimated = undefined.

This PR mocks reanimatedWrapper in Errors.test.tsx (same pattern as runOnJSReanimatedHandlers.test.tsx), which makes the suite independent of whether the real Reanimated can be imported under Jest. The mock additionally provides useComposedEventHandler, which InterceptingGestureDetector calls.

Test plan

  • yarn test — 19/19 suites, 159/159 tests pass (Errors.test.tsx was failing on main before this change)

@m-bert
m-bert requested review from j-piasecki and a lite review from Copilot August 26, 2026 11:08
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 55f1a3db-0ddf-49b5-8b55-d71e4a228a88

📥 Commits

Reviewing files that changed from the base of the PR and between cdc5c59 and ebf1ff6.

📒 Files selected for processing (1)
  • packages/react-native-gesture-handler/src/__tests__/Errors.test.tsx

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved gesture test reliability by preventing animation-library import failures.
    • Ensured gesture detection tests consistently run through the intended animation pathway.

Walkthrough

The change adds a test-only reanimatedWrapper mock to support gesture tests without Reanimated import failures. The mock covers handler, event, shared-value, and gesture-state APIs, while Worklets remains unavailable.

Changes

Gesture test support

Layer / File(s) Summary
Mock Reanimated gesture APIs
packages/react-native-gesture-handler/src/__tests__/Errors.test.tsx
The test setup mocks the Reanimated APIs used by gesture tests, including handler state, event callbacks, shared-value handling, and gesture-state updates. Worklets is set to undefined.

Merge Risk: ⚪ Minimal · up to ebf1f

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)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the test failure and its cause: Reanimated 4.6.0. It accurately describes the primary change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/reanimatedWrapper in Errors.test.tsx to avoid importing real Reanimated under Jest.
  • Extend the mock to include useComposedEventHandler, which is required by InterceptingGestureDetector.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +18 to +24
// 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', () => ({
@m-bert
m-bert merged commit 8819ea6 into main Aug 26, 2026
6 checks passed
@m-bert
m-bert deleted the @mbert/rea-ci branch August 26, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants