I am trying to start using jest in my React App but getting this error:
Test suite failed to run
TypeError: Cannot read property 'hasOwnProperty' of undefined
at node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:40:27
at Object.<anonymous> (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:1018:5)
at Object.<anonymous> (node_modules/react-test-renderer/shallow.js:6:20)
at Object.<anonymous> (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:11:39)
Test Suites: 1 failed, 1 total
This is what I have installed:
"devDependencies": {
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"jest-enzyme": "^7.1.2",
"jest": "^26.6.3",
This my starter code just to start testing:
import React from 'react';
import Enzyme from 'enzyme';
import EnzymeAdapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new EnzymeAdapter() });
test('should render without error', () => {});
I guess that problem is with Dependencies but not sure how I can fix it. If you say to remove Jest as it is coming with react, I get the same error even if I remove Jest
This is my test script:
"scripts": {
"test": "react-scripts test",
}