Skip to content

Commit

Permalink
fix(coverage-istanbul): clear coverage map after use (#2466)
Browse files Browse the repository at this point in the history
* test: add coverage snapshots

* fix(coverage-istanbul): clear coverage map after use

- Fixes issues where statement counts were duplicated
  • Loading branch information
AriPerkkio authored Dec 10, 2022
1 parent 286e9cf commit e6a18c7
Show file tree
Hide file tree
Showing 3 changed files with 1,613 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/coverage-istanbul/src/index.ts
Original file line number Diff line number Diff line change
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
}
Loading

0 comments on commit e6a18c7

Please sign in to comment.