Skip to content

Commit

Permalink
fix: duplicated files when "skipFilesWithNoCoverage=false" on windows
Browse files Browse the repository at this point in the history
Co-authored-by: Cristian Danilo Gutiérrez <cristian.gutierrez@globant.com>
  • Loading branch information
CrisDan1905 and Cristian Danilo Gutiérrez committed May 28, 2020
1 parent 5f3f030 commit 052f6ab
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/util.js
Expand Up @@ -17,7 +17,7 @@ function fixPathSeparators(filePath) {
const isWin = process.platform.startsWith('win');
// Workaround for https://github.com/mattlewis92/karma-coverage-istanbul-reporter/issues/9
if (isWin && filePath) {
return filePath.replace(/\//g, '\\');
return filePath.replace(/\//g, '\\').replace(/\\\\/g, '\\');
}

return filePath;
Expand Down
31 changes: 31 additions & 0 deletions test/util.spec.js
@@ -1,5 +1,6 @@
const { expect } = require('chai');
const { fixWebpackSourcePaths } = require('../src/util');
const { fixPathSeparators } = require('../src/util');

const originalPlatform = process.platform;

Expand Down Expand Up @@ -244,4 +245,34 @@ describe('util', () => {
).to.deep.equal(output);
});
});

describe('fixPathSeparators', () => {
let input;

beforeEach(() => {
input =
'\\Users\\mattlewis\\Code\\/open-source/karma-coverage-istanbul-reporter\\test\\fixtures\\typescript';
});

it('Should transform any forwardslash into backslash and remove any leftover backslash if OS is Windows', () => {
Object.defineProperty(process, 'platform', {
value: 'win32',
});

const output =
'\\Users\\mattlewis\\Code\\open-source\\karma-coverage-istanbul-reporter\\test\\fixtures\\typescript';

expect(fixPathSeparators(input)).to.deep.equal(output);
});

it('Should not transform any forwardslash into backslash if OS is different from Windows', () => {
Object.defineProperty(process, 'platform', {
value: 'linux',
});

const output = input;

expect(fixPathSeparators(input)).to.deep.equal(output);
});
});
});

0 comments on commit 052f6ab

Please sign in to comment.