Skip to content

Commit

Permalink
fix(coverage-istanbul): clear coverage map after use
Browse files Browse the repository at this point in the history
- Fixes issues where statement counts were duplicated
  • Loading branch information
AriPerkkio committed Dec 9, 2022
1 parent e66cbec commit 4db5786
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/coverage-istanbul/src/index.ts
Expand Up @@ -7,5 +7,11 @@ export async function getProvider() {

export function takeCoverage() {
// @ts-expect-error -- untyped global
return globalThis[COVERAGE_STORE_KEY]
const coverage = globalThis[COVERAGE_STORE_KEY]

// Reset coverage map to prevent duplicate results if this is called twice in row
// @ts-expect-error -- untyped global
globalThis[COVERAGE_STORE_KEY] = {}

return coverage
}

0 comments on commit 4db5786

Please sign in to comment.