Skip to content

feat: attribute console logs to test attempts - #12141

Closed
hi-ogawa wants to merge 8 commits into
vitest-dev:mainfrom
hi-ogawa:fix/issue-12123
Closed

hi-ogawa wants to merge 8 commits into
vitest-dev:mainfrom
hi-ogawa:fix/issue-12123

Conversation

@hi-ogawa

@hi-ogawa hi-ogawa commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds retryIndex and repeatIndex to UserConsoleLog.

Previously, a reporter could not directly tell which attempt printed a console log, and #12123 mentioned matching UserConsoleLog's taskId and time against testCase.attempts() as a workaround.

Example

let runs = 0
test('flaky', { retry: 2 }, () => {
  console.log('attempt')
  expect(++runs).toBe(3)
})
// =>
//  three UserConsoleLog with
//  content   | retryIndex | repeatIndex
//  'attempt' | 0          | 0
//  'attempt' | 1          | 0
//  'attempt' | 2          | 0

A reporter can then group the logs of each attempt:

onTestRunEnd(modules: ReadonlyArray<TestModule>) {
  for (const test of modules.flatMap(m => [...m.children.allTests()])) {
    for (const attempt of test.attempts()) {
      const logsFromAttempt = test.logs().filter(
        log => log.retryIndex === attempt.retryIndex && log.repeatIndex === attempt.repeatIndex,
      )
    }
  }
}

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 8c43974
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6b0e83385aa6e0c197008ec5
😎 Deploy Preview https://deploy-preview-12141--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@flakiness-io

flakiness-io Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Test Results Summary

This comment shows the latest test results for this pull request.

Commit Status Test Results CI Runs
a4385f2 ❌ Failed 1 failed · 33541 passed · 234 flaky · 1256 skipped 29 runs

1 failed

❌ Ubuntu 26.04 · chromium test/ui/test/ui.spec.ts:310 › html report › annotations in the report tab

⚠️ 234 flaky

⚠️ Ubuntu 26.04 · threads test/unit/test/retry.test.ts:55 › describe object add(1, 1) › returned value not be greater than 2
⚠️ win 10.0.26100 · vmThreads test/unit/test/retry.test.ts:55 › describe object add(1, 1) › returned value not be greater than 2
⚠️ win 10.0.26100 · threads test/unit/test/retry.test.ts:55 › describe object add(1, 1) › returned value not be greater than 2
⚠️ Ubuntu 26.04 · threads test/unit/test/retry.test.ts:55 › describe object add(1, 1) › returned value not be greater than 2
⚠️ Ubuntu 26.04 · vmThreads test/unit/test/retry.test.ts:55 › describe object add(1, 1) › returned value not be greater than 2
⚠️ Ubuntu 26.04 · forks test/unit/test/retry.test.ts:55 › describe object add(1, 1) › returned value not be greater than 2
⚠️ win 10.0.26100 · forks test/unit/test/retry.test.ts:55 › describe object add(1, 1) › returned value not be greater than 2
⚠️ Ubuntu 26.04 · vmThreads test/unit/test/retry.test.ts:55 › describe object add(1, 1) › returned value not be greater than 2
⚠️ Ubuntu 26.04 · forks test/unit/test/retry.test.ts:55 › describe object add(1, 1) › returned value not be greater than 2
⚠️ Ubuntu 26.04 · threads test/unit/test/retry.test.ts:61 › describe object add(1, 1) › returned value not be less than 2
…and 224 more

View full report

ℹ️ About Flakiness.io in GitHub

Your team has set up Flakiness.io pull request comments. This comment is updated when

  • The first test results arrive for this pull request
  • A later run reports more results for the same commit
  • A new commit is pushed and tested

Flakiness.io rewrites the comment in place, so it always reflects the most recently tested commit.

hi-ogawa and others added 5 commits December 1, 2026 15:42
# Conflicts:
#	packages/vitest/src/runtime/console.ts
#	packages/vitest/src/runtime/runner/run.ts
#	packages/vitest/src/runtime/runner/test-state.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moved to a separate docs PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hi-ogawa and others added 2 commits December 1, 2026 17:20
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hi-ogawa

hi-ogawa commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

Recreated from an upstream branch as #12158, stacked on #12157.

@hi-ogawa hi-ogawa closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attribute onUserConsoleLog output to test attempts (retryIndex / repeatIndex)

1 participant