I'm trying to run jest --coverage --watch so that I only get the coverage for whatever component I'm writing tests for and I can see the increased coverage as I write more tests. But while the modified tests are successfully picked up and run, the coverage report comes up empty.
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 0 | 0 | 0 | 0 | |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 2 passed, 2 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 5.599s
Ran all test suites related to changed files.
The documentation on this is almost zero, but it seems like it should work according to this pr: https://github.com/facebook/jest/pull/5601
Here is a solution Create a jest.config.js and add the following content
module.exports = {
collectCoverage: true,
coverageReporters: [
"html"
]
};
And in package.json:
"scripts": {
"test": "jest --watchAll"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With