diff --git a/packages/coverage-istanbul/src/provider.ts b/packages/coverage-istanbul/src/provider.ts index 0311e0729bef..5bc72843c51d 100644 --- a/packages/coverage-istanbul/src/provider.ts +++ b/packages/coverage-istanbul/src/provider.ts @@ -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) { diff --git a/packages/coverage-v8/src/provider.ts b/packages/coverage-v8/src/provider.ts index c067b3f512fe..19a88e71e56b 100644 --- a/packages/coverage-v8/src/provider.ts +++ b/packages/coverage-v8/src/provider.ts @@ -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) { diff --git a/packages/vitest/src/utils/coverage.ts b/packages/vitest/src/utils/coverage.ts index 49510a1565f4..e5755c330373 100644 --- a/packages/vitest/src/utils/coverage.ts +++ b/packages/vitest/src/utils/coverage.ts @@ -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 ( @@ -154,7 +156,7 @@ export class BaseCoverageProvider { )}` } - console.error(errorMessage) + onError(errorMessage) } } }