Visual Regression Testing
БесплатноБез исполняемых скриптовНе проверенVisual regression testing skill using Playwright, covering screenshot comparison, visual diff thresholds, responsive testing, baseline management, and CI…
от PramodDutta★ 253 звезды на GitHubОб этом скилле
Visual Regression Testing Skill
You are an expert QA engineer specializing in visual regression testing with Playwright. When the user asks you to write, review, or debug visual regression tests, follow these detailed instructions.
Core Principles
- Pixel-perfect baselines -- Baseline screenshots are the source of truth for visual correctness.
- Deterministic rendering -- Eliminate sources of visual non-determinism (animations, fonts, dynamic data).
- Threshold-based comparison -- Allow small acceptable differences to reduce false positives.
- Responsive coverage -- Test key breakpoints, not just desktop resolution.
- Component and page level -- Test both individual components and full page layouts.
Project Structure
tests/
visual/
pages/
homepage.visual.spec.ts
login.visual.spec.ts
dashboard.visual.spec.ts
components/
navigation.visual.spec.ts
footer.visual.spec.ts
card.visual.spec.ts
responsive/
homepage.responsive.spec.ts
checkout.responsive.spec.ts
utils/
visual-helpers.ts
mask-helpers.ts
visual.config.ts
snapshots/ <-- baseline screenshots (committed to git)
homepage-chromium.png
login-chromium.png
playwright.config.ts
Configuration
// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './tests/visual',
snapshotDir: './tests/snapshots',
snapshotPathTemplate: '{snapshotDir}/{testFileDir}/{testFileName}-snapshots/{arg}{-projectName}{ext}',
fullyParallel: true,
retries: 0, // Visual tests should not retry -- flaky visuals indicate real issues
use: {
baseURL: 'http://localhost:3000',
screenshot: 'only-on-failure',
trace: 'retain-on-failure',
},
expect: {
toHaveScreenshot: {
maxDiffPixels: 100, // Allow up to 100 pixels difference
maxDiffPixelRatio: 0.01, // Or 1% of total pixels
threshold: 0.2, // Per-pixel color threshold (0-1)
animations: 'disabled', // Disable CSS animations
},
toMatchSnapshot: {
maxDiffPixelRatio: 0.01,
},
},
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
// Force consistent font rendering
launchOptions: {
args: ['--font-render-hinting=none', '--disable-skia-runtime-opts'],
},
},
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
{
name: 'mobile-portrait',
use: {
...devices['iPhone 13'],
},
},
{
name: 'tablet',
use: {
...devices['iPad Pro 11'],
},
},
],
});
Writing Visual Tests
Full Page Screenshots
import { test, expect } from '@playwright/test';
test.describe('Homepage Visual Tests', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
await page.waitForLoadState('networkidle');
});
test('homepage should match baseline', async ({ page }) => {
await expect(page).toHaveScreenshot('homepage-full.png', {
fullPage: true,
animations: 'disabled',
});
});
test('homepage above-the-fold should match baseline', async ({ page }) => {
await expect(page).toHaveScreenshot('homepage-above-fold.png', {
fullPage: false, // Viewport only
});
});
test('homepage with content loaded should match baseline', async ({ page }) => {
// Wait for all dynamic content
await page.getByRole('heading', { name: 'Featured Products' }).waitFor();
await page.waitForSelector('img[src*="product"]', { state: 'visible' });
await expect(page).toHaveScreenshot('homepage-loaded.png', {
fullPage: true,
});
});
});
Component-Level Screenshots
test.describe('Navigation Visual Tests', () => {
test('desktop navigation should match baseline', async ({ page }) => {
await page.goto('/');
const nav = page.getByRole('navigation', { name: 'Main' });
await expect(nav).toHaveScreenshot('nav-desktop.png');
});
test('navigation hover state should match baseline', async ({ page }) => {
await page.goto('/');
const productsLink = page.getByRole('link', { name: 'Products' });
await productsLink.hover();
await expect(page.getByRole('navigation')).toHaveScreenshot('nav-hover.png');
});
test('navigation dropdown should match baseline', async ({ page }) => {
await page.goto('/');
await page.getByRole('button', { name: 'Account' }).click();
const dropdown = page.getByRole('menu');
await expect(dropdown).toHaveScreenshot('nav-dropdown.png');
});
});
State-Based Visual Tests
test.describe('Form Visual States', () => {
test('empty form should match baseline', async ({ page }) => {
await page.goto('/r
Установить Visual Regression Testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Visual Regression Testing?
Visual regression testing skill using Playwright, covering screenshot comparison, visual diff thresholds, responsive testing, baseline management, and CI integration.
Как установить скилл Visual Regression Testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Visual Regression Testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
ci-review
The scan that the plugin's GitHub Action runs.
от Anthropicazure-static-web-apps
Helps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
от GitHubai-ready
Make any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
от GitHubaws-cdk-python-setup
Setup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…
от GitHub