You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Various test runners (Jest, Vitest, Playwright) support a sharding option with --shard. When test runners run in this mode coverage is generated differently in each shard.
Example:
If A.ts is a dependency of the tests in --shard=1/2 and not a dependency of the tests in --shard=2/2 then the first shard's coverage report will reference a MappedCoverage instance of A.ts but the second shard will reference a FileCoverage instance.
Attempting to merge these files using istanbuljs will lead to inaccurate coverage. Presumably due to the mismatch in line numbers.
Workaround / Potential Solution
To work around this issue we can apply patches to istanbul-lib-coverage and istanbul-lib-source-maps which adds a new isMapped property denoting whether or not a file is an instance of MappedCoverage. We then prefer MappedCoverage over FileCoverage and prevent merges of MappedCoverage with FileCoverage for the same file.
These patches only work when using the same TestRunner across merges! Solving for differing test-runners is a more complicated issue due to differences in transformation
Various test runners (Jest, Vitest, Playwright) support a sharding option with
--shard
. When test runners run in this mode coverage is generated differently in each shard.Example:
If
A.ts
is a dependency of the tests in--shard=1/2
and not a dependency of the tests in--shard=2/2
then the first shard's coverage report will reference aMappedCoverage
instance ofA.ts
but the second shard will reference aFileCoverage
instance.Attempting to merge these files using
istanbuljs
will lead to inaccurate coverage. Presumably due to the mismatch in line numbers.Workaround / Potential Solution
To work around this issue we can apply patches to
istanbul-lib-coverage
andistanbul-lib-source-maps
which adds a newisMapped
property denoting whether or not a file is an instance ofMappedCoverage
. We then preferMappedCoverage
overFileCoverage
and prevent merges ofMappedCoverage
withFileCoverage
for the same file.istanbul-lib-coverage+3.2.2.patch
istanbul-lib-source-maps+4.0.0.patch
These patches only work when using the same TestRunner across merges! Solving for differing test-runners is a more complicated issue due to differences in transformation
Related Issues
The text was updated successfully, but these errors were encountered: