Skip to content

Commit

Permalink
fix: Drop coverage produced by nyc --all for files that were tested
Browse files Browse the repository at this point in the history
Sometimes the coverage data produced by `nyc --all` is incompatible with
the coverage data produced by actual test runs.  This is generally due
to configuration error but results in inconsistent coverage reports or
in some cases causes `nyc report` to crash.  The workaround is
implemented in istanbul-lib-coverage to drop coverage data associated
with `nyc --all` when coverage data from a test run is found.  This
commit tags the coverage data when appropriate so the coverage merge
logic knows what to do.

Fixes istanbuljs#1113, istanbuljs#1124, istanbuljs#1148
  • Loading branch information
coreyfarrell committed Aug 1, 2019
1 parent 7783284 commit 57832e1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ class NYC {
const coverage = coverageFinder()
const lastCoverage = this.instrumenter().lastFileCoverage()
if (lastCoverage) {
coverage[lastCoverage.path] = lastCoverage
coverage[lastCoverage.path] = {
...lastCoverage,
// Only use this data if we don't have it without `all: true`
all: true
}
}
})
this.fakeRequire = false
Expand Down

0 comments on commit 57832e1

Please sign in to comment.