visual-regression-testing by aj-geddes/useful-ai-prompts
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill visual-regression-testing视觉回归测试会捕获 UI 组件和页面的截图,然后跨版本进行比较以检测非预期的视觉变化。这种自动化方法可以发现传统功能测试遗漏的 CSS 错误、布局问题和设计回归。
最小工作示例:
// tests/visual/homepage.spec.ts
import { test, expect } from "@playwright/test";
test.describe("Homepage Visual Tests", () => {
test("homepage matches baseline", async ({ page }) => {
await page.goto("/");
// Wait for images to load
await page.waitForLoadState("networkidle");
// Full page screenshot
await expect(page).toHaveScreenshot("homepage-full.png", {
fullPage: true,
maxDiffPixels: 100, // Allow small differences
});
});
test("responsive design - mobile", async ({ page }) => {
await page.setViewportSize({ width: 375, height: 667 }); // iPhone SE
await page.goto("/");
await expect(page).toHaveScreenshot("homepage-mobile.png");
});
test("responsive design - tablet", async ({ page }) => {
// ... (see reference guides for full implementation)
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
references/ 目录中的详细实现:
| 指南 | 内容 |
|---|---|
| Playwright 视觉测试 | Playwright Visual Testing |
| Percy 视觉测试 | Percy Visual Testing |
| 用于 Storybook 的 Chromatic | Chromatic for Storybook |
| Cypress 视觉测试 | Cypress Visual Testing |
| BackstopJS 配置 | BackstopJS Configuration |
| 处理动态内容 | Handling Dynamic Content |
| 测试响应式组件 | Testing Responsive Components |
每周安装数
147
代码仓库
GitHub 星标数
121
首次出现
Jan 21, 2026
安全审计
安装于
opencode130
gemini-cli125
codex123
claude-code120
cursor116
github-copilot106
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.
Minimal working example:
// tests/visual/homepage.spec.ts
import { test, expect } from "@playwright/test";
test.describe("Homepage Visual Tests", () => {
test("homepage matches baseline", async ({ page }) => {
await page.goto("/");
// Wait for images to load
await page.waitForLoadState("networkidle");
// Full page screenshot
await expect(page).toHaveScreenshot("homepage-full.png", {
fullPage: true,
maxDiffPixels: 100, // Allow small differences
});
});
test("responsive design - mobile", async ({ page }) => {
await page.setViewportSize({ width: 375, height: 667 }); // iPhone SE
await page.goto("/");
await expect(page).toHaveScreenshot("homepage-mobile.png");
});
test("responsive design - tablet", async ({ page }) => {
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Playwright Visual Testing | Playwright Visual Testing |
| Percy Visual Testing | Percy Visual Testing |
| Chromatic for Storybook | Chromatic for Storybook |
| Cypress Visual Testing | Cypress Visual Testing |
| BackstopJS Configuration | BackstopJS Configuration |
| Handling Dynamic Content | Handling Dynamic Content |
| Testing Responsive Components |
Weekly Installs
147
Repository
GitHub Stars
121
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode130
gemini-cli125
codex123
claude-code120
cursor116
github-copilot106
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
33,600 周安装
| Testing Responsive Components |