Closed
Description
Describe the bug
__fbBatchedBridgeConfig is not set, cannot invoke native modules
error occurs when trying to render a simple RN component.
Important to mention, that this is an expo app in a monorepo, this is the repo/commit.
The test is dead simple and fails due to wrong configuration I think.
// index.test.tsx
import React from 'react';
import {Text, View} from 'react-native';
import {render} from '@testing-library/react-native';
const HelloWorld = () => (
<View>
<Text>Hello from the machine!</Text>
</View>
);
describe('<App />', () => {
it('has 2 child', () => {
render(<HelloWorld />);
});
});
//jest.config.js
module.exports = {
preset: 'react-native',
setupFilesAfterEnv: ['./jest.setup.js'],
transformIgnorePatterns: [
'node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)',
],
};
Expected behavior
No errors when rendering a simple RN component.
Steps to Reproduce
git clone git@github.com:vanGalilea/react-native-testing.git
cd react-native-testing/
git checkout feat/expo-app
yarn
cd apps/rn-expo-app/
yarn test
Screenshots/ Full Error
Trying to detect host component names triggered the following error:
__fbBatchedBridgeConfig is not set, cannot invoke native modules
There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.
Please check if you are using compatible versions of React Native and React Native Testing Library.
11 | describe('<App />', () => {
12 | it('has 2 child', () => {
> 13 | render(<HelloWorld />);
| ^
14 | });
15 | });
16 |
at detectHostComponentNames (../../node_modules/@testing-library/react-native/src/helpers/host-component-names.tsx:56:11)
at detectHostComponentNames (../../node_modules/@testing-library/react-native/src/helpers/host-component-names.tsx:27:30)
at renderInternal (../../node_modules/@testing-library/react-native/src/render.tsx:49:40)
at renderInternal (../../node_modules/@testing-library/react-native/src/render.tsx:32:10)
at Object.<anonymous> (__tests__/app/index.test.tsx:13:11)
Versions
Weirdly enough when running:
npx envinfo --npmPackages react,react-native,react-test-renderer,@testing-library/react-native
I only get:
npmPackages:
react-native: 0.73.2 => 0.73.2
So from yarn.lock
:
@testing-library/react-native => 12.4.3
jest => 29.7.0
jest-expo => 50.0.1
react => 18.2.0
react-native => 0.73.2
Metadata
Metadata
Assignees
Labels
No labels