From 55c1c2cb404f857cefa69854e95990bdba7e74cf Mon Sep 17 00:00:00 2001 From: Mike Hardy Date: Mon, 22 Jan 2024 18:09:21 -0500 Subject: [PATCH] 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 --- jest.setup.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jest.setup.ts b/jest.setup.ts index 155bdbf347..1713754b9c 100644 --- a/jest.setup.ts +++ b/jest.setup.ts @@ -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: {