You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(regression-test): capture screenshots across canvas, light, and dark themes
Render each component page under multiple themes and screenshot each one, so the
visual regression suite compares canvas, light, and dark side by side.
- layout.tsx reads the `?theme=` query param and applies the matching theme via
InstUISettingsProvider. It renders `canvas` for the first paint and switches in
an effect to avoid a hydration mismatch, exposing `data-theme` on <html> so the
spec can wait for the theme to be applied before screenshotting.
- spec.cy.ts is now data-driven: a PAGES list (slug/title/wait/a11y-skip) times a
THEMES list. Each page is screenshotted as `<slug>-<theme>` before the axe check
so an a11y failure can never drop a visual baseline. Axe runs per theme with
skipFailures and the totals are asserted once at the end, keeping a11y a gate
across all themes without aborting the other themes' screenshots.
- Screenshot capture moved out of the support afterEach into the spec.
Screenshot filenames change from `<title>` to `<slug>-<theme>`, so the first run
re-baselines every image.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: regression-test/README.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ A small Next.js app that imports `@instructure/ui` locally and exposes one page
6
6
-**Detect a11y issues** — axe-core runs against every page.
7
7
-**Detect unexpected console errors** — the spec's `afterEach` hook asserts `console.error` was not called.
8
8
9
+
Each page is captured once **per theme** (`canvas`, `light`, `dark`), so screenshots are named `<slug>-<theme>.png`. The theme is selected with the `?theme=<key>` query param, which `src/app/layout.tsx` reads and applies via `InstUISettingsProvider`. Add or remove themes with the `THEMES` array in `cypress/e2e/spec.cy.ts` (this multiplies the screenshot/baseline count).
10
+
9
11
See the [visual regression testing guide](../docs/testing/visual-regression.md) for the full CI pipeline, the diff report UI, and tuning notes.
10
12
11
13
## Why npm instead of pnpm?
@@ -41,6 +43,7 @@ Run the Cypress suite against the running server:
41
43
## Adding a new component
42
44
43
45
1. Create `src/app/<component-name>/page.tsx`. Start the file with `'use client'` and wrap the rendered markup in an element with the `axe-test` class — that's what the axe-core check selects against.
44
-
2. Add a corresponding `it(...)` block in `cypress/e2e/spec.cy.ts` that visits `http://localhost:3000/<component-name>`, calls `cy.injectAxe()`, and `cy.checkA11y('.axe-test', axeOptions, terminalLog)`.
45
-
3. If the component animates or loads content asynchronously, add a `cy.wait(<ms>)` before `injectAxe()`.
46
-
4. Commit and push. The first PR run will show the new screenshot as "New"; merging the PR promotes it to a baseline automatically.
46
+
2. Add an entry to the `PAGES` array in `cypress/e2e/spec.cy.ts` with the page's `slug` and a human-readable `title`. The suite generates the visit, per-theme screenshots, and the axe check for you.
47
+
- If the component animates or loads content asynchronously, set `wait: <ms>`.
48
+
- If the page has a known a11y issue, set `a11y: false` with an `a11ySkipReason` (ticket or short note) until it's fixed.
49
+
3. Commit and push. The first PR run will show the new screenshots (one per theme) as "New"; merging the PR promotes them to baselines automatically.
0 commit comments