Jest test pass but I always get a “Nothing was returned from render” error when running jest coverage
Created by: DLJames
Note: 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?