Skip to content

Commit

Permalink
fix: don't call onCoverage hook if there is no coverage to report
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jan 14, 2025
1 parent 077f230 commit 33c8544
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/advanced/api/reporters.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ import type { CoverageMap } from 'istanbul-lib-coverage'
declare function onCoverage(coverage: CoverageMap): Awaitable<void>
```

If Vitest didn't perform any coverage, this hook is not called.

## onTestModuleQueued

```ts
Expand Down
4 changes: 3 additions & 1 deletion packages/vitest/src/node/test-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export class TestRun {
])
}
finally {
await this.vitest.report('onCoverage', coverage)
if (coverage) {
await this.vitest.report('onCoverage', coverage)
}
}
}

Expand Down

0 comments on commit 33c8544

Please sign in to comment.