Issue when running tests with --watchAll=false --coverage
See original GitHub issueDescribe the bug
When I attempt to run my tests with coverage in CI (or locally for that matter) I get an error: App(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.
Did you try recovering your dependencies?
N/A (happens on a fresh bootstrap of a new app
Which terms did you search for in User Guide?
N/A, though I did search for the error in the issues and found nothing
Environment
Environment Info:
current version of create-react-app: 3.4.1
running from /Users/kentcdodds/.npm/_npx/59115/lib/node_modules/create-react-app
System:
OS: macOS 10.15.3
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Binaries:
Node: 12.13.1 - ~/n/bin/node
Yarn: 1.21.1 - ~/.yarn/bin/yarn
npm: 6.14.3 - /usr/local/bin/npm
Browsers:
Chrome: 80.0.3987.149
Firefox: 71.0
Safari: 13.0.5
npmPackages:
react: ^16.13.1 => 16.13.1
react-dom: ^16.13.1 => 16.13.1
react-scripts: 3.4.1 => 3.4.1
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
Reproduction steps:
npm create react-app coverage-issues
cd coverage-issues
npx react-scripts test --watchAll=false --coverage
Expected behavior
I expect the test to pass and coverage to be reported
Actual behavior
Here’s the relevant output:
FAIL src/App.test.js
✕ renders learn react link (22ms)
● renders learn react link
App(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.
4 |
5 | test('renders learn react link', () => {
> 6 | const { getByText } = render(<App />);
| ^
7 | const linkElement = getByText(/learn react/i);
8 | expect(linkElement).toBeInTheDocument();
9 | });
at reconcileChildFibers (node_modules/react-dom/cjs/react-dom.development.js:14348:23)
at reconcileChildren (node_modules/react-dom/cjs/react-dom.development.js:16762:28)
at mountIndeterminateComponent (node_modules/react-dom/cjs/react-dom.development.js:17542:5)
at beginWork (node_modules/react-dom/cjs/react-dom.development.js:18596:16)
at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:188:14)
at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:237:16)
at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:292:31)
at beginWork$1 (node_modules/react-dom/cjs/react-dom.development.js:23203:7)
at performUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:22157:12)
at workLoopSync (node_modules/react-dom/cjs/react-dom.development.js:22130:22)
at performSyncWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:21756:9)
at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom.development.js:21188:7)
at updateContainer (node_modules/react-dom/cjs/react-dom.development.js:24373:3)
at node_modules/react-dom/cjs/react-dom.development.js:24758:7
at unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:21903:12)
at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:24757:5)
at Object.render (node_modules/react-dom/cjs/react-dom.development.js:24840:10)
at node_modules/@testing-library/react/dist/pure.js:86:25
at batchedUpdates$1 (node_modules/react-dom/cjs/react-dom.development.js:21856:12)
at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:929:14)
at render (node_modules/@testing-library/react/dist/pure.js:82:26)
at Object.<anonymous> (src/App.test.js:6:25)
Reproducible demo
The reproduction steps should be enough. You don’t need to change anything about the generated project.
I am also experiencing this in all of my react-scripts
apps. I think this only started happening in the last week or so.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:47
- Comments:25 (2 by maintainers)
Top Results From Across the Web
What's the difference between '--watchAll=false' and 'CI=true'?
In the documentation for running tests, it states the following: "By default npm test runs the watcher with interactive CLI. However, you can ......
Read more >Running Tests | Create React App
*Although we recommend running your tests in watch mode during development, you can disable this behavior by passing in the --watchAll=false ...
Read more >Create react app typescript: testing with jest and enzyme
In this article, you can find how to get jest and enzyme ready for your tests and Istanbul to collect the coverage. It...
Read more >@wolox/js-test-coverage-script - npm
Script to retrieve lcov test coverage and put into code_coverage.json ... keep these options --watchAll=false --silent --coverageThreshold ...
Read more >Jest CLI Options
Run tests related to changed files based on hg/git (uncommitted files): ... jest --watchAll #runs all tests ... jest --collect-coverage
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Top GitHub Comments
Ran into this issue today. Downgraded to
react-scripts
3.4.0
in my package.json as a workaround.We are experiencing this with the
--coverage
flag, even if--watchAll=false
is removed.