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

Per-directory coverage thresholds #3709

Closed
4 tasks done
lcswillems opened this issue Jun 30, 2023 · 3 comments · Fixed by #4442
Closed
4 tasks done

Per-directory coverage thresholds #3709

lcswillems opened this issue Jun 30, 2023 · 3 comments · Fixed by #4442
Labels
enhancement New feature or request feat: coverage Issues and PRs related to the coverage feature

Comments

@lcswillems
Copy link

Clear and concise description of the problem

I cannot set coverage thresholds globally and also for a specific directory.

Suggested solution

Something similar to coverageThreshold of Jest: https://jestjs.io/docs/configuration#coveragethreshold-object

Alternative

No response

Additional context

No response

Validations

@AriPerkkio AriPerkkio added enhancement New feature or request feat: coverage Issues and PRs related to the coverage feature labels Jun 30, 2023
@AriPerkkio
Copy link
Member

Now that @vitest/coverage-c8 is being deprecated, we can implement this for both coverage providers. I think it would be breaking change though, as option structure would change.

@adriengibrat
Copy link

I think it would be breaking change though, as option structure would change.

does not have to introduce Breaking change, "coverageThreshold" could be an alternative property like it is implemented in jest.

@AriPerkkio
Copy link
Member

The current option format would be replaced with new one.

These options:

{
  test: {
    coverage: {
      branches: 100,
      lines: 100,
      statements: 100,
      functions: 100,
    }
  }
}

would be replaced with these ones:

{
  test: {
    coverage: {
      threshold: {
        global {
          branches: 100,
          lines: 100,
          statements: 100,
          functions: 100,
        },
        "./src/utils/**": {
          lines: 80,
        }
      }
    }
  }
}

But sure, it doesn't have to be a breaking change at first. The coverage['lines'|'branches'|'statements'|'functions'] could be used as fallback for coverage.threshold.global before they are completely removed from configuration API.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request feat: coverage Issues and PRs related to the coverage feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants