Testing visual regression
Skill jeremylongshore/claude-code-plugins-plus-skills/skills/.curated/testing-visual-regression
'Detect visual changes in UI components using screenshot comparison.From its SKILL.md
npx -y skills add jeremylongshore/claude-code-plugins-plus-skills --skill testing-visual-regressionAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
5.1 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
Visual Regression Tester
Overview
Detect unintended visual changes in UI components by capturing screenshots and comparing them pixel-by-pixel against approved baselines. Supports Playwright visual comparisons, Percy, Chromatic, BackstopJS, and reg-suit.
Prerequisites
- Browser automation tool installed (Playwright, Puppeteer, or Cypress)
- Visual regression library configured (Playwright
toHaveScreenshot, Percy, Chromatic, or BackstopJS) - Baseline screenshots committed to version control or stored in a cloud service
- Storybook or component playground running for isolated component captures (optional)
- Consistent rendering environment (Docker or CI with fixed OS/fonts/GPU settings)
Instructions
- Identify all UI components and pages requiring visual coverage using Glob to scan component directories and route definitions.
- Create a visual test file for each component or page:
- Navigate to the component URL or Storybook story.
- Wait for all network requests, animations, and lazy-loaded images to complete.
- Set a consistent viewport size (e.g., 1280x720 for desktop, 375x812 for mobile).
- Capture screenshots with deterministic settings:
- Disable animations and transitions (
* { animation: none !important; transition: none !important; }). - Mask dynamic content (timestamps, random avatars, ads) with CSS overlays.
- Use
fullPage: truefor scrollable pages.
- Disable animations and transitions (
- Compare captured screenshots against baselines:
- Configure pixel difference threshold (recommended: 0.1% for component tests, 0.5% for full-page).
- Generate diff images highlighting changed regions.
- Flag tests as failed when differences exceed the threshold.
- For responsive testing, capture at multiple breakpoints:
- Mobile: 375px width
- Tablet: 768px width
- Desktop: 1280px width
- Wide: 1920px width
- Review diff images for each failure and classify as:
- Intentional change: Update the baseline with
--update-snapshots. - Regression: File a bug with the diff image attached.
- Intentional change: Update the baseline with
- Integrate into CI so visual tests run on every pull request with diff images uploaded as artifacts.
Output
- Screenshot baseline images stored in
__screenshots__/or equivalent directory - Diff images highlighting pixel-level changes between baseline and current
- Visual regression test report with pass/fail status per component
- CI artifacts containing all captured, baseline, and diff images
- Responsive coverage matrix showing results across breakpoints
Error Handling
| Error | Cause | Solution |
|---|---|---|
| Anti-aliasing differences across OS | Font rendering varies between macOS, Linux, and Windows | Run visual tests in Docker with fixed fonts; use threshold option to allow sub-pixel variance |
| Flaky screenshots from animations | CSS transitions or JS animations still running at capture time | Inject prefers-reduced-motion or disable animations via addStyleTag before capture |
| Missing baseline on first run | No previous screenshot exists to compare against | Run with --update-snapshots to create initial baselines; commit them to the repository |
| Viewport size mismatch | Browser chrome or scrollbar width differs between environments | Use setViewportSize explicitly; hide scrollbars with CSS overflow: hidden |
| Dynamic content causes false failures | Timestamps, user avatars, or ads change between runs | Mask dynamic elements with mask option or replace content via page.evaluate |
Examples
Playwright visual regression test:
import { test, expect } from '@playwright/test';
test('homepage matches baseline', async ({ page }) => {
await page.goto('/');
await page.waitForLoadState('networkidle');
await page.addStyleTag({ content: '* { animation: none !important; }' });
await expect(page).toHaveScreenshot('homepage.png', {
maxDiffPixelRatio: 0.001,
fullPage: true,
});
});
BackstopJS scenario configuration:
{
"label": "Login Page",
"url": "http://localhost:3000/login", # 3000: 3 seconds in ms
"selectors": ["document"],
"misMatchThreshold": 0.1,
"viewports": [
{ "label": "phone", "width": 375, "height": 812 }, # 812: 375 = configured value
{ "label": "desktop", "width": 1280, "height": 720 } # 1280: 720 = configured value
]
}
Resources
- Playwright visual comparisons: https://playwright.dev/docs/test-snapshots
- Percy visual testing: https://www.percy.io/
- Chromatic (Storybook): https://www.chromatic.com/
- BackstopJS: https://github.com/garris/BackstopJS
- reg-suit visual regression: https://reg-viz.github.io/reg-suit/
What ships with it: 10 files
21.5 KB alongside SKILL.md, 4 of them executable
assets/
- example_backstop_config.jsruns2.8 KB
- example_chromatic_config.yml2.2 KB
- example_percy_config.yml2.1 KB
- html_report_template.html3.3 KB
- README.md371 B
references/
- README.md67 B
scripts/
- analyze_diffs.pyruns4.7 KB
- README.md416 B
- run_visual_tests.pyruns2.8 KB
- update_baselines.pyruns2.7 KB
Gives 0 of the 12 instructions most e2e browser skills give in ~1.1k tokens
Counted across 499 of the 513 authors here whose files we hold, read 2026-09-06
- Capture screenshots, videos, and traces on failurein 32 of 499, across 23 files
- Close the browser when donein 22 of 499
- Interact with elements using snapshot refsin 21 of 499, across 20 files
- Wait for specific network responses instead of fixed timeoutsin 20 of 499, across 10 files
- Keep tests independent with no shared statein 19 of 499, across 17 files
- Use Page Object Model classes to encapsulate page interactionsin 19 of 499, across 9 files
- Locate elements with data-testid attributesin 19 of 499, across 10 files
- Quarantine flaky tests with fixme or skipin 17 of 499, across 7 files
- Upload test artifacts after every CI runin 17 of 499, across 8 files
- Wait on conditions instead of using fixed sleepsin 17 of 499, across 13 files
- Clean up test data after each testin 17 of 499, across 16 files
- Test user-visible behavior, not implementation detailsin 16 of 499, across 10 files
Said here and by no other author read
- Identify UI components needing visual coverage
- Create a visual test file per component
- Wait for network requests and animations before capture
- Disable animations and transitions before capture
- Generate diff images for changed regions
- Review diff images and classify each failure
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.