chromatic-visual-regression-testing
БесплатноБез исполняемых скриптовНе проверенUse when visual regression tests run on Chromatic Cloud for Storybook, Playwright or Cypress: the chromatic CLI, baselines, TurboSnap, UI Review, CI gating…
от testland★ 18 звёзд на GitHubОб этом скилле
chromatic-visual-regression-testing
Overview
Chromatic is a visual testing platform built by the team behind Storybook (chromatic-overview). It works in three modes:
- Storybook (default): every story becomes a snapshot.
- Playwright: snapshots are captured during Playwright test runs via
the
--playwrightflag. - Cypress: snapshots are captured during Cypress runs via
--cypress.
The CLI shape: chromatic is one binary; everything (auth, framework
choice, TurboSnap) is a flag or env var.
When to use
- The project uses Storybook and wants a hosted UI for visual review with team sign-off on baseline changes.
- The team needs TurboSnap - a per-PR speedup that snapshots only stories whose dependency graph changed (turbosnap).
- The repo already has
chromaticindevDependenciesor achromatic.config.jsonat the root. - Visual coverage is story-driven, not full-page-driven (in contrast to Percy or Playwright snapshots, which are page-driven by default).
Authoring
Install
npm install --save-dev chromatic
(Per the Chromatic quickstart.)
Connect to a project
The first run uploads the Storybook build, captures a snapshot of each story, and establishes those snapshots as the project baseline (quickstart):
npx chromatic --project-token <your-project-token>
Subsequent runs compare new snapshots to the baseline; visual changes must be explicitly accepted in the Chromatic UI before the build passes.
Authoring stories (Storybook mode)
Chromatic snapshots whatever your Storybook indexes, so authoring is
"add a story." Per-story knobs that affect snapshots are passed in the
story's parameters.chromatic block (e.g. modes, delay, pauseAnimationAtEnd).
Authoring tests (Playwright / Cypress mode)
When invoked with --playwright or --cypress, the CLI captures
snapshots from your existing Playwright / Cypress test runs
(cli); no per-test code changes are required beyond running the
matching framework's archive output through Chromatic.
Stories that change on every build: fix the source, not the threshold
A story that renders new Date(), Math.random(), live data or a
running animation produces a new diff on every build. Raising
diffThreshold to silence it makes every comparison less sensitive,
so real regressions pass too; the default is 0.063
([threshold][threshold]). Make the input fixed instead:
| Source of change | Fix in the story or component |
|---|---|
| Current time ("2 minutes ago", today's date) | Pass a fixed timestamp as an arg, or mock Date in a decorator |
| Random colours, IDs, shuffled order | Derive them from the data (hash of a name), or seed the generator |
| Network data | Fixture args or a request mock, never a live API |
| CSS animations and transitions | Chromatic pauses them at the end of the cycle; set pauseAnimationAtEnd: false to capture the first frame instead ([animations][animations]) |
JavaScript animations (requestAnimationFrame, timers, animation libraries) |
Chromatic does not control them; branch on isChromatic() and render the final state ([animations][animations]) |
import isChromatic from 'chromatic/isChromatic';
export function ProgressRing({ value }: { value: number }) {
const [shown, setShown] = useState(isChromatic() ? value : 0);
useEffect(() => {
if (isChromatic()) return; // snapshot shows the final value
const id = requestAnimationFrame(() => setShown(value));
return () => cancelAnimationFrame(id);
}, [value]);
return <svg aria-label={`${shown}%`}>{/* ... */}</svg>;
}
Do not paper over it with a long delay or by disabling snapshots for
the story: the first only moves the race, the second removes the
coverage. After the fix, put diffThreshold back to the default.
Themes and viewports: modes
Modes replace the older per-story chromatic.viewports parameter. A
mode is a named combination of globals (viewport, theme, locale), and
"Chromatic treats each mode as an individual entity, with its own
unique baselines and specific approvals" ([modes][modes]). Define them
once in .storybook/modes.ts and apply them in
.storybook/preview.ts so every story gets them:
// .storybook/modes.ts
export const allModes = {
'compact light': { viewport: 'compact', theme: 'light' },
'compact dark': { viewport: 'compact', theme: 'dark' },
'wide light': { viewport: 'wide', theme: 'light' },
'wide dark': { viewport: 'wide', theme: 'dark' },
} as const;
// .storybook/preview.ts
import { allModes } from './modes';
const preview = {
parameters: {
viewport: {
options: { // Storybook 9
Установить chromatic-visual-regression-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл chromatic-visual-regression-testing?
Use when visual regression tests run on Chromatic Cloud for Storybook, Playwright or Cypress: the chromatic CLI, baselines, TurboSnap, UI Review, CI gating and reading exit codes to tell visual changes from errors.
Как установить скилл chromatic-visual-regression-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл chromatic-visual-regression-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies 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…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic