Prompt
How do I debug false positives in Chromatic?
Latest observation
Here’s a practical way to debug false positives in Chromatic (cases where Chromatic says a story changed, but you didn’t intend a visual change).
1) Verify it’s actually a false positive
Open the Chromatic build and inspect:
- Image diff
- DOM snapshot diff
- Interaction state / viewport / theme / locale
A lot of “false positives” are caused by one of:
- font loading differences
- animations/transitions
- time/date/randomness
- async data not being fully mocked
- environment-dependent rendering
- antialiasing/subpixel differences
- OS/browser differences
2) Reproduce locally with the same Storybook build
Run the same build process locally that Chromatic uses:
npx chromatic --project-token=... --debug
Then inspect:
- whether the story renders differently locally
- whether the issue appears only in CI
- whether your Storybook build includes the same globals, env vars, and mocks
If it only happens in Chromatic, it’s often due to build/runtime differences rather than an actual regression.
3) Use Chromatic’s debugging tools
In the Chromatic UI:
- compare before/after images
- inspect the snapshot DOM
- look at the Storybook URL/state
- check whether the change is in a specific region or all over the page
If the DOM is unchanged but the image differs, suspect rendering noise:
- fonts
- anti-aliasing
- browser rendering
- SVG/CSS effects
If the DOM changed, inspect props, state, or data sources.
4) Eliminate nondeterminism in your stories
Common fixes:
Freeze time
If components use Date, timestamps, or locale-based formatting:
- mock
Date.now() - use a fixed timezone
- use a deterministic date in stories/tests
Fix randomness
If you use:
Math.random()- generated IDs
- UUIDs
replace them with deterministic values in stories.
Mock network/data
Ensure async data is stable:
- use MSW or static fixtures
- avoid live API calls
- wait for loading states to settle before snapshot
Disable animations
Animations can create pixel diffs:
- disable CSS transitions/animations in Storybook
- use Chromatic parameters for reduced motion if applicable
- ensure components render in a final stable state
5) Check fonts carefully
Fonts are one of the biggest sources of false positives:
- ensure the same font files are loaded in Storybook and Chromatic
- self-host fonts if possible
- avoid relying on system fonts
- verify font loading isn’t async in a way that causes fallback rendering
6) Look for layout instability
False positives often come from:
- images loading after the snapshot
- web fonts swapping in late
- dynamic content size changes
- responsive breakpoints being borderline
- CSS depending on viewport size or scrollbar width
Make the story deterministic:
- fixed viewport
- fixed container size
- preloaded assets
- explicit dimensions for images/icons
7) Use thresholds carefully
If the change is extremely small and harmless:
- review Chromatic’s diff tolerance / threshold settings
- only relax thresholds when you’ve confirmed the variation is expected and stable
Don’t use thresholds as a blanket fix for real regressions.
8) Compare Storybook and Chromatic environments
Check:
- Node version
- browser version
- Storybook version
- environment variables
- CI vs local OS differences
- CSS preprocessing and asset paths
Sometimes a “false positive” is caused by a real mismatch between environments.
9) Reduce the story to isolate the cause
If one story is noisy:
- copy it to a minimal reproduction
- remove decorators, globals, providers, and data sources one by one
- see when the diff disappears
This usually reveals the culprit quickly.
10) If it’s still unclear
Gather:
- Chromatic build URL
- story name
- screenshot/diff
- whether the DOM changed
- local reproduction steps
- recent code changes
Then inspect whether the issue is:
- rendering nondeterminism
- a genuine visual change
- a bug in Storybook/Chromatic/browser rendering
If you want, I can also give you a Chromatic false-positive troubleshooting checklist or help diagnose a specific diff if you share what kind of change you’re seeing.