diff --git a/packages/coverage-istanbul/package.json b/packages/coverage-istanbul/package.json index 43aed3563883..19470d96561c 100644 --- a/packages/coverage-istanbul/package.json +++ b/packages/coverage-istanbul/package.json @@ -49,7 +49,7 @@ "istanbul-lib-coverage": "^3.2.2", "istanbul-lib-instrument": "^6.0.3", "istanbul-lib-report": "^3.0.1", - "istanbul-lib-source-maps": "^5.0.5", + "istanbul-lib-source-maps": "^5.0.6", "istanbul-reports": "^3.1.7", "magicast": "^0.3.4", "picocolors": "^1.0.1", diff --git a/packages/coverage-istanbul/src/provider.ts b/packages/coverage-istanbul/src/provider.ts index 60b08c6a55c0..480a54d47b77 100644 --- a/packages/coverage-istanbul/src/provider.ts +++ b/packages/coverage-istanbul/src/provider.ts @@ -415,8 +415,6 @@ export class IstanbulCoverageProvider } async function transformCoverage(coverageMap: CoverageMap) { - includeImplicitElseBranches(coverageMap) - const sourceMapStore = libSourceMaps.createSourceMapStore() return await sourceMapStore.transformCoverage(coverageMap) } @@ -429,44 +427,3 @@ async function transformCoverage(coverageMap: CoverageMap) { function removeQueryParameters(filename: string) { return filename.split('?')[0] } - -/** - * Work-around for #1887 and #2239 while waiting for https://github.com/istanbuljs/istanbuljs/pull/706 - * - * Goes through all files in the coverage map and checks if branchMap's have - * if-statements with implicit else. When finds one, copies source location of - * the if-statement into the else statement. - */ -function includeImplicitElseBranches(coverageMap: CoverageMap) { - for (const file of coverageMap.files()) { - const fileCoverage = coverageMap.fileCoverageFor(file) - - for (const branchMap of Object.values(fileCoverage.branchMap)) { - if (branchMap.type === 'if') { - const lastIndex = branchMap.locations.length - 1 - - if (lastIndex > 0) { - const elseLocation = branchMap.locations[lastIndex] - - if (elseLocation && isEmptyCoverageRange(elseLocation)) { - const ifLocation = branchMap.locations[0] - - elseLocation.start = { ...ifLocation.start } - elseLocation.end = { ...ifLocation.end } - } - } - } - } - } -} - -function isEmptyCoverageRange(range: libCoverage.Range) { - return ( - range.start === undefined - || range.start.line === undefined - || range.start.column === undefined - || range.end === undefined - || range.end.line === undefined - || range.end.column === undefined - ) -} diff --git a/packages/coverage-v8/package.json b/packages/coverage-v8/package.json index 979674cc50b9..3f424951fb60 100644 --- a/packages/coverage-v8/package.json +++ b/packages/coverage-v8/package.json @@ -49,7 +49,7 @@ "debug": "^4.3.5", "istanbul-lib-coverage": "^3.2.2", "istanbul-lib-report": "^3.0.1", - "istanbul-lib-source-maps": "^5.0.5", + "istanbul-lib-source-maps": "^5.0.6", "istanbul-reports": "^3.1.7", "magic-string": "^0.30.10", "magicast": "^0.3.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 70bcf568f2b7..1c9c4fafeb7f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -506,8 +506,8 @@ importers: specifier: ^3.0.1 version: 3.0.1 istanbul-lib-source-maps: - specifier: ^5.0.5 - version: 5.0.5 + specifier: ^5.0.6 + version: 5.0.6 istanbul-reports: specifier: ^3.1.7 version: 3.1.7 @@ -564,8 +564,8 @@ importers: specifier: ^3.0.1 version: 3.0.1 istanbul-lib-source-maps: - specifier: ^5.0.5 - version: 5.0.5 + specifier: ^5.0.6 + version: 5.0.6 istanbul-reports: specifier: ^3.1.7 version: 3.1.7 @@ -11492,8 +11492,8 @@ packages: make-dir: 4.0.0 supports-color: 7.2.0 - /istanbul-lib-source-maps@5.0.5: - resolution: {integrity: sha512-gKf4eJ8bHmSX/ljiOCpnd8vtmHTwG71uugm0kXYd5aqFCl6z8cj8k7QduXSwU6QOst6LCdSXTlaoc8W4554crQ==} + /istanbul-lib-source-maps@5.0.6: + resolution: {integrity: sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==} engines: {node: '>=10'} dependencies: '@jridgewell/trace-mapping': 0.3.25 diff --git a/test/coverage-test/test/__snapshots__/pre-transpiled-istanbul.snapshot.json b/test/coverage-test/test/__snapshots__/pre-transpiled-istanbul.snapshot.json index ae61082635ad..ee97c6cbd987 100644 --- a/test/coverage-test/test/__snapshots__/pre-transpiled-istanbul.snapshot.json +++ b/test/coverage-test/test/__snapshots__/pre-transpiled-istanbul.snapshot.json @@ -156,14 +156,8 @@ } }, { - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } + "start": {}, + "end": {} } ] }, @@ -191,14 +185,8 @@ } }, { - "start": { - "line": 10, - "column": 2 - }, - "end": { - "line": 13, - "column": 3 - } + "start": {}, + "end": {} } ] }, @@ -226,14 +214,8 @@ } }, { - "start": { - "line": 15, - "column": 2 - }, - "end": { - "line": 18, - "column": 3 - } + "start": {}, + "end": {} } ] } diff --git a/test/coverage-test/test/__snapshots__/results-istanbul.snapshot.json b/test/coverage-test/test/__snapshots__/results-istanbul.snapshot.json index a9df3f490fe7..96501cf5bf90 100644 --- a/test/coverage-test/test/__snapshots__/results-istanbul.snapshot.json +++ b/test/coverage-test/test/__snapshots__/results-istanbul.snapshot.json @@ -438,14 +438,8 @@ } }, { - "start": { - "line": 33, - "column": 2 - }, - "end": { - "line": 36, - "column": null - } + "start": {}, + "end": {} } ] }, @@ -473,14 +467,8 @@ } }, { - "start": { - "line": 39, - "column": 2 - }, - "end": { - "line": 42, - "column": null - } + "start": {}, + "end": {} } ] }