Skip to content

fix(reporter): include failure screenshot attachments in JUnit report#9905

Open
mixelburg wants to merge 4 commits intovitest-dev:mainfrom
mixelburg:fix/junit-screenshot-attachments
Open

fix(reporter): include failure screenshot attachments in JUnit report#9905
mixelburg wants to merge 4 commits intovitest-dev:mainfrom
mixelburg:fix/junit-screenshot-attachments

Conversation

@mixelburg
Copy link
Copy Markdown
Contributor

Fixes #9904

When browser mode is configured with screenshotFailures: true, screenshots are captured on test failures and stored as internal:failureScreenshot artifacts on the task. However, the JUnit reporter was not referencing these screenshots in its XML output, making it impossible for CI systems to correlate failures with their screenshots.

This PR emits a <system-out> element containing [[ATTACHMENT|/path/to/screenshot.png]] for each failure screenshot artifact on a failed test case. The [[ATTACHMENT|...]] convention is widely supported by CI systems (GitLab, Jenkins, GitHub Actions test report parsers, etc.).

Changes

  • packages/vitest/src/node/reporters/junit.ts — after emitting <failure> elements, iterate over task.artifacts for internal:failureScreenshot artifacts and emit their path via <system-out>[[ATTACHMENT|...]]</system-out>
  • test/cli/test/reporters/reporters.test.ts — add unit test verifying the [[ATTACHMENT|...]] is emitted in the JUnit output when a failed test has a failure screenshot artifact

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 18, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit b0c8305
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69bb222dd1f303000983a629
😎 Deploy Preview https://deploy-preview-9905--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@hi-ogawa
Copy link
Copy Markdown
Collaborator

This shouldn't be internal:failureScreenshot specific, but achieved uniformly through annotation API level https://vitest.dev/guide/test-annotations.html#test-annotations

@hi-ogawa hi-ogawa added the maybe automated User is likely an AI agent, or the content was generated by an AI assistant without user control label Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maybe automated User is likely an AI agent, or the content was generated by an AI assistant without user control

Projects

None yet

Development

Successfully merging this pull request may close these issues.

screenshotFailures does not attach screenshots to JUnit reporter output

2 participants