This project uses Chromatic for visual testing and review of Storybook components.
We have set up GitHub Actions to automatically run Chromatic on:
- Every push to the
main
anddev
branches - Every pull request targeting these branches
- The GitHub Action checks out the code
- Installs dependencies using pnpm
- Builds the Storybook static files
- Publishes the Storybook to Chromatic for visual testing
If you want to run Chromatic locally, you can use:
# Using environment variable
export CHROMATIC_PROJECT_TOKEN=your_project_token
pnpm run chromatic
# Or pass the token directly
CHROMATIC_PROJECT_TOKEN=your_project_token pnpm run chromatic
The Chromatic configuration is handled in two places:
-
GitHub Actions Workflow (
.github/workflows/chromatic.yml
):- Controls when Chromatic runs in CI
- Sets options like auto-accepting changes on the main branch
-
Package.json Script:
- Provides an easy way to run Chromatic locally
- Visual Testing: Detects visual changes in your components
- UI Review: Provides a platform for reviewing UI changes
- Baseline Capture: Captures baseline images of your components
- Auto-accepting Changes: Changes on the main branch are automatically accepted as new baselines
To make the integration work, you need to add the CHROMATIC_PROJECT_TOKEN
as a secret in your GitHub repository:
- Go to your GitHub repository
- Click on "Settings"
- Click on "Secrets" in the left sidebar
- Click on "Actions"
- Click "New repository secret"
- Name:
CHROMATIC_PROJECT_TOKEN
- Value: Your Chromatic project token
- Click "Add secret"