In NextJS app, I am trying to include unit test using Jest and react-testing-library
When I tried to test using yarn test, I am getting the following error
console.error
Error: Uncaught [TypeError: React.createContext is not a function]
at reportException (/home/admin-1/Documents/unit-test/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:62:24)
Current react version:
"react": "^17.0.2",
"react-dom": "^17.0.2",
Current devDependencies :
"@babel/core": "^7.8.6",
"@babel/preset-env": "^7.8.6",
"@babel/preset-react": "^7.8.3",
"@testing-library/jest-dom": "^5.1.1",
"@testing-library/react": "^9.4.1",
"babel-jest": "^25.1.0",
"babel-plugin-styled-components": "^1.10.7",
"jest": "^25.1.0",
"jest-axe": "^3.3.0",
"prettier": "^2.2.1",
"react-test-renderer": "^16.13.0"
Tried to: Update my react and react-dom node modules (did not help)