Improve the message when run coverage while there are no tests
See original GitHub issue🐛 Bug Report
When you run jest
with --coverage
but there are no tests, it shows error “Jest: Coverage data for global was not found.”
To Reproduce
-
Delete all test files e.g. *.test.js
-
Run
jest --config=jest.json --coverage
with below configuration injest.json
:
{
"testEnvironment": "node",
"coverageThreshold": {
"global": {
"branches": 90,
"functions": 90,
"lines": 90,
"statements": -10
}
},
"collectCoverageFrom" : [
"*.js"
]
}
Expected behavior
A simple and clear error like “No tests found”, or simply skipping coverage, or coverage report as usual (and failed 100%).
Link to repl or repo (highly encouraged)
https://github.com/Tiendq/lego-part-loader
Run npx envinfo --preset jest
System:
OS: macOS Sierra 10.12.6
Binaries:
Node: 10.0.0 - /usr/local/bin/node
Yarn: 1.6.0 - /usr/local/bin/yarn
npm: 5.6.0 - /usr/local/bin/npm
npmPackages:
jest: ^22.4.3 => 22.4.3
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Improve your component test coverage with this one weird trick
Improve your component test coverage with this one weird trick ... While the pragmatic answer is 'no', sometimes you need to accept that ......
Read more >Troubleshooting Code Coverage - Visual Studio (Windows)
Explanation—Code coverage analysis is done while tests are running. It only includes assemblies that are loaded into memory when the tests run.
Read more >How To Test a React App with Jest and React Testing Library
No tests found related to files changed since last commit. Press `a` to run all tests, or run Jest with `--watchAll`. Watch Usage...
Read more >Why Code Coverage in react app is empty? Tried using npm ...
If you just created a new app and you're getting no code coverage it's most likely because no tests have been written. You...
Read more >How do I increase my code coverage, or why can't I cover ...
After running unit tests, if the line starting with a.Description is not covered, it's an indication that the loop never begins iterating ......
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
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’d like to try this if no one is on it 😄
Here’s where that error is thrown, should be able to add the check you need somewhere in that function with a nice explination