Visual Regression Testing

Visual Regression Testing

Teaches an agent to detect unintended UI changes by comparing screenshots, with setups for Playwright, Cypress, Percy, Chromatic and BackstopJS and tips for dynamic content.

Skill files9 files

references/

templates/

SKILL.md104 lines
1
---
2
name: visual-regression-testing
3
description: >
4
Detect unintended visual changes in UI by comparing screenshots across
5
versions. Use for visual regression, screenshot diff, Percy, Chromatic, UI
6
testing, and visual validation.
7
---
8
9
# Visual Regression Testing
10
11
## Table of Contents
12
13
- [Overview](#overview)
14
- [When to Use](#when-to-use)
15
- [Quick Start](#quick-start)
16
- [Reference Guides](#reference-guides)
17
- [Best Practices](#best-practices)
18
19
## Overview
20
21
Visual regression testing captures screenshots of UI components and pages, then compares them across versions to detect unintended visual changes. This automated approach catches CSS bugs, layout issues, and design regressions that traditional functional tests miss.
22
23
## When to Use
24
25
- Detecting CSS regression bugs
26
- Validating responsive design across viewports
27
- Testing across different browsers
28
- Verifying component visual consistency
29
- Catching layout shifts and overlaps
30
- Testing theme changes
31
- Validating design system components
32
- Reviewing visual changes in PRs
33
34
## Quick Start
35
36
Minimal working example:
37
38
```typescript
39
// tests/visual/homepage.spec.ts
40
import { test, expect } from "@playwright/test";
41
42
test.describe("Homepage Visual Tests", () => {
43
test("homepage matches baseline", async ({ page }) => {
44
await page.goto("/");
45
46
// Wait for images to load
47
await page.waitForLoadState("networkidle");
48
49
// Full page screenshot
50
await expect(page).toHaveScreenshot("homepage-full.png", {
51
fullPage: true,
52
maxDiffPixels: 100, // Allow small differences
53
});
54
});
55
56
test("responsive design - mobile", async ({ page }) => {
57
await page.setViewportSize({ width: 375, height: 667 }); // iPhone SE
58
await page.goto("/");
59
60
await expect(page).toHaveScreenshot("homepage-mobile.png");
61
});
62
63
test("responsive design - tablet", async ({ page }) => {
64
// ... (see reference guides for full implementation)
65
```
66
67
## Reference Guides
68
69
Detailed implementations in the `references/` directory:
70
71
| Guide | Contents |
72
|---|---|
73
| [Playwright Visual Testing](references/playwright-visual-testing.md) | Playwright Visual Testing |
74
| [Percy Visual Testing](references/percy-visual-testing.md) | Percy Visual Testing |
75
| [Chromatic for Storybook](references/chromatic-for-storybook.md) | Chromatic for Storybook |
76
| [Cypress Visual Testing](references/cypress-visual-testing.md) | Cypress Visual Testing |
77
| [BackstopJS Configuration](references/backstopjs-configuration.md) | BackstopJS Configuration |
78
| [Handling Dynamic Content](references/handling-dynamic-content.md) | Handling Dynamic Content |
79
| [Testing Responsive Components](references/testing-responsive-components.md) | Testing Responsive Components |
80
81
## Best Practices
82
83
### ✅ DO
84
85
- Hide or mock dynamic content (timestamps, ads)
86
- Test across multiple viewports
87
- Wait for animations and images to load
88
- Use consistent viewport sizes
89
- Disable animations during capture
90
- Test interactive states (hover, focus)
91
- Review diffs carefully before approving
92
- Store baselines in version control
93
94
### ❌ DON'T
95
96
- Test pages with constantly changing content
97
- Ignore small legitimate differences
98
- Skip responsive testing
99
- Forget to update baselines after design changes
100
- Test pages with random data
101
- Use overly strict thresholds (0% diff)
102
- Skip browser/device variations
103
- Commit unapproved diffs
104

© AJ Geddes · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…