I've been using jest --coverage to calculate coverage for my code. I've added a coverageThreshold
in jest.config.js but this only checks whole codebase/folder coverage.
I also tried jest -o
(--onlyChanged
) but this generates coverage percent for the entire file making actual new line coverage seem higher than it is.
Is there any way to check jest --coverage
coverage percentage on new lines only (not changed lines)??
EXAMPLE: whole file coverage example, will pass global threshold of 95%. one new if statement line, didn't write a test for:
--------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------|---------|----------|---------|---------|-------------------
All files | 96.15 | 95.83 | 100 | 95.83 |
changeFile.tsx| 96.15 | 95.83 | 100 | 95.83 | 119
--------------|---------|----------|---------|---------|-------------------
EXAMPLE: as supposed to NEW line coverage example, will fail if global threshold is 95%, fails due to one of the lines not covered.
--------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered New Line #s
--------------|---------|----------|---------|---------|-------------------
changeFile.tsx| 50.00 | 100 | 100 | 100 | 1/2
--------------|---------|----------|---------|---------|-------------------
tried:
jest -o
(--onlyChanged
) , --lastCommit, --changedSince
but they only calculate coverage percent of entire changed file
If theres other coverage tools that can accomplish this, suggestions would be appreciated :)