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

fix(coverage): support overriding exclude #5997

Merged

Conversation

AriPerkkio
Copy link
Member

@AriPerkkio AriPerkkio commented Jun 28, 2024

Description

Previously Vitest did not allow user to override default coverage.exclude. In cases like #5964 this caused issues where users were completely unable to get coverage of files that were located in dist/**, as defaults were hard-coded and didn't allow overrides. Now Vitest allows users to completely override coverage.exclude.

This option overrides all default options. Extend the default options when adding new patterns to ignore:

import { coverageConfigDefaults, defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    coverage: {
      exclude: ['**/custom-pattern/**', ...coverageConfigDefaults.exclude]
    },
  },
})

https://vitest.dev/config/#coverage-exclude

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

Sorry, something went wrong.

@AriPerkkio
Copy link
Member Author

/ecosystem-ci run

@vitest-ecosystem-ci
Copy link

vitest-ecosystem-ci bot commented Jun 28, 2024

📝 Ran ecosystem CI: Open

suite result
aria-live-capture ✅ success
nuxt ❌ failure
nuxt-test-utils ❌ failure
elk ✅ success
effect ❌ failure
zustand ✅ success
vue ✅ success
vite ✅ success
vitest-vscode ❌ failure
vitest-sonar-reporter ✅ success
vitest-github-actions-reporter ✅ success
vitest-browser-simple ✅ success
vitest-browser-examples ❌ failure
vitest-coverage-large ✅ success
vitest-reporters-large ✅ success

@AriPerkkio AriPerkkio force-pushed the fix/coverage-exclude-override branch from 1b3c49a to 9ee4549 Compare June 29, 2024 11:55
@AriPerkkio AriPerkkio force-pushed the fix/coverage-exclude-override branch from 9ee4549 to 8014e0e Compare June 29, 2024 14:40
@AriPerkkio AriPerkkio force-pushed the fix/coverage-exclude-override branch from 8014e0e to c7f33bf Compare June 30, 2024 18:18
@sheremet-va sheremet-va merged commit 169bc1f into vitest-dev:main Jul 1, 2024
16 checks passed
@AriPerkkio AriPerkkio deleted the fix/coverage-exclude-override branch July 1, 2024 07:25
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.

coverage.exclude should be fully configurable
2 participants