react-test-renderer cannot find the render function of the react-native component
See original GitHub issueDo you want to request a feature or report a bug? A bug
What is the current behavior? When I run my tests and I render my component (using the shallow function of Enzyme) it fails because it can’t find the render function.
TypeError: this._instance.render is not a function
> 45 | wrapper = shallow(<NewEventScreen navigation={navigation} />);
| ^
47 | });
48 |
at ReactShallowRenderer._mountClassComponent (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:195:37)
at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:143:14)
at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:337:35
at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:110:16)
at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:336:68)
at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:170:22)
at shallow (node_modules/enzyme/build/shallow.js:21:10)
at Object.<anonymous> (src/screens/new-event/__tests__/NewEventScreen.test.js:45:15)
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn’t have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
I am developing a react-native application. I am running the default jest command to run the tests and this happens. I can’t reproduce it in a small project.
What is the expected behavior? It should run the tests
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? I am using: “@babel/core”: “^7.0.0-beta.47”, “prop-types”: “15.6.2”, “react”: “16.4.1”, “react-dom”: “16.4.2”, “react-native”: “0.56.0”, “@babel/core”: “^7.0.0-beta”, “babel-core”: “^7.0.0-beta”, “babel-jest”: “23.4.2”, “babel-preset-react-native”: “5.0.2”, “babel-runtime”: “^7.0.0-beta”, “enzyme”: “3.4.1”, “enzyme-adapter-react-16”: “1.2.0”, “jest”: "23.5.0 ", “jest-fetch-mock”: “1.6.5”, “jsdom”: “11.12.0”, “react-test-renderer”: “16.4.1”,
My jest configuration is in jest.config.js
module.exports = {
preset: 'react-native',
setupFiles: ['./jest.setup.js'], // in here i am just loading global.fetch = require('jest-fetch-mock');
};
and my babel config in babel.config.js
module.exports = {
presets: [
['react-native'],
],
};
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)

Top Related StackOverflow Question
this breaks when i upgrade test renderer from 16.4.2 to 16.5.1. I am also using react native, but I don’t think it has anything to do with that.
thanks for the tip Dan - it doesn’t seem to work in my case unfortunately. I’ve created an issue over at
react-native(https://github.com/facebook/react-native/issues/20683) along with a repo that highlights the regression (https://github.com/deecewan/react-native-jest-regression).