create-react-app: test coverage is empty - v3.0.0
Is this a bug report?
yes, test coverage is always empty
After updating react-scripts
to 3.0.0 test coverage is always empty, this worked before in v2.1.8
v2.1.8
v3.0.0
Did you try recovering your dependencies?
This happens after booting an app up using create react app using typescript create-react-app cra-coverage-example --typescript
Which terms did you search for in User Guide?
n/a
Environment
Environment Info:
System:
OS: macOS 10.14.4
CPU: x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Binaries:
Node: 11.12.0 - ~/.nvm/versions/node/v11.12.0/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.7.0 - ~/.nvm/versions/node/v11.12.0/bin/npm
Browsers:
Chrome: 73.0.3683.103
Safari: 12.1
npmPackages:
react: ^16.8.6 => 16.8.6
react-dom: ^16.8.6 => 16.8.6
react-scripts: 3.0.0 => 3.0.0
npmGlobalPackages:
create-react-app: Not Found
Steps to Reproduce
- create-react-app cra-coverage-example --typescript
- yarn test --coverage
Expected Behavior
test coverage would be output
Actual Behavior
test coverage is always empty
Reproducible Demo
https://github.com/pete-redmond-cko/cra-coverage-example or you can spin up an app using create react app v.3.0.0 and run yarn test --coverage
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 19
- Comments: 39 (2 by maintainers)
Commits related to this issue
- Added working coverage command. Per https://github.com/facebook/create-react-app/issues/6888 — committed to DevUnltd/js-library-boilerplate by hodgef 5 years ago
- kent example — committed to lugithub/rabbit by lugithub 5 years ago
If you turn off watch via: yarn test --coverage --watchAll=false
It will work properly. Looks like a Jest bug. @stipsan
Jest needs more Jest tests to test the Jest.
try this one
It doesn’t fix it for me though. Still getting empty results
At this point, I haven’t seen a legit bug except for in a minor case (pressing ‘a’ in watch mode doesn’t retroactive show coverage). In all cases the feature is working as expected. If you disagree, please file a new issue with a clean repro so we can investigate. Thanks!
@sketchbuch For npm, you’ll need an extra set of dashes to get watchAll flag to work, something like:
npm run test:c -- --watchAll=false
, which produces result:Here I’ve changed one file, and the coverage also works correctly:
I have the same problem (v3.0.1). I can’t run coverage at all. It used to work, this is my repo: https://github.com/sketchbuch/school-report
when I run > npm run test:c
it says no tests have changed. --watchAll or --watchAll=false does nothing. Pressing “a” runs the tests but produces no coverage or even runs coverage. The coverage folder is created but contains just a few files - mostly little images used in the report display.