Skip to content

Coverage report is wrong (lower) when code is executed by many separate test files #11776

@ipsips

Description

@ipsips

🐛 Bug Report

Since upgrading to jest 27 (i have 27.0.6 atm) the coverage is not reported correctly. My project is massive in which some utility modules are executed in lots of unit tests while these utilities do not have unit tests of their own. Prior to jest 27 this wasn't a problem as other test exercised these utilities fully and thus they were covered 100%. Now it seems that some of that coverage gets lost

To Reproduce

Clone https://github.com/ipsips/jest-coverage-problem and issue npm test.

Expected behavior

Expecting 100% coverage on get1.ts but I consistently get less:

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |   81.82 |    66.67 |     100 |   81.82 |                   
 get1.ts  |   66.67 |       50 |     100 |   66.67 | 5-6               
 get2.ts  |     100 |      100 |     100 |     100 |                   
...
 get99.ts |     100 |      100 |     100 |     100 |                   
----------|---------|----------|---------|---------|-------------------

If you delete get3.ts through get100.ts and leave only get1.ts and get2.ts (with their spec files ofc) then coverage is 100% as expected.

Link to repl or repo (highly encouraged)

https://github.com/ipsips/jest-coverage-problem

envinfo

this problem also occurs for others in my team with various op systems

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions