Update Storybook visual regression snapshots after intentional UI changes. Use when visual tests fail due to expected changes, or when asked to update snapshots.
Storybook snapshots are baseline images used for visual regression testing. When UI components change intentionally, snapshots must be updated to reflect the new expected appearance.
Update snapshots when:
Do NOT update snapshots when:
pnpm test:storybook
Review which snapshots failed. Failures generate diff images.
Diff images are saved to:
packages/keychain/__image_snapshots__/__diff_output__/
Each diff image shows:
Verify the changes are intentional before proceeding.
pnpm test:storybook:update
This regenerates all snapshot images based on current component rendering.
Check the updated images look correct:
# List changed snapshot files
git status packages/*/__image_snapshots__/
# View specific changes (if you have an image viewer)
ls packages/keychain/__image_snapshots__/*.png
git add packages/*/__image_snapshots__/
git commit -m "chore: update storybook snapshots"
packages/keychain/__image_snapshots__/
āāā components-*.png # Component snapshots
āāā __diff_output__/ # Diff images (not committed)
ā āāā *-diff.png
packages/keychain/src/components/pnpm test:storybook:update to generate initial snapshotWhen design tokens or theme changes affect multiple components:
# Update all snapshots at once
pnpm test:storybook:update
# Review all changes
git diff --stat packages/*/__image_snapshots__/
# Commit with descriptive message
git add packages/*/__image_snapshots__/
git commit -m "chore: update snapshots for design system changes"
The CI workflow (test.yml) can auto-update snapshots and push:
This means if you push changes that affect visuals, CI may auto-commit updated snapshots to your PR.
Storybook must be able to start:
# Kill any existing Storybook process
pkill -f storybook
# Ensure port 6006 is free
lsof -i :6006
# Try running Storybook manually first
pnpm storybook
If snapshots differ between local and CI:
pnpm clean && pnpm i && pnpm build:deps
There's also a helper script available:
./scripts/update-storybook-snapshot.sh
