Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Code Coverage in react app is empty? Tried using npm run test -- --coverage. But always showing empty code coverage

I need help to find code coverage.

I have just created a new app using the latest create-react-app.

I am trying to find the code coverage using npm run test -- --coverage. this is showing empty code coverage. Can any please help me to find where I am missing.

 PASS  src/__tests__/App.test.js
  ✓ renders without crashing (2ms)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |        0 |        0 |        0 |        0 |                   |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.17s, estimated 1s
Ran all test suites.

Watch Usage: Press w to show more.
like image 889
Umang Gupta Avatar asked Nov 24 '25 16:11

Umang Gupta


1 Answers

https://github.com/facebook/create-react-app/issues/6888

Just add flag --watchAll=false to your npm run test -- --coverage

like image 56
Mikhail Shemenyov Avatar answered Nov 27 '25 09:11

Mikhail Shemenyov