Skip to content

Commit 7080513

Browse files
authored
fix(coverage): pass thresholds errors to stderr of startVitest() (#5954)
1 parent e9ddf9c commit 7080513

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

packages/coverage-istanbul/src/provider.ts

+1
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ export class IstanbulCoverageProvider
336336
this.checkThresholds({
337337
thresholds: resolvedThresholds,
338338
perFile: this.options.thresholds.perFile,
339+
onError: error => this.ctx.logger.error(error),
339340
})
340341

341342
if (this.options.thresholds.autoUpdate && allTestsRun) {

packages/coverage-v8/src/provider.ts

+1
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ export class V8CoverageProvider
324324
this.checkThresholds({
325325
thresholds: resolvedThresholds,
326326
perFile: this.options.thresholds.perFile,
327+
onError: error => this.ctx.logger.error(error),
327328
})
328329

329330
if (this.options.thresholds.autoUpdate && allTestsRun) {

packages/vitest/src/utils/coverage.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@ export class BaseCoverageProvider {
9595
checkThresholds({
9696
thresholds: allThresholds,
9797
perFile,
98+
onError,
9899
}: {
99100
thresholds: ResolvedThreshold[]
100101
perFile?: boolean
102+
onError: (error: string) => void
101103
}) {
102104
for (const { coverageMap, thresholds, name } of allThresholds) {
103105
if (
@@ -154,7 +156,7 @@ export class BaseCoverageProvider {
154156
)}`
155157
}
156158

157-
console.error(errorMessage)
159+
onError(errorMessage)
158160
}
159161
}
160162
}

0 commit comments

Comments
 (0)