I am getting the following error in a test with jest:
TypeError: Cannot read property 'add' of undefined
● Test suite failed to run
TypeError: Cannot read properties of undefined (reading 'add')
at Object.<anonymous> (node_modules/@react-navigation/stack/lib/commonjs/utils/conditional.tsx:3:9)
at Object.<anonymous> (node_modules/@react-navigation/stack/lib/commonjs/TransitionConfigs/CardStyleInterpolators.tsx:7:1)
I am mocking the navigator like this:
interface IProps {
component: any,
params?: any,
type: 'stack' | 'tab'
}
const Stack = createStackNavigator();
const TabsNav = createBottomTabNavigator();
const MockedNavigator = ({ component, type, params = {} }: IProps) => {
return (
<Provider store={store}>
<NavigationContainer>
{ type === 'stack' ? (
<Stack.Navigator>
<Stack.Screen
name="MockedScreen"
component={ component }
initialParams={ params }
/>
</Stack.Navigator>
) : (
<TabsNav.Navigator
initialRouteName="HomeScreen"
>
<TabsNav.Screen
name="MockedScreen"
component={ component }
initialParams={ params }
/>
</TabsNav.Navigator>
)}
</NavigationContainer>
<FlashMessage position="top" testID="flash-message"/>
</Provider>
);
};
export default MockedNavigator;
"react-native": "0.69.1",
"@react-navigation/native": "^6.0.11",
"@react-navigation/stack": "^6.2.2",
"babel-jest": "^26.6.3",
"jest": "^26.6.3",
"react-test-renderer": "18.0.0",
"@testing-library/jest-native": "^4.0.5",
"@testing-library/react-native": "^10.1.1",
I appreciate any help with this problem.