From 3c0f998b28e6de50e08b4ee8c58d2aba17c61a38 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa <4232207+hi-ogawa@users.noreply.github.com> Date: Fri, 11 Sep 2026 11:14:29 +0900 Subject: [PATCH] fix(runner): track failed repeats separately Co-authored-by: Codex (GPT-6) --- packages/vitest/src/runtime/runner/run.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/vitest/src/runtime/runner/run.ts b/packages/vitest/src/runtime/runner/run.ts index 2be9f8965..e57b63cfb 100644 --- a/packages/vitest/src/runtime/runner/run.ts +++ b/packages/vitest/src/runtime/runner/run.ts @@ -616,11 +616,10 @@ async function runTest(test: Test, runner: VitestRunner): Promise { const $ = runner.trace! const repeats = test.repeats ?? 0 - let failedRepeatErrors: TestError[] | undefined + let hasFailedRepeat = false for (let repeatCount = 0; repeatCount <= repeats; repeatCount++) { // Force widening to TaskState because TypeScript cannot track mutations made by hooks and the test. test.result.state = 'run' as TaskState - test.result.errors = undefined const retry = getRetryCount(test.retry) for (let retryCount = 0; retryCount <= retry; retryCount++) { let beforeEachCleanups: unknown[] = [] @@ -767,14 +766,12 @@ async function runTest(test: Test, runner: VitestRunner): Promise { } if (test.result.state === 'fail') { - failedRepeatErrors ??= [] - failedRepeatErrors.push(...test.result.errors || []) + hasFailedRepeat = true } } - if (failedRepeatErrors) { + if (hasFailedRepeat) { test.result.state = 'fail' - test.result.errors = failedRepeatErrors } // if test is marked to be failed, flip the result unless `TestSyntaxError` is present -- 2.51.2