Skip to content

Commit

Permalink
fix(coverage): fix sourcemaps of uncovered lines
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Oct 6, 2022
1 parent a3e624b commit cbe0373
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/coverage-istanbul/src/provider.ts
Expand Up @@ -211,7 +211,7 @@ export class IstanbulCoverageProvider implements CoverageProvider {

const lastCoverage = this.instrumenter.lastFileCoverage()
if (lastCoverage)
coverageMap.data[lastCoverage.path] = lastCoverage
coverageMap.addFileCoverage(lastCoverage)
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions test/coverage-test/src/untested-file.ts
@@ -1,3 +1,33 @@
/*
* Some top level comment which adds some padding. This helps us see
* if sourcemaps are off.
*/

export default function untestedFile() {
return 'This file should end up in report when {"all": true} is given'
}

function add(a: number, b: number) {
// This line should NOT be covered
return a + b
}

function multiply(a: number, b: number) {
// This line should NOT be covered
return a * b
}

export function math(a: number, b: number, operator: '*' | '+') {
if (operator === '*') {
// This line should NOT be covered
return multiply(a, b)
}

if (operator === '+') {
// This line should NOT be covered
return add(a, b)
}

// This line should NOT be covered
throw new Error('Unsupported operator')
}

0 comments on commit cbe0373

Please sign in to comment.