From f1f34482df738e560262570d3155d5e019a4d9f1 Mon Sep 17 00:00:00 2001 From: Matthew Preble Date: Sat, 18 Apr 2020 09:03:35 -0500 Subject: [PATCH] Remove the concept of using Jest's stored sourceMaps to map BabelCoverage - inputSourceMap should always be available. --- packages/jest-reporters/src/coverage_reporter.ts | 7 ------- packages/jest-reporters/src/generateEmptyCoverage.ts | 10 +++++----- packages/jest-transform/src/ScriptTransformer.ts | 3 --- packages/jest-types/src/Transform.ts | 1 - 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/packages/jest-reporters/src/coverage_reporter.ts b/packages/jest-reporters/src/coverage_reporter.ts index b769743e2ff6..68ba5ab5bfc0 100644 --- a/packages/jest-reporters/src/coverage_reporter.ts +++ b/packages/jest-reporters/src/coverage_reporter.ts @@ -215,13 +215,6 @@ export default class CoverageReporter extends BaseReporter { ]); } else { this._coverageMap.addFileCoverage(result.coverage); - - if (result.sourceMapPath) { - this._sourceMapStore.registerURL( - filename, - result.sourceMapPath, - ); - } } } } catch (error) { diff --git a/packages/jest-reporters/src/generateEmptyCoverage.ts b/packages/jest-reporters/src/generateEmptyCoverage.ts index 62ab4c023f2c..b6c270060fdd 100644 --- a/packages/jest-reporters/src/generateEmptyCoverage.ts +++ b/packages/jest-reporters/src/generateEmptyCoverage.ts @@ -18,7 +18,6 @@ export type CoverageWorkerResult = | { kind: 'BabelCoverage'; coverage: FileCoverage; - sourceMapPath?: string | null; } | { kind: 'V8Coverage'; @@ -66,9 +65,11 @@ export default function ( } // Transform file with instrumentation to make sure initial coverage data is well mapped to original code. - const {code, mapCoverage, sourceMapPath} = new ScriptTransformer( - config, - ).transformSource(filename, source, true); + const {code} = new ScriptTransformer(config).transformSource( + filename, + source, + true, + ); // TODO: consider passing AST const extracted = readInitialCoverage(code); // Check extracted initial coverage is not null, this can happen when using /* istanbul ignore file */ @@ -76,7 +77,6 @@ export default function ( coverageWorkerResult = { coverage: createFileCoverage(extracted.coverageData), kind: 'BabelCoverage', - sourceMapPath: mapCoverage ? sourceMapPath : null, }; } } diff --git a/packages/jest-transform/src/ScriptTransformer.ts b/packages/jest-transform/src/ScriptTransformer.ts index 2b92994b503a..cb5d9e1d9e79 100644 --- a/packages/jest-transform/src/ScriptTransformer.ts +++ b/packages/jest-transform/src/ScriptTransformer.ts @@ -296,7 +296,6 @@ export default class ScriptTransformer { // two separate processes write concurrently to the same cache files. return { code, - mapCoverage: false, originalCode: content, sourceMapPath, }; @@ -385,7 +384,6 @@ export default class ScriptTransformer { return { code, - mapCoverage: false, originalCode: content, sourceMapPath, }; @@ -431,7 +429,6 @@ export default class ScriptTransformer { return { code, - mapCoverage: false, originalCode: content, sourceMapPath, }; diff --git a/packages/jest-types/src/Transform.ts b/packages/jest-types/src/Transform.ts index 9c59e7b34489..43e9ff986eb1 100644 --- a/packages/jest-types/src/Transform.ts +++ b/packages/jest-types/src/Transform.ts @@ -9,6 +9,5 @@ export type TransformResult = { code: string; originalCode: string; - mapCoverage: boolean; sourceMapPath: string | null; };