Jest test pass but I always get a “Nothing was returned from render” error when running jest coverage
See original GitHub issueNote: I used create-react-app to create a new App, but I got an error I cant fix, I already looked through similar questions; the solutions provided do not solve my problem.
I am getting the following error in my React app:
console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29 <br> Error: Uncaught [Error: Test(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.]
My Jest plug dependencies:
"@testing-library/jest-dom": "^5.11.0",
"@testing-library/react": "^10.4.6",
"@testing-library/user-event": "^12.0.11",
"babel-eslint": "10.1.0",
"babel-jest": "^24.9.0",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.6",
"babel-preset-react-app": "^9.1.2",
I try to search reason on google and get taht maybe this issue caused by babel version, solution looks like below
{ "presets": [ [""@babel/preset-react"", { "pragma": "React.createElement" }] ] }
but we use babel-preset-react-app, so could you help advise how to resolve this issue?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:23 (2 by maintainers)
Top GitHub Comments
I updated my CRA project with
yarn add --exact react-scripts@3.4.3
and I still cannot run coverage. Usingreact-scripts test --env=jest-environment-jsdom-sixteen --coverage
I have empty coverage table/report. With--coverage --watchAll
I have the same problem as is described above (a lot of errors with these variables vs without flags all tests are passed).The same issue happens with react-scripts@4.0.0