bun-test-react-native
v0.0.3
Published
Run React Native and Expo tests in Bun
Readme
bun-test-react-native
Run React Native and Expo tests in Bun
Usage
Preload the package test setup before app-specific test setup:
[test]
preload = ["bun-test-react-native/setup"]What It Does
React Native packages assume Metro, Jest, native modules, platform-specific files, and Flow syntax. Bun does not provide those behaviors by default, so this package adds the missing compatibility layer in two parts.
- Platform resolution: resolves
.ios.*,.native.*, then base files, so imports like./Viewcan land onView.ios.tsxorView.native.tsx. - React Native package fields: prefers React Native-specific package entry fields before generic package entries.
- Flow stripping: transpiles Flow-typed React Native package source before Bun parses it.
- React Native root exports: rewrites
react-native/index.jsCommonJS export definitions into usable static named exports for ESM consumers. - NativeModules shim: redirects React Native's internal
NativeModulesimport to a test/build-safe mock module. - Empty module shims: returns empty modules for platform files that React Native conventionally treats as unavailable.
- Asset imports: maps images, fonts, audio, and other React Native asset imports to lightweight JS modules.
- React Native test globals: sets
__DEV__, React act flags, animation frame timers,window,document,performance, andregeneratorRuntime. - Jest compatibility global: uses
bun-jest-require-actualto provideglobalThis.jest.requireActualon top of Bun test globals.
Supported Packages
Supports Expo SDK 56+ and React Native 0.57+ test environments.
bun-test-react-native/setup includes built-in test support for:
react-native@react-native/assets-registry@react-native-community/netinforeact-native-reanimatedreact-native-gesture-handlerreact-native-keyboard-controllerexpoexpo-modules-coreexpo-file-systemexpo-media-library@expo/uiexpo-fontexpo-constants@react-native-firebase/app@react-native-firebase/auth@react-native-firebase/messagingprettier, when available for packages that require it during test-time module evaluation
