Skip to content

[Regression] Browser mode: Failure screenshot not created when unstable error occurs in v4.1.0-beta.4 #9690

@sandra555

Description

@sandra555

Describe the bug

Regression: In v4.1.0-beta.4, the changes from #9552 (fix: don't take failure screenshot if tests have artifacts created by toMatchScreenshot) unintentionally prevent a failure screenshot from being captured and saved in unstable test failures.

Problem:
When a test fails with an unstable screenshot error (e.g., Could not capture a stable screenshot within...), Vitest now only provides a reference screenshot artifact. This makes it impossible to see what was actually rendered at the point of instability, hampering debugging ability. Previously, an 'internal:failureScreenshot' artifact was attached, but after this change, it is missing for these failures if any internal:toMatchScreenshot artifacts exist.

Expected:
When a test fails due to instability or any other reason that doesn't generate regular diff/actual artifacts, the failure screenshot should still be saved and attached, probably in .vitest-attachments folder though and not next to referenced screenshot.

Reproduction

Attaching minimal reproduction case

unstable-reproduction-test.zip

System Info

System:
    OS: macOS 26.2
    CPU: (12) arm64 Apple M3 Pro
    Memory: 384.31 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.15.1 - /Users/smilaite/.nvm/versions/node/v22.15.1/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.9.2 - /Users/smilaite/.nvm/versions/node/v22.15.1/bin/npm
    pnpm: 9.15.2 - /Users/smilaite/Library/pnpm/pnpm
  Browsers:
    Chrome: 145.0.7632.76
    Chrome Canary: 147.0.7693.0
    Firefox: 146.0
    Safari: 26.2

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

Labels

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

Type

Projects

Status

Approved

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions