Coming from Karma I like to keep a browser tab opened to check the code coverage of my tests from time to time. Is possible with a jest to generate the coverage folder without jest printing the coverage in the console?
I have not found out any cli or config about this.
You can set up coverageReporters
config for jest like this:
jest.config.js
:
module.exports = {
// ...
coverageReporters: ['json', 'lcov', 'clover']
};
By default, the value of coverageReporters
configuration is ["json", "lcov", "text", "clover"]
As you can see, if you don't want to print the coverage report in stdout, you need to remove text
reporter.
Before:
PASS src/stackoverflow/53934331/authService.spec.ts
authService
#postAuthUser
✓ login user (6ms)
----------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------------|----------|----------|----------|----------|-------------------|
All files | 100 | 100 | 100 | 100 | |
authService.ts | 100 | 100 | 100 | 100 | |
----------------|----------|----------|----------|----------|-------------------|
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 3.703s
After:
PASS src/stackoverflow/53934331/authService.spec.ts
authService
#postAuthUser
✓ login user (5ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 3.64s