Prompt
I'm building a React design system and need visual regression testing for shared components
Latest observation
Nov 12, 2026
OpenAI APIWeb search: off
A solid setup for visual regression testing in a React design system is usually:
Recommended stack
- Storybook for isolated component examples
- Playwright or Chromatic for screenshot-based regression tests
- CI to run comparisons on every PR
Best option for design systems: Storybook + Chromatic
If you want the simplest and most common workflow:
- Build components in Storybook
- Connect Storybook to Chromatic
- Chromatic captures baseline screenshots and compares changes on PRs
Why this works well
- Easy for shared components
- Works naturally with component variants/states
- Great review workflow for designers and engineers
- Minimal test maintenance
Alternative: Storybook + Playwright
If you want full control or want to avoid a SaaS tool:
- Create Storybook stories for each component state
- Use Playwright to open each story
- Take screenshots
- Compare against committed baselines
Pros
- Full control
- Can run locally and in CI
- No vendor dependency
Cons
- You manage baseline images, thresholds, flakiness, and review workflow
- More setup than Chromatic
Suggested approach for a React design system
1. Create stories for every important state
For each shared component, include:
- default
- hover
- active
- disabled
- loading
- error
- dark mode
- responsive sizes
- long text / edge cases
Example:
export const Default = {};
export const Disabled = {
args: { disabled: true },
};
export const LongLabel = {
args: { children: 'This is a very long button label' },
};
2. Standardize the visual environment
To reduce false positives:
- lock viewport size
- use consistent fonts
- mock dates/time/network
- freeze animations
- disable transitions in test mode
- use stable theme/provider wrappers
3. Decide what to compare
Usually compare:
- component rendering
- spacing
- typography
- colors
- icon alignment
- truncation/overflow behavior
Avoid comparing:
- live timestamps
- random avatars
- animated states unless intentionally tested
4. Run in CI
Your pipeline should:
- build Storybook
- run visual snapshots
- upload results
- fail on unexpected diffs
If you want a practical recommendation
For most React design systems:
Use Storybook + Chromatic first.
It gives the fastest path to value and is widely used for component libraries.
If you need self-hosted or custom control: Use Storybook + Playwright screenshot tests.
Good testing practices
- Keep stories deterministic
- Use one story per visual state
- Test components in isolation, not whole pages
- Review diffs manually before approving
- Update baselines only when changes are intentional
If you want, I can give you:
- a step-by-step setup for Storybook + Chromatic, or
- a Playwright-based visual regression setup with example code.