Skip to content

Commit

Permalink
fix(coverage): pass thresholds errors to stderr of startVitest() (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio authored Jun 23, 2024
1 parent e9ddf9c commit 7080513
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/coverage-istanbul/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export class IstanbulCoverageProvider
this.checkThresholds({
thresholds: resolvedThresholds,
perFile: this.options.thresholds.perFile,
onError: error => this.ctx.logger.error(error),
})

if (this.options.thresholds.autoUpdate && allTestsRun) {
Expand Down
1 change: 1 addition & 0 deletions packages/coverage-v8/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ export class V8CoverageProvider
this.checkThresholds({
thresholds: resolvedThresholds,
perFile: this.options.thresholds.perFile,
onError: error => this.ctx.logger.error(error),
})

if (this.options.thresholds.autoUpdate && allTestsRun) {
Expand Down
4 changes: 3 additions & 1 deletion packages/vitest/src/utils/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ export class BaseCoverageProvider {
checkThresholds({
thresholds: allThresholds,
perFile,
onError,
}: {
thresholds: ResolvedThreshold[]
perFile?: boolean
onError: (error: string) => void
}) {
for (const { coverageMap, thresholds, name } of allThresholds) {
if (
Expand Down Expand Up @@ -154,7 +156,7 @@ export class BaseCoverageProvider {
)}`
}

console.error(errorMessage)
onError(errorMessage)
}
}
}
Expand Down

0 comments on commit 7080513

Please sign in to comment.