Having difficulty with generating Jest coverage reports for all committed files in my create-react-app.
Initially, code coverage was generating as expected, however something has changed in my environment, and now only files changed since the last commit are showing coverage.
I see there are many other posts about this issue, however I am unable to resolve it myself.
package.json:
{...
"devDependencies": {
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^12.6.3",
"react-test-renderer": "^17.0.1"
},
"jest": {
"testMatch": [ "**/tests/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)" ],
"coverageReporters": ["json","html","lcov", "text"]
}
...}
Project structure:
|
+--node_modules
+--src
|
+ __tests__
+ App.js
- package.json
Running command npm test -- --coverage
produces the following output:
No tests found related to files changed since last commit.
Press `a` to run all tests, or run Jest with `--watchAll`.
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 0 | 0 | 0 | 0 |
----------|---------|----------|---------|---------|-------------------
Watch Usage
? Press a to run all tests.
? Press f to run only failed tests.
? Press q to quit watch mode.
? Press p to filter by a filename regex pattern.
? Press t to filter by a test name regex pattern.
? Press Enter to trigger a test run.
question from:
https://stackoverflow.com/questions/66056448/jest-coverage-reporting-on-all-committed-files-in-create-react-app 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…