Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6211

cannot test renderer.create in react-native, react-navigation, jest, react-test-renderer

$
0
0

I am trying to just test that my app renders correctly using jest and no matter what i do i get

TypeError: Cannot read property 'create' of undefined

at Object.create (node_modules/react-navigation-drawer/lib/commonjs/views/DrawerSidebar.js:1:3876) at Object.require (node_modules/react-navigation-drawer/lib/commonjs/views/DrawerView.js:1:1222)

now the issue is if i mock out react-navigation-drawer this error then moves to the next react-navigation stack and so on and so forth. all the way until it hits my components then this error appears in my components.

this tells me something is happening where react-test-renderer,Jest does't like how react-navigation sets up your app container.

import 'react-native';import React from 'react';import App from '../App';// Note: test renderer must be required after react-native.import renderer from 'react-test-renderer';it('renders correctly', () => {  renderer.create(<App />);});

const App = () => {  return (<AppContainer />  );};

"jest": {"preset": "react-native","moduleFileExtensions": ["ts","tsx","js","jsx","json","node"    ],"transformIgnorePatterns": ["node_modules/(?!react-native|react-navigation)/"    ],"setupFiles": ["./node_modules/react-native-gesture-handler/jestSetup.js","./testenv.js"    ]  }

Viewing all articles
Browse latest Browse all 6211

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>