visual-regression-testing
Comprehensive visual regression testing using Playwright and jest-image-snapshot. Implements screenshot comparison, baseline management, CI/CD integration…

Установить visual-regression-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Visual Regression Testing
This skill provides comprehensive visual regression testing capabilities to detect unintended visual changes in UI components and prevent visual bugs from being merged into production.
Overview
Visual regression testing works by:
- Taking screenshots of components/pages in a known-good state (baselines)
- Taking new screenshots after code changes
- Comparing new screenshots with baselines pixel-by-pixel
- Flagging differences for human review
Framework: Playwright + jest-image-snapshot Approach: Based on Ant Design's visual regression testing methodology
Core Capabilities
1. Screenshot Baseline Management
Create and update baseline screenshots that serve as the source of truth for visual comparison.
Implementation: tests/shared/imageTest.tsx
Key features:
- Automated baseline capture for all component demos
- Version-controlled baseline storage
- Easy baseline updates when intentional changes occur
- Support for multiple viewport sizes and themes
2. Visual Comparison Testing
Implementation: scripts/visual-regression/
Core testing workflow:
// Example structure from tests/shared/imageTest.tsx
import { test, expect } from '@playwright/test';
test('component visual regression', async ({ page }) => {
await page.goto('http://localhost:5173/component-demo');
await page.waitForLoadState('networkidle');
// Take screenshot and compare with baseline
const screenshot = await page.screenshot();
expect(screenshot).toMatchImageSnapshot({
customSnapshotsDir: '__image_snapshots__',
customDiffDir: '__image_snapshots__/diff',
threshold: 0.1, // 0.1% pixel difference tolerance
});
});
3. CI/CD Integration
Implementation: .github/workflows/visual-regression-*.yml
Workflow files:
visual-regression-pr.yml- Runs on pull requestsvisual-regression-baseline.yml- Updates baselines on main branchvisual-regression-report.yml- Generates and uploads diff reports
PR Workflow:
- Checkout code and install dependencies
- Start local server
- Run visual regression tests
- If differences found:
- Generate diff screenshots
- Upload artifacts to GitHub
- Post comment on PR with visual diff preview
- Mark check as failed
- If no differences, mark check as passed
Baseline Update Workflow:
- Runs on main branch after merge
- Regenerates all baseline screenshots
- Commits updated baselines back to repo
File Structure
.github/workflows/
├── visual-regression-pr.yml # PR visual checks
├── visual-regression-baseline.yml # Baseline updates
└── visual-regression-report.yml # Diff reporting
tests/shared/
└── imageTest.tsx # Baseline screenshot utilities
scripts/visual-regression/
├── capture-baselines.ts # Generate baseline screenshots
├── compare-screenshots.ts # Compare current vs baseline
├── generate-report.ts # Create HTML diff report
└── upload-to-storage.ts # Upload to OSS/S3
__image_snapshots__/
├── baseline/ # Baseline screenshots
├── current/ # Latest test screenshots
└── diff/ # Difference highlights
Usage Patterns
For Component Development
When developing a new component:
# 1. Create component and demos
npm run dev
# 2. Generate initial baseline
npm run visual:baseline
# 3. Make changes
# ... edit component code ...
# 4. Run visual regression test
npm run visual:test
# 5. Review diffs (if any)
npm run visual:report
# 6. Update baseline if changes are intentional
npm run visual:update-baseline
For PR Reviews
Reviewers can:
- Check CI status for visual regression failures
- Click artifact link in PR comment
- Review visual diff report
- Approve/request changes based on visual impact
For CI/CD Pipeline
# Example from .github/workflows/visual-regression-pr.yml
name: Visual Regression Testing
on:
pull_request:
branches: [main, develop]
jobs:
visual-regression:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Install Playwright
run: npx playwright install --with-deps chromium
- name: Start dev server
run: npm run dev &
- name: Wait for server
run: npx wait-on http://localhost:5173
- name: Run visual regression tests
run: npm run visual:test
- name: Upload diff artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: visual-diffs
path: __image_snapshots__/diff/
- name: Generate report
if: failure()
run: npm run visual:report
- name: Comment PR with results
if: failu
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл visual-regression-testing?
Comprehensive visual regression testing using Playwright and jest-image-snapshot. Implements screenshot comparison, baseline management, CI/CD integration, and visual diff reporting following Ant Design best practices. Use for preventing visual bugs, ensuring UI consistency, and automating visual QA. (project)
Как установить скилл visual-regression-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл visual-regression-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
AnthropicGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
webapp-testing
AnthropicToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
brand-guidelines
AnthropicApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
web-artifacts-builder
AnthropicSuite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
