[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix(coverage): remove work-around for implicit `else` (#6014)

authored by

Ari Perkkiö and committed by
GitHub
(Jul 2, 2024, 1:14 PM +0200) 368c1372 d87bef96

+18 -91
+6 -6
pnpm-lock.yaml
··· 506 506 specifier: ^3.0.1 507 507 version: 3.0.1 508 508 istanbul-lib-source-maps: 509 - specifier: ^5.0.5 510 - version: 5.0.5 509 + specifier: ^5.0.6 510 + version: 5.0.6 511 511 istanbul-reports: 512 512 specifier: ^3.1.7 513 513 version: 3.1.7 ··· 564 564 specifier: ^3.0.1 565 565 version: 3.0.1 566 566 istanbul-lib-source-maps: 567 - specifier: ^5.0.5 568 - version: 5.0.5 567 + specifier: ^5.0.6 568 + version: 5.0.6 569 569 istanbul-reports: 570 570 specifier: ^3.1.7 571 571 version: 3.1.7 ··· 11492 11492 make-dir: 4.0.0 11493 11493 supports-color: 7.2.0 11494 11494 11495 - /istanbul-lib-source-maps@5.0.5: 11496 - resolution: {integrity: sha512-gKf4eJ8bHmSX/ljiOCpnd8vtmHTwG71uugm0kXYd5aqFCl6z8cj8k7QduXSwU6QOst6LCdSXTlaoc8W4554crQ==} 11495 + /istanbul-lib-source-maps@5.0.6: 11496 + resolution: {integrity: sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==} 11497 11497 engines: {node: '>=10'} 11498 11498 dependencies: 11499 11499 '@jridgewell/trace-mapping': 0.3.25
+1 -1
packages/coverage-istanbul/package.json
··· 49 49 "istanbul-lib-coverage": "^3.2.2", 50 50 "istanbul-lib-instrument": "^6.0.3", 51 51 "istanbul-lib-report": "^3.0.1", 52 - "istanbul-lib-source-maps": "^5.0.5", 52 + "istanbul-lib-source-maps": "^5.0.6", 53 53 "istanbul-reports": "^3.1.7", 54 54 "magicast": "^0.3.4", 55 55 "picocolors": "^1.0.1",
+1 -1
packages/coverage-v8/package.json
··· 49 49 "debug": "^4.3.5", 50 50 "istanbul-lib-coverage": "^3.2.2", 51 51 "istanbul-lib-report": "^3.0.1", 52 - "istanbul-lib-source-maps": "^5.0.5", 52 + "istanbul-lib-source-maps": "^5.0.6", 53 53 "istanbul-reports": "^3.1.7", 54 54 "magic-string": "^0.30.10", 55 55 "magicast": "^0.3.4",
-43
packages/coverage-istanbul/src/provider.ts
··· 415 415 } 416 416 417 417 async function transformCoverage(coverageMap: CoverageMap) { 418 - includeImplicitElseBranches(coverageMap) 419 - 420 418 const sourceMapStore = libSourceMaps.createSourceMapStore() 421 419 return await sourceMapStore.transformCoverage(coverageMap) 422 420 } ··· 428 426 */ 429 427 function removeQueryParameters(filename: string) { 430 428 return filename.split('?')[0] 431 - } 432 - 433 - /** 434 - * Work-around for #1887 and #2239 while waiting for https://github.com/istanbuljs/istanbuljs/pull/706 435 - * 436 - * Goes through all files in the coverage map and checks if branchMap's have 437 - * if-statements with implicit else. When finds one, copies source location of 438 - * the if-statement into the else statement. 439 - */ 440 - function includeImplicitElseBranches(coverageMap: CoverageMap) { 441 - for (const file of coverageMap.files()) { 442 - const fileCoverage = coverageMap.fileCoverageFor(file) 443 - 444 - for (const branchMap of Object.values(fileCoverage.branchMap)) { 445 - if (branchMap.type === 'if') { 446 - const lastIndex = branchMap.locations.length - 1 447 - 448 - if (lastIndex > 0) { 449 - const elseLocation = branchMap.locations[lastIndex] 450 - 451 - if (elseLocation && isEmptyCoverageRange(elseLocation)) { 452 - const ifLocation = branchMap.locations[0] 453 - 454 - elseLocation.start = { ...ifLocation.start } 455 - elseLocation.end = { ...ifLocation.end } 456 - } 457 - } 458 - } 459 - } 460 - } 461 - } 462 - 463 - function isEmptyCoverageRange(range: libCoverage.Range) { 464 - return ( 465 - range.start === undefined 466 - || range.start.line === undefined 467 - || range.start.column === undefined 468 - || range.end === undefined 469 - || range.end.line === undefined 470 - || range.end.column === undefined 471 - ) 472 429 }
+6 -24
test/coverage-test/test/__snapshots__/pre-transpiled-istanbul.snapshot.json
··· 156 156 } 157 157 }, 158 158 { 159 - "start": { 160 - "line": 2, 161 - "column": 2 162 - }, 163 - "end": { 164 - "line": 5, 165 - "column": 3 166 - } 159 + "start": {}, 160 + "end": {} 167 161 } 168 162 ] 169 163 }, ··· 191 185 } 192 186 }, 193 187 { 194 - "start": { 195 - "line": 10, 196 - "column": 2 197 - }, 198 - "end": { 199 - "line": 13, 200 - "column": 3 201 - } 188 + "start": {}, 189 + "end": {} 202 190 } 203 191 ] 204 192 }, ··· 226 214 } 227 215 }, 228 216 { 229 - "start": { 230 - "line": 15, 231 - "column": 2 232 - }, 233 - "end": { 234 - "line": 18, 235 - "column": 3 236 - } 217 + "start": {}, 218 + "end": {} 237 219 } 238 220 ] 239 221 }
+4 -16
test/coverage-test/test/__snapshots__/results-istanbul.snapshot.json
··· 438 438 } 439 439 }, 440 440 { 441 - "start": { 442 - "line": 33, 443 - "column": 2 444 - }, 445 - "end": { 446 - "line": 36, 447 - "column": null 448 - } 441 + "start": {}, 442 + "end": {} 449 443 } 450 444 ] 451 445 }, ··· 473 467 } 474 468 }, 475 469 { 476 - "start": { 477 - "line": 39, 478 - "column": 2 479 - }, 480 - "end": { 481 - "line": 42, 482 - "column": null 483 - } 470 + "start": {}, 471 + "end": {} 484 472 } 485 473 ] 486 474 }