-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Workspace coverage wrong when a file transforms differently in projects #3251
Comments
@sheremet-va, is Coverage providers will then use |
Yes, they must be unique. The error will be thrown if they are not before tests are running. |
Describe the bug
Writing down the findings from #3226 (comment) with reproduction case. This affects both
@vitest/coverage-c8
and@vitest/coverage-istanbul
.If a single file can transform differently in different workspace projects, the final coverage reported by
@vitest/coverage-<x>
packages will be incorrect. For example:Here both client and server import
shared/user-list.js
with different code transforms. These produce two different code outputs and source maps.When generating coverage report the
@vitest/coverage-c8
picks the first source map it finds from project'svite-node
cache and uses it for both workspace projects. Instead it should be aware of which workspace project the current V8 coverage report belongs to, and use that project'svite-node
cache.I haven't yet debugged the
@vitest/coverage-istanbul
case but it's likely picking the first source map it encounters inistanbul-lib-source-maps
and re-uses that one for both file coverages. Instead it should separate each workspace projects'coverageMap
completely, and merge them at the end into one.Reproduction
Source
Transformed for workspace 1
Transformed for workspace 3
Coverage reports
From left to right: merged broken coverage, workspace 1 coverage, workspace 3 coverage:
The separate workspace specific reports look OK but the merged one is clearly broken.
Istanbul:
C8:
System Info
Vitest `main` + any
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: