Skip to content

Commit

Permalink
fix: don't double-report files with mixed slashes in their names on w…
Browse files Browse the repository at this point in the history
…indows

For whatever reason, the remapped coverage re-creates paths for source files with mixed slashes. This means that the reporter adds duplicate entries that differ only by the joining path separator, confusing the report writer, which fails to report the coverage on either entry.
  • Loading branch information
peitschie committed Dec 21, 2018
1 parent 3c48bf8 commit 38087c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@ function CoverageIstanbulReporter(baseReporterDecorator, logger, config) {
.map;

if (!coverageConfig.skipFilesWithNoCoverage) {
// On Windows, istanbul returns files with mixed forward/backslashes in them
const fixedFilePaths = {};
remappedCoverageMap.files().forEach(path => {
fixedFilePaths[util.fixPathSeparators(path)] = true;
});
coverageMap.files().forEach(path => {
if (!(path in remappedCoverageMap)) {
if (!(util.fixPathSeparators(path) in fixedFilePaths)) {
// Re-add empty coverage record
remappedCoverageMap.addFileCoverage(path);
}
Expand Down
1 change: 1 addition & 0 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function overrideThresholds(key, overrides, basePath) {
return thresholds;
}

module.exports.fixPathSeparators = fixPathSeparators;
module.exports.fixWebpackSourcePaths = fixWebpackSourcePaths;
module.exports.fixWebpackFilePath = fixWebpackFilePath;
module.exports.overrideThresholds = overrideThresholds;

0 comments on commit 38087c2

Please sign in to comment.