testing-visual-regression

0
0
Source

Detect visual changes in UI components using screenshot comparison. Use when detecting unintended UI changes or pixel differences. Trigger with phrases like "test visual changes", "compare screenshots", or "detect UI regressions".

Install

mkdir -p .claude/skills/testing-visual-regression && curl -L -o skill.zip "https://mcp.directory/api/skills/download/8573" && unzip -o skill.zip -d .claude/skills/testing-visual-regression && rm skill.zip

Installs to .claude/skills/testing-visual-regression

About this skill

Visual Regression Tester

Overview

Detect unintended visual changes in UI components by capturing screenshots and comparing them pixel-by-pixel against approved baselines. Supports Playwright visual comparisons, Percy, Chromatic, BackstopJS, and reg-suit.

Prerequisites

  • Browser automation tool installed (Playwright, Puppeteer, or Cypress)
  • Visual regression library configured (Playwright toHaveScreenshot, Percy, Chromatic, or BackstopJS)
  • Baseline screenshots committed to version control or stored in a cloud service
  • Storybook or component playground running for isolated component captures (optional)
  • Consistent rendering environment (Docker or CI with fixed OS/fonts/GPU settings)

Instructions

  1. Identify all UI components and pages requiring visual coverage using Glob to scan component directories and route definitions.
  2. Create a visual test file for each component or page:
    • Navigate to the component URL or Storybook story.
    • Wait for all network requests, animations, and lazy-loaded images to complete.
    • Set a consistent viewport size (e.g., 1280x720 for desktop, 375x812 for mobile).
  3. Capture screenshots with deterministic settings:
    • Disable animations and transitions (* { animation: none !important; transition: none !important; }).
    • Mask dynamic content (timestamps, random avatars, ads) with CSS overlays.
    • Use fullPage: true for scrollable pages.
  4. Compare captured screenshots against baselines:
    • Configure pixel difference threshold (recommended: 0.1% for component tests, 0.5% for full-page).
    • Generate diff images highlighting changed regions.
    • Flag tests as failed when differences exceed the threshold.
  5. For responsive testing, capture at multiple breakpoints:
    • Mobile: 375px width
    • Tablet: 768px width
    • Desktop: 1280px width
    • Wide: 1920px width
  6. Review diff images for each failure and classify as:
    • Intentional change: Update the baseline with --update-snapshots.
    • Regression: File a bug with the diff image attached.
  7. Integrate into CI so visual tests run on every pull request with diff images uploaded as artifacts.

Output

  • Screenshot baseline images stored in __screenshots__/ or equivalent directory
  • Diff images highlighting pixel-level changes between baseline and current
  • Visual regression test report with pass/fail status per component
  • CI artifacts containing all captured, baseline, and diff images
  • Responsive coverage matrix showing results across breakpoints

Error Handling

ErrorCauseSolution
Anti-aliasing differences across OSFont rendering varies between macOS, Linux, and WindowsRun visual tests in Docker with fixed fonts; use threshold option to allow sub-pixel variance
Flaky screenshots from animationsCSS transitions or JS animations still running at capture timeInject prefers-reduced-motion or disable animations via addStyleTag before capture
Missing baseline on first runNo previous screenshot exists to compare againstRun with --update-snapshots to create initial baselines; commit them to the repository
Viewport size mismatchBrowser chrome or scrollbar width differs between environmentsUse setViewportSize explicitly; hide scrollbars with CSS overflow: hidden
Dynamic content causes false failuresTimestamps, user avatars, or ads change between runsMask dynamic elements with mask option or replace content via page.evaluate

Examples

Playwright visual regression test:

import { test, expect } from '@playwright/test';

test('homepage matches baseline', async ({ page }) => {
  await page.goto('/');
  await page.waitForLoadState('networkidle');
  await page.addStyleTag({ content: '* { animation: none !important; }' });
  await expect(page).toHaveScreenshot('homepage.png', {
    maxDiffPixelRatio: 0.001,
    fullPage: true,
  });
});

BackstopJS scenario configuration:

{
  "label": "Login Page",
  "url": "http://localhost:3000/login",  # 3000: 3 seconds in ms
  "selectors": ["document"],
  "misMatchThreshold": 0.1,
  "viewports": [
    { "label": "phone", "width": 375, "height": 812 },  # 812: 375 = configured value
    { "label": "desktop", "width": 1280, "height": 720 }  # 1280: 720 = configured value
  ]
}

Resources

svg-icon-generator

jeremylongshore

Svg Icon Generator - Auto-activating skill for Visual Content. Triggers on: svg icon generator, svg icon generator Part of the Visual Content skill category.

8227

d2-diagram-creator

jeremylongshore

D2 Diagram Creator - Auto-activating skill for Visual Content. Triggers on: d2 diagram creator, d2 diagram creator Part of the Visual Content skill category.

4926

automating-mobile-app-testing

jeremylongshore

This skill enables automated testing of mobile applications on iOS and Android platforms using frameworks like Appium, Detox, XCUITest, and Espresso. It generates end-to-end tests, sets up page object models, and handles platform-specific elements. Use this skill when the user requests mobile app testing, test automation for iOS or Android, or needs assistance with setting up device farms and simulators. The skill is triggered by terms like "mobile testing", "appium", "detox", "xcuitest", "espresso", "android test", "ios test".

14217

performing-penetration-testing

jeremylongshore

This skill enables automated penetration testing of web applications. It uses the penetration-tester plugin to identify vulnerabilities, including OWASP Top 10 threats, and suggests exploitation techniques. Use this skill when the user requests a "penetration test", "pentest", "vulnerability assessment", or asks to "exploit" a web application. It provides comprehensive reporting on identified security flaws.

4615

designing-database-schemas

jeremylongshore

Design and visualize efficient database schemas, normalize data, map relationships, and generate ERD diagrams and SQL statements.

11514

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

11410

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,1421,171

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

969933

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

683829

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

691549

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

797540

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

697374

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.