Skip to content

fix(🧪): Jest mock - #441

Merged
wcandillon merged 1 commit into
mainfrom
feat/jest-mock
Jul 29, 2026
Merged

fix(🧪): Jest mock#441
wcandillon merged 1 commit into
mainfrom
feat/jest-mock

Conversation

@wcandillon

Copy link
Copy Markdown
Owner

TurboModuleRegistry.getEnforcing("WebGPUModule") throws at import time under Jest since there's no native binary, so any app that imports react-native-webgpu (even just to render a screen that uses ) crashes its test suite.

Add src/mock.ts, a JS-only stand-in with no native module dependency: Canvas renders as a plain View, and GPU-dependent APIs (importDevice, adoptTexture, useDevice, a real canvas context) throw a clear error if a test actually exercises them. Ship it via a root jestSetup.js (added to setupFilesAfterEnv) following the same pattern used by react-native-reanimated, react-native-worklets, and @shopify/react-native-skia.

TurboModuleRegistry.getEnforcing("WebGPUModule") throws at import time
under Jest since there's no native binary, so any app that imports
react-native-webgpu (even just to render a screen that uses <Canvas>)
crashes its test suite.

Add src/mock.ts, a JS-only stand-in with no native module dependency:
Canvas renders as a plain View, and GPU-dependent APIs (importDevice,
adoptTexture, useDevice, a real canvas context) throw a clear error if
a test actually exercises them. Ship it via a root jestSetup.js
(added to setupFilesAfterEnv) following the same pattern used by
react-native-reanimated, react-native-worklets, and
@shopify/react-native-skia.
@wcandillon wcandillon changed the title feat(🧪): Jest mock fix(🧪): Jest mock Jul 29, 2026
@wcandillon
wcandillon merged commit 4584b94 into main Jul 29, 2026
1 of 2 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant