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

[test-runner] Support per-file code coverage threshold restrictions #2834

Open
miyasudokoro opened this issue Oct 25, 2024 · 0 comments
Open

Comments

@miyasudokoro
Copy link

There is a configuration "per-file" that exists in code-coverage libraries such as c8 and nyc that allows restricting code coverage metric thresholds per each file rather than in the aggregate or summary of all files. It would be very nice to have this feature in the test-runner code coverage.

Here's an example for why someone would want this feature. Let's say you have the following coverage config and code coverage summary:

{
    "threshold": {
        "lines": 30,
        "functions": 30,
        "statements": 30,
        "branches": 30
    },
    "perFile": false,
    .... other configurations
}

--------------------------------------|---------|----------|---------|---------|-------------------------------------------
File                                  | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------------------------------|---------|----------|---------|---------|-------------------------------------------
All files                             |   61.75 |    83.92 |   31.77 |   61.75 |                                                                         
 src/js                               |   62.38 |    85.45 |   32.07 |   62.38 |                                           
  notcovered.js                       |       0 |        0 |       0 |       0 | 1-6                                       
  templater.js                        |   62.63 |    87.03 |   32.38 |   62.63 | ...270-1272,1277-1281,1412-1432,1459-1461 
--------------------------------------|---------|----------|---------|---------|-------------------------------------------

This code coverage passes because the "All files" summary percentages are all above 30%. However, if you set "perFile" to true, then this code coverage would fail because the notcovered.js file is only at 0%.

I am willing to implement this myself. I have always had "per-file" turned on in the past, so I would like to be able to use it here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant