Issue when running tests with --watchAll=false --coverage
Created by: kentcdodds
Describe 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.