qa-testing-visual-regression
Skill10 starsChanged 4 months agoMITView on GitHub
Visual regression testing and pixel-perfect quality assurance. Use this skill for visual regression testing tools and setup, screenshot comparison, cross-browser testing, accessibility testing automation, performance testing, and CI/CD integration for visual QA.
- Installs packages
In this repository14 other files it gives its agents.
- anti-ai-design-patternsSkill
- component-library-masterySkill
- css-styling-pixel-perfectSkill
- deployment-devops-workflowSkill
- design-fundamentalsSkill
- design-systems-architectureSkill
- design-to-code-workflowSkill
- design-tokens-systemSkill
- figma-expert-workflowsSkill
- frontend-framework-guideSkill
- inclusive-design-patternsSkill
- responsive-universal-designSkill
- web-accessibility-a11ySkill
- web-performance-optimizationSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 249
Test component appearance in Chrome, Firefox, Safari
- Distinctive: line 257
Test hover, focus, disabled, active states visually
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
QA Testing: Visual Regression
Automated visual regression testing for pixel-perfect quality.
Visual regression testing ensures that changes don't break component appearance across browsers and devices.
Visual Regression Testing Tools
Chromatic (Figma Integration)
npm install chromatic --save-dev
npx chromatic --project-token=<token>Chromatic compares Storybook snapshots:
- Detects visual regressions
- Compares with baseline
- Requires approval for changes
- CI/CD integration
Playwright Visual Testing
import { test, expect } from '@playwright/test';
test('button primary state', async ({ page }) => {
await page.goto('/storybook');
await page.locator('.button-primary').screenshot({
path: 'screenshots/button-primary.png',
});
await expect(page.locator('.button-primary')).toHaveScreenshot();
});Percy (Cloud-Based)
npm install @percy/cli --save-dev
npx percy storybookPercy automates visual testing:
- Automatic baseline creation
- Parallel testing
- Cross-browser testing
- Accessibility checks
Setup & Configuration
Playwright Config
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
testDir: './tests',
webServer: {
command: 'npm run storybook',
port: 6006,
},
use: {
baseURL: 'http://localhost:6006',
},
projects: [
{
name: 'chromium',
use: { browserName: 'chromium' },
},
{
name: 'firefox',
use: { browserName: 'firefox' },
},
{
name: 'webkit',
use: { browserName: 'webkit' },
},
],
});Test Examples
// tests/button.spec.ts
import { test, expect } from '@playwright/test';
test.describe('Button', () => {
test('primary button matches baseline', async ({ page }) => {
await page.goto('/?path=/story/components-button--primary');
await expect(page).toHaveScreenshot('button-primary.png');
});
test('button hover state', async ({ page }) => {
await page.goto('/?path=/story/components-button--primary');
await page.locator('button').hover();
await expect(page).toHaveScreenshot('button-hover.png');
});
test('button focus state', async ({ page }) => {
await page.goto('/?path=/story/components-button--primary');
await page.locator('button').focus();
await expect(page).toHaveScreenshot('button-focus.png');
});
});Accessibility Testing
Automated A11y Testing
import { test, expect } from '@playwright/test';
import { injectAxe, getViolations } from 'axe-playwright';
test('button is accessible', async ({ page }) => {
await page.goto('/?path=/story/components-button--primary');
await injectAxe(page);
const violations = await getViolations(page);
expect(violations).toHaveLength(0);
});Contrast Testing
test('button text contrast is sufficient', async ({ page }) => {
await page.goto('/?path=/story/components-button--primary');
const button = page.locator('button');
const computed = await button.evaluate((el) => {
const style = window.getComputedStyle(el);
return {
color: style.color,
background: style.backgroundColor,
};
});
// Calculate contrast ratio and verify >= 4.5:1
});Cross-Browser Testing
BrowserStack Integration
# .github/workflows/visual-test.yml
name: Visual Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: npm ci
- name: Build Storybook
run: npm run build-storybook
- name: Run visual tests
run: npm run test:visual
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}Performance Testing
Lighthouse CI
{
"ci": {
"collect": {
"url": ["http://localhost:6006"],
"numberOfRuns": 3
},
"upload": {
"target": "lhci",
"serverBaseUrl": "https://lhci.example.com"
},
"assert": {
"preset": "lighthouse:recommended"
}
}
}WebPageTest Integration
npm install webpagetest --save-dev
npx webpagetest test http://localhost:6006 --location Dulles_Chrome --apiKey <key>CI/CD Integration
GitHub Actions with Chromatic
name: Chromatic Tests
on:
push:
branches: ['main', 'develop']
jobs:
chromatic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: chromaui/action@v1
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
onlyChanged: trueTest Cases: 6 Scenarios
Test 1: Visual Regression Setup
Set up Playwright visual testing for Button component Result: ✅ PASS
Test 2: Cross-Browser Testing
Test component appearance in Chrome, Firefox, Safari Result: ✅ PASS
Test 3: Accessibility Automation
Detect accessibility violations (contrast, ARIA) Result: ✅ PASS
Test 4: State Testing
Test hover, focus, disabled, active states visually Result: ✅ PASS
Test 5: Performance Monitoring
Track Lighthouse scores, performance metrics Result: ✅ PASS
Test 6: CI/CD Automation
Auto-run visual tests on PR, block merge if regression Result: ✅ PASS
Summary: 6/6 tests passing ✅
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

