Skip to content

Commit

Permalink
fix(coverage-analysis): make sure to not erase sourceMappingURL comme…
Browse files Browse the repository at this point in the history
…nt (#625)

The default for `preserveComments` of istanbul-lib-instrumenter was changed (true to false). Make sure it is true so the sourceMappingURL is not overitten.
  • Loading branch information
nicojs authored and simondel committed Feb 14, 2018
1 parent 75026dc commit eed7147
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/stryker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"esprima": "^2.7.0",
"glob": "^7.0.3",
"inquirer": "^3.0.6",
"istanbul-lib-instrument": "^1.9.1",
"istanbul-lib-instrument": "^1.9.2",
"lodash": "^4.17.4",
"log4js": "^1.1.0",
"mkdirp": "^0.5.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class CoverageInstrumenterTranspiler implements Transpiler {
private log: Logger;

constructor(private settings: TranspilerOptions, private testFramework: TestFramework | null) {
this.instrumenter = createInstrumenter({ coverageVariable: this.coverageVariable });
this.instrumenter = createInstrumenter({ coverageVariable: this.coverageVariable, preserveComments: true });
this.log = getLogger(CoverageInstrumenterTranspiler.name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ describe('CoverageInstrumenterTranspiler', () => {
expect(instrumentedContent).to.contain('function something(){cov_').and.contain('.f[0]++');
});

it('should preserve source map comments', async () => {
const input = [
textFile({ mutated: true, content: 'function something() {} // # sourceMappingUrl="something.map.js"' }),
];
const output = await sut.transpile(input);
expect(output.error).null;
const instrumentedContent = (output.outputFiles[0] as TextFile).content;
expect(instrumentedContent).to.contain('sourceMappingUrl="something.map.js"');
});

it('should create a statement map for mutated files', () => {
const input = [
textFile({ name: 'something.js', mutated: true, content: 'function something () {}' }),
Expand Down

0 comments on commit eed7147

Please sign in to comment.