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

feat(coverage): thresholds to support maximum uncovered items #7061

Merged
merged 8 commits into from
Dec 17, 2024

Conversation

jonahkagan
Copy link
Contributor

@jonahkagan jonahkagan commented Dec 10, 2024

Description

Closes #7056

Match Jest's API for coverage thresholds, treating a positive number as the minimum covered percentage (lines: 90 means 90% of lines must be covered) and a negative number as the maximum uncovered count (lines: -10 means no more than 10 lines may be uncovered).

When using negative coverage thresholds with the autoUpdate flag, set the new thresholds based on the reported number of uncovered entities. If there are no uncovered entities, set the threshold to 100%.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Match Jest's API for coverage thresholds, treating positive numbers as percentage thresholds (`lines: X` means X% of lines must be covered) and negative numbers as absolute thresholds (`lines: -X` means no more than X lines may be uncovered).
When using absolute coverage thresholds (configured using negative numbers) with the `autoUpdate` flag, set the new thresholds based on the reported number of uncovered entities. If there are no uncovered entities, set the threshold to 100%.
Remove links to Istanbul docs since those docs only talk about
percentage thresholds (and they don't contain any additional information
that isn't already in the vitest docs).
Copy link

netlify bot commented Dec 10, 2024

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit e9fc7eb
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/676087d89efbc10008781ab8
😎 Deploy Preview https://deploy-preview-7061--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jonahkagan jonahkagan marked this pull request as ready for review December 10, 2024 20:46
@jonahkagan
Copy link
Contributor Author

I see one test failure in CI that appears to be an unrelated test: test/timeout.spec.ts. I don't think I have permission to re-run the job to see if this test might be flaky.

@AriPerkkio AriPerkkio changed the title feat(coverage): support configuring coverage thresholds as minimum percentages or maximum uncovered items feat(coverage): thresholds to support maximum uncovered items Dec 11, 2024
@jonahkagan jonahkagan mentioned this pull request Dec 11, 2024
4 tasks
Copy link
Member

@AriPerkkio AriPerkkio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Glad to see that thresholds.autoUpdate didn't require that much complex logic. Also test cases seem to cover all cases - nice! 💯

Left some minor improvement ideas.

docs/config/index.md Show resolved Hide resolved
packages/vitest/src/utils/coverage.ts Outdated Show resolved Hide resolved
test/coverage-test/test/threshold-absolute-failure.test.ts Outdated Show resolved Hide resolved
Copy link
Member

@AriPerkkio AriPerkkio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@AriPerkkio AriPerkkio merged commit bde98b6 into vitest-dev:main Dec 17, 2024
17 checks passed
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

Successfully merging this pull request may close these issues.

Absolute coverage thresholds
2 participants