Skip to content

feat: attribute console logs to test attempts - #12158

Merged
sheremet-va merged 11 commits into
user-console-log-docsfrom
fix/issue-12123
Dec 1, 2026
Merged

sheremet-va merged 11 commits into
user-console-log-docsfrom
fix/issue-12123

Conversation

@hi-ogawa

@hi-ogawa hi-ogawa commented Dec 1, 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,
      )
    }
  }
}

hi-ogawa and others added 9 commits November 30, 2026 13:23
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# 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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	docs/api/advanced/test-case.md
@flakiness-io

flakiness-io Bot commented Dec 1, 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
6688bf8 ❌ Failed 1 regressed · 33555 passed · 234 flaky · 1261 skipped 30 runs

1 regressed

🔥 macOS 26.7.2 arm64 · main test/e2e/test/sequence-concurrent.test.ts:68 › applies sequence.concurrent per project (not just the root config)

⚠️ 234 flaky

⚠️ 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 · vmThreads 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 · 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
⚠️ 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 · vmThreads 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
⚠️ win 10.0.26100 · 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
hi-ogawa added this pull request to stack #12159 December 1, 2026 09:08
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Dec 1, 2026

Copy link
Copy Markdown

✅ Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit d258fe4
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6b0e8ea78a4e597e0ad87b3c
😎 Deploy Preview https://deploy-preview-12158--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.

@netlify

netlify Bot commented Dec 1, 2026

Copy link
Copy Markdown

✅ Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit 04b06e3
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6b0e8ed342ed6303ded288b6
😎 Deploy Preview https://deploy-preview-12158--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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hi-ogawa
hi-ogawa marked this pull request as ready for review December 1, 2026 10:05
@sheremet-va
sheremet-va merged commit 05a2fea into main Dec 1, 2026
27 of 30 checks passed
@sheremet-va
sheremet-va deleted the fix/issue-12123 branch December 1, 2026 10:51
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)

2 participants