Add test failure screenshot option. - #6171
Open
michelinewu wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
🟡 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 bySLOBS_FAIL_SCREENSHOT_DIR. - Hooks screenshot capture into
test.afterEach.alwaysbefore 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); |
BundleMonUnchanged files (4)
No change in files bundle size Final result: ✅ View report in BundleMon website ➡️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()totest/helpers/webdriver/index.ts, called fromafterEach.alwaysright before the existing teardown stops the app — the last point at which the failing UI still exists. Opt-in viaSLOBS_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.tsPerformance Implications
None on a normal test run — the function returns immediately unless
SLOBS_FAIL_SCREENSHOT_DIRis set. When enabled, adds one screenshot capture per failing test, on the already-failing path.