Skip to content

Failure screenshot of a retried test always shows the last attempt #11614

Closed

Description

@hi-ogawa

Describe the bug

When a browser-mode test fails on every retry, the failure summary prints one error per attempt, and each one lists the same failure screenshot path. Every attempt writes its screenshot to the same file, so only the last attempt's image survives. The screenshot shown under the first attempt's error is actually the last attempt's page.

 FAIL  |chromium| basic.test.ts > retried
AssertionError: expected 1 to be 10
Failure screenshot:
  - .vitest/attachments/failure-screenshots/basic.test.ts/retried.png
⎯⎯⎯[1/3]⎯
 FAIL  |chromium| basic.test.ts > retried
AssertionError: expected 2 to be 10
Failure screenshot:
  - .vitest/attachments/failure-screenshots/basic.test.ts/retried.png
⎯⎯⎯[2/3]⎯
 FAIL  |chromium| basic.test.ts > retried
AssertionError: expected 3 to be 10
Failure screenshot:
  - .vitest/attachments/failure-screenshots/basic.test.ts/retried.png
⎯⎯⎯[3/3]⎯

retried.png shows the attempt 3 button.

There are two parts to this:

#11232 (for #10303) records each attempt's errors with its retry and repeat index, so the reporter can tell which attempt produced an error. That is enough for the trace timeline from #11592 (#11594), because browser trace artifacts already record retry and repeats. Failure screenshots would still need the artifact to record its attempt in the same way, and a file name per attempt.

Reproduction

import { expect, test } from 'vitest'
import { page } from 'vitest/browser'

let attempt = 0
test('retried', { retry: 2 }, async () => {
  attempt++
  document.body.innerHTML = `<button>attempt ${attempt}</button>`
  await page.getByText(`attempt ${attempt}`).click()
  expect(attempt).toBe(10)
})

Run with browser mode enabled and screenshotFailures: true (the default).

System Info

Vitest main (b61d1ce), Playwright provider, chromium.

Activity

  1. added theissue type on Oct 16, 2026
  2. added
    feat: browserIssues and PRs related to the browser runner
    p3-minor-bugAn edge case that only affects very specific usage (priority)
    and removed
    feat: browserIssues and PRs related to the browser runner
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: browserIssues and PRs related to the browser runnerp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions