Skip to content

Commit 55c1c2c

Browse files
committed
test(jest): do enough fake react-native setup to fool new turbomodule 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
1 parent e1ba719 commit 55c1c2c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

jest.setup.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ import * as ReactNative from 'react-native';
22
import { jest } from '@jest/globals';
33

44
jest.doMock('react-native', () => {
5+
// @ts-ignore - react-native empty bridge config so native modules at least default init
6+
global.__fbBatchedBridgeConfig = {};
7+
8+
// @ts-ignore - react-native new architecture interop flag to true
9+
global.RN$TurboInterop = true;
10+
11+
// make sure PlatformConstants is visible otherwise turbo modules default init fails
12+
ReactNative.NativeModules['PlatformConstants'] = {};
13+
514
return Object.setPrototypeOf(
615
{
716
Platform: {

0 commit comments

Comments
 (0)