How to Run Chromatic for Storybook in CI
Chromatic builds your Storybook, snapshots every story in its cloud, and needs only the chromatic CLI plus a project token in CI.
Run the chromatic CLI with --project-token; it builds Storybook, uploads it, and captures one snapshot per story for review against the last accepted baseline.
Steps
- Install
chromaticas a dev dependency. - Store the project token as the
CHROMATIC_PROJECT_TOKENsecret. - Run
npx chromaticin CI on each push. - Review and accept changes in the Chromatic UI.
Install
Terminal
npm install --save-dev chromaticWorkflow
.github/workflows/ci.yml
jobs:
chromatic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npx chromatic --project-token=${{ secrets.CHROMATIC_PROJECT_TOKEN }}Gotchas
- Chromatic needs full git history (
fetch-depth: 0) to compare against the correct baseline commit. - A shallow clone makes it snapshot every story as new each run.
Related guides
How to Enable TurboSnap for Changed Stories in ChromaticCut Chromatic snapshot cost with TurboSnap, which uses the Webpack dependency graph to snapshot only stories…
How to Set Up Percy Visual Testing in CIAdd Percy visual testing to CI by installing @percy/cli, wrapping your test command with percy exec, and pass…