-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Labels
Description
Describe the bug
When using vitest's projects configuration with multiple environments (e.g., jsdom for unit tests and browser for component tests), files that are covered by both projects get duplicate coverage entries, resulting in inflated statement/function/branch counts.
For example, a file with 15 statements is reported as having 29 statements in the combined coverage report.
Reproduction
Repository: https://github.com/stevez/restaurant-reviews-platform
Branch: test/vitest-coverage-bug
Steps:
- Clone the repo and checkout the branch
git clone https://github.com/stevez/restaurant-reviews-platform cd restaurant-reviews-platform git checkout test/vitest-coverage-bug
Run npm install
Run npx vitest --coverage
Check coverage for src/lib/constants.ts - it shows 29 statements instead of 15
System Info
System: OS: Windows 11 Node: v22.x Packages: vitest: 4.0.x @vitest/coverage-v8: 4.0.xUsed Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.