بنقرة واحدة
chromatic-snapshots
Guide for diagnosing and fixing snapshot failures, flakiness, and comparison issues in Chromatic.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Guide for diagnosing and fixing snapshot failures, flakiness, and comparison issues in Chromatic.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Write end-to-end tests using Playwright. Test user behavior, not implementation details. Also useful for non-test Playwright scripting.
Write React components following idiomatic patterns, hooks best practices, and performance optimizations
Write React components designed to be easily tested with Playwright and Testing Library — semantic HTML, clear boundaries, no test-specific hacks
| name | chromatic-snapshots |
| description | Guide for diagnosing and fixing snapshot failures, flakiness, and comparison issues in Chromatic. |
Stable snapshots are the foundation of visual regression testing. Every inconsistency you eliminate prevents a false positive from blocking your team.
Activate when you encounter:
| Symptom | Root Cause | Fix |
|---|---|---|
| Blank snapshot | animateIn effect or position: fixed without dimensions | Add chromatic: { delay: 300 } or wrap in a sized container |
| Missing images/fonts | Resource didn't load within 15s timeout | Serve as static files or use a placeholder service |
| Content cut off vertically | overflow: hidden or height: 100vh on ancestor | Remove overflow constraint or set explicit height via decorator |
| Portal not captured | Component renders outside viewport | Reposition component or adjust viewport size via modes |
| Mocked data not appearing | MSW handler mismatch or loading state captured | Add interaction test assertions; match API path only in handlers |
| Ignored elements still diff | Baseline and new snapshot have different dimensions | Ensure ignored elements keep identical dimensions across builds |
delay)seedrandom or mockdate to eliminate non-determinism (dates, IDs, random data).storybook/preview-head.htmlisChromatic() to conditionally stabilize behavior only in Chromatic100vh) shows all content| Option | Purpose |
|---|---|
chromatic: { delay: <ms> } | Wait before capturing |
chromatic: { pauseAnimationAtEnd: false } | Pause CSS animation at first frame |
chromatic: { diffThreshold: <0-1> } | Sensitivity of pixel comparison |
.chromatic-ignore / data-chromatic="ignore" | Exclude region from diff |
isChromatic() | Detect Chromatic environment at runtime |
staticDirs (Storybook config) | Serve local assets for stories |
For deeper guidance, load these companion files:
DEBUGGING-GUIDE.md — Full 9-step debugging workflow, Trace Viewer usage, MSW diagnosticsFLAKY-SNAPSHOTS.md — Flakiness causes, rerun workflow, prevention checklistEXAMPLES.md — Code examples for delay, animations, assertions, and ignoring elements