Skip to content

Commit 1d89888

Browse files
balzssclaude
andcommitted
fix(regression-test): decouple a11y checks from screenshot capture
An axe violation throws in `cy.checkA11y`, which failed the Cypress test and triggered two problems in the visual regression pipeline: the deterministic afterEach screenshot was skipped (the page got a blank/missing baseline), and Cypress' automatic failure screenshot (the error overlay) leaked into the diff as a spurious "new" image because it has a different filename. Always take the afterEach screenshot even when the test failed, and disable Cypress' failure screenshots. The a11y assertion still fails the run as a gate, but the visual baselines are now clean and complete regardless of a11y state. This bug was latent from the start; it only surfaced once a change introduced an actual a11y violation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent bf4f72a commit 1d89888

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

regression-test/cypress.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ export default defineConfig({
3030
screenshotsFolder: 'cypress/screenshots',
3131
trashAssetsBeforeRuns: true,
3232
video: false,
33+
// Never capture Cypress' automatic failure screenshots (the error overlay).
34+
// Visual regression baselines come solely from the deterministic afterEach
35+
// `cy.screenshot`; a failure screenshot has a different filename and would
36+
// otherwise leak into the diff as a spurious "new" image.
37+
screenshotOnRunFailure: false,
3338
e2e: {
3439
viewportWidth: 1280,
3540
viewportHeight: 800,

regression-test/cypress/support/e2e.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ function slugify(s: string) {
5151

5252
afterEach(function () {
5353
const test = this.currentTest
54-
if (!test || test.state === 'failed') return
54+
// Capture the screenshot even when the test failed (e.g. an axe a11y
55+
// violation). The a11y assertion still fails the run as a gate, but the
56+
// page itself rendered fine, so we always want its visual baseline rather
57+
// than a missing/blank image.
58+
if (!test) return
5559
const name = slugify(test.title)
5660
cy.location('pathname', { log: false }).then((pagePath) => {
5761
cy.task('recordMeta', { name, pagePath }, { log: false })

0 commit comments

Comments
 (0)