question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jest test pass but I always get a “Nothing was returned from render” error when running jest coverage

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:23 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
NdV66commented, Aug 17, 2020

I updated my CRA project with yarn add --exact react-scripts@3.4.3 and I still cannot run coverage. Using react-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).

4reactions
chrkaatzcommented, Oct 28, 2020

The same issue happens with react-scripts@4.0.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest test pass but I always get a "Nothing was returned from ...
Jest test pass but I always get a "Nothing was returned from render " error when running jest coverage ... Note: I already...
Read more >
Jest mock axios instance typescript - hs-barssel.de
Mocking axios in a vue3 typescript unit test using jest and vue-test-utils2 ... folder Enzyme/Jest: Component(): Nothing was returned from render After ...
Read more >
CS50's Mobile App Development with React Native 2018
1:29:37We wanted a component, but nothing was returned from render. 1:29:40Well, great. 1:29:41Our tests caught an error.
Read more >
`undefined` cannot be serialized as JSON-Reactjs
Getting props as undefined in component returned from getStaticProps · test --coverage throwing "Nothing was returned from render." error · 'AADSTS500011' ...
Read more >
Deploying, Testing - CS50's Mobile App Development with ...
Deploying, Testing. CS50 Video Player. Screen. Shortcuts ... 1:29:37We wanted a component, but nothing was returned from render. 1:29:40Well, great.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found