Skip to content

Add test failure screenshot option. - #6171

Open
michelinewu wants to merge 1 commit into
masterfrom
mw_failure_screenshot
Open

Add test failure screenshot option.#6171
michelinewu wants to merge 1 commit into
masterfrom
mw_failure_screenshot

Conversation

@michelinewu

Copy link
Copy Markdown
Contributor

Capture a Screenshot of the App When an E2E Test Fails

Issues

Speed up debugging by recording what the app actually looked like at the moment of failure.

Fixes

Added saveFailureScreenshot() to test/helpers/webdriver/index.ts, called from afterEach.always right before the existing teardown stops the app — the last point at which the failing UI still exists. Opt-in via SLOBS_FAIL_SCREENSHOT_DIR, so a normal test run captures nothing and is unaffected. Files are named after the test title (kebab-cased, truncated to 80 chars). The capture is wrapped in try/catch and never throws, so a failed screenshot can't mask or replace the real test failure.

File(s) changed: test/helpers/webdriver/index.ts

Performance Implications

None on a normal test run — the function returns immediately unless SLOBS_FAIL_SCREENSHOT_DIR is set. When enabled, adds one screenshot capture per failing test, on the already-failing path.

Copilot AI lite review requested due to automatic review settings September 9, 2026 22:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The generated screenshot filename can become empty for non-ASCII test titles, producing paths like .png and risking confusing/overwritten artifacts.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds an opt-in mechanism to capture the app’s UI state at the moment an AVA e2e test fails, to improve failure debugging without impacting normal test runs.

Changes:

  • Introduces saveFailureScreenshot() gated by SLOBS_FAIL_SCREENSHOT_DIR.
  • Hooks screenshot capture into test.afterEach.always before teardown stops the app.
File summaries
File Description
test/helpers/webdriver/index.ts Adds an opt-in failure-screenshot helper and calls it during afterEach.always before teardown.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +232 to +236
const imgTitle = t.title
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '')
.slice(0, 80);
@bundlemon

bundlemon Bot commented Sep 9, 2026

Copy link
Copy Markdown

BundleMon

Unchanged files (4)
Status Path Size Limits
renderer.(hash).js
10.54MB -
vendors~renderer.(hash).js
4.67MB -
updater.js
115.29KB -
guest-api.js
40.23KB -

No change in files bundle size

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

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.

2 participants