jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
43.91k stars 6.4k forks source link

[Feature]: Isolated coverage reports #13876

Open CreativeTechGuy opened 1 year ago

CreativeTechGuy commented 1 year ago

šŸš€ Feature Proposal

An easy way to run Jest but generate coverage separately for each test file.

Motivation

A common pattern is to have a test file for each source file. But coverage is generated for the whole repo so one test can "accidentally" cover lines in another file. This leads to a problem where when for tests that need to be written based on code coverage, it shows that a branch is tested, but it may have been executed as a result of a different test suite that doesn't actually assert on the branch in question.

Example

Two parts:

Pitch

There's not an easy or efficient way to do this without it being built-in.

Currently the best/only way to do it is with a custom script that finds all test files, finds the associated source files for each test file (in our case that is based on the file name) and then run jest to test only a single test file and gather coverage from only the one source file. Then run Jest hundreds of times, one for each test file to generate coverage separately for each.

I don't believe this is a change to the default reporter rather a different way of triggering the reporter. The way that the reporters work would stay the same, it'd just be executed anew for each test file.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 1 year ago

Not stale

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 1 year ago

Still not stale

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 1 year ago

Not stale

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 1 year ago

Not stale

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 1 year ago

Not stale

github-actions[bot] commented 11 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 11 months ago

Still not stale

github-actions[bot] commented 10 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 10 months ago

Not stale

github-actions[bot] commented 9 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 9 months ago

Not stale

github-actions[bot] commented 8 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 8 months ago

Not stale

github-actions[bot] commented 7 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 7 months ago

Not stale (Happy holidays)

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 6 months ago

Not stale (Happy new year)

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 5 months ago

Not stale

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 4 months ago

Not stale

github-actions[bot] commented 3 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 3 months ago

Not stale

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 2 months ago

Not stale

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 1 month ago

Not stale

github-actions[bot] commented 15 hours ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

CreativeTechGuy commented 13 hours ago

Not stale

andriyor commented 4 hours ago

Hi, i made tool which allows to define coverage threshold per file tree https://github.com/andriyor/ts-tree-cli