Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also remap sources when remapping filenames #145

Merged
merged 1 commit into from
Mar 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/CoverageTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ export default class CoverageTransformer {
.forEach((filename) => {
const coverage = Object.assign({}, srcCoverage[filename]);
coverage.path = this.mapFileName(filename);
if (this.sourceStore && coverage.path !== filename) {
const source = this.sourceStore.get(filename);
this.sourceStore.set(coverage.path, source);
}
collector.add({
[coverage.path]: coverage
});
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/lib/remap.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,18 @@ define([
assert.strictEqual(coverageData.path, 'bar/tests/unit/support/basic.ts');
},

'mapFileName with sources': function () {
var store = new MemoryStore();
remap(loadCoverage('tests/unit/support/coverage-inlinesource.json'), {
sources: store,

mapFileName: function (filename) {
return 'bar/' + filename;
}
});
assert(store.map['bar/tests/unit/support/inlinesource.ts'], 'Source should be available on renamed file');
},

'useAbsolutePaths': function () {
var coverage = remap(loadCoverage('tests/unit/support/coverage.json'), {
useAbsolutePaths: true
Expand Down