Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
TypeError: Cannot read properties of undefined (reading 'add'). Error on running jest test

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!