Skip to content

Commit

Permalink
test(jest): do enough fake react-native setup to fool new turbomodule…
Browse files Browse the repository at this point in the history
… init

it really wants to initialize things if you are not in the new interop mode,
and if you set the new interop mode then you need platform constants
  • Loading branch information
mikehardy committed Jan 22, 2024
1 parent e1ba719 commit 55c1c2c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ import * as ReactNative from 'react-native';
import { jest } from '@jest/globals';

jest.doMock('react-native', () => {
// @ts-ignore - react-native empty bridge config so native modules at least default init
global.__fbBatchedBridgeConfig = {};

// @ts-ignore - react-native new architecture interop flag to true
global.RN$TurboInterop = true;

// make sure PlatformConstants is visible otherwise turbo modules default init fails
ReactNative.NativeModules['PlatformConstants'] = {};

return Object.setPrototypeOf(
{
Platform: {
Expand Down

1 comment on commit 55c1c2c

@vercel
Copy link

@vercel vercel bot commented on 55c1c2c Jan 23, 2024

Choose a reason for hiding this comment

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

Please sign in to comment.