Skip to content

Commit

Permalink
fix: remove inputSourceMap before instrumenting
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Aug 12, 2020
1 parent 1b52fe7 commit 06407d7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/istanbul-lib-instrument/src/visitor.js
Expand Up @@ -632,6 +632,10 @@ function programVisitor(types, sourceFilePath = 'unknown.js', opts = {}) {
sourceMappingURL: visitState.sourceMappingURL
};
}
const { inputSourceMap } = coverageData;
// remove `inputSourceMap` before we output coverage data to source code
// because it is not a plain object
delete coverageData.inputSourceMap;
coverageData[MAGIC_KEY] = MAGIC_VALUE;
const hash = createHash(SHA)
.update(JSON.stringify(coverageData))
Expand All @@ -640,6 +644,10 @@ function programVisitor(types, sourceFilePath = 'unknown.js', opts = {}) {
const coverageNode = T.valueToNode(coverageData);
delete coverageData[MAGIC_KEY];
delete coverageData.hash;
// restore `inputSourceMap`
if (inputSourceMap) {
coverageData.inputSourceMap = inputSourceMap;
}
let gvTemplate;
if (opts.coverageGlobalScopeFunc) {
if (path.scope.getBinding('Function')) {
Expand Down

0 comments on commit 06407d7

Please sign in to comment.