Nothing Special   »   [go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Isolated coverage reports #13876

Open
CreativeTechGuy opened this issue Feb 8, 2023 · 43 comments
Open

[Feature]: Isolated coverage reports #13876

CreativeTechGuy opened this issue Feb 8, 2023 · 43 comments

Comments

@CreativeTechGuy
Copy link

🚀 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:

  • An option to generate multiple coverage reports for a single Jest run (eg: one coverage report per test file)
  • The ability to define collectCoverageFrom as a function which is passed the current test file as an argument so you can dynamically set which source files coverage can be collected from given the test that is running.

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
Copy link

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.

@github-actions github-actions bot added the Stale label Mar 10, 2023
@CreativeTechGuy
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Mar 10, 2023
@github-actions
Copy link
github-actions bot commented Apr 9, 2023

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.

@github-actions github-actions bot added the Stale label Apr 9, 2023
@CreativeTechGuy
Copy link
Author

Still not stale

@github-actions github-actions bot removed the Stale label Apr 10, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label May 10, 2023
@CreativeTechGuy
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label May 11, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label Jun 10, 2023
@CreativeTechGuy
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Jun 11, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label Jul 11, 2023
@CreativeTechGuy
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Jul 16, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label Aug 15, 2023
@CreativeTechGuy
Copy link
Author

Still not stale

@github-actions github-actions bot removed the Stale label Aug 15, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label Sep 14, 2023
@CreativeTechGuy
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Sep 14, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot removed the Stale label Apr 20, 2024
Copy link

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.

@github-actions github-actions bot added the Stale label May 20, 2024
@CreativeTechGuy
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label May 20, 2024
Copy link

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.

@github-actions github-actions bot added the Stale label Jun 19, 2024
@CreativeTechGuy
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Jun 19, 2024
Copy link

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.

@github-actions github-actions bot added the Stale label Jul 19, 2024
@CreativeTechGuy
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Jul 19, 2024
@andriyor
Copy link

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

Copy link

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.

@github-actions github-actions bot added the Stale label Aug 19, 2024
@CreativeTechGuy
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Aug 19, 2024
Copy link

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.

@github-actions github-actions bot added the Stale label Sep 18, 2024
@CreativeTechGuy
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Sep 21, 2024
Copy link

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.

@github-actions github-actions bot added the Stale label Oct 21, 2024
@CreativeTechGuy
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Oct 21, 2024
Copy link

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.

@github-actions github-actions bot added the Stale label Nov 20, 2024
@CreativeTechGuy
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants