xiaohongshu
xiaohongshu
chromatic
Automates visual regression testing for Storybook components using cloud-based snapshot comparison. Use when setting up visual testing, catching UI regressions, or reviewing component changes.
Full skill instructions
Cloud-based visual testing platform that captures screenshots of every Storybook story and detects visual changes.
# Install Chromatic
npx storybook add chromatic
# Or install manually
npm install --save-dev chromatic
# Run visual tests (first time creates baselines)
npx chromatic --project-token=<token>
{
"projectToken": "chpt_xxxxxxxxxxxx",
"buildScriptName": "build-storybook",
"storybookBuildDir": "storybook-static",
"zip": true,
"autoAcceptChanges": "main",
"exitOnceUploaded": false,
"exitZeroOnChanges": false,
"onlyChanged": true,
"externals": ["public/**"],
"skip": "dependabot/**"
}
{
"scripts": {
"chromatic": "chromatic --exit-zero-on-changes",
"chromatic:ci": "chromatic --auto-accept-changes=main"
}
}
// Skip specific story
export const Loading: Story = {
parameters: {
chromatic: { disableSnapshot: true }
}
};
// Skip all stories in file
export default {
title: 'Components/Spinner',
parameters: {
chromatic: { disableSnapshot: true }
}
};
export const Responsive: Story = {
parameters: {
chromatic: {
viewports: [320, 768, 1200]
}
}
};
export const Animated: Story = {
parameters: {
chromatic: {
delay: 300, // Wait 300ms before snapshot
pauseAnimationAtEnd: true
}
}
};
export const SubtleChanges: Story = {
parameters: {
chromatic: {
diffThreshold: 0.2 // 0-1, higher = more tolerant
}
}
};
// Test in multiple browsers
export default {
title: 'Components/Button',
parameters: {
chromatic: {
modes: {
chrome: { viewport: 1200 },
firefox: { viewport: 1200 },
safari: { viewport: 1200 },
edge: { viewport: 1200 }
}
}
}
};
// .storybook/modes.ts
export const allModes = {
light: { theme: 'light' },
dark: { theme: 'dark' },
mobile: { viewport: { width: 375, height: 667 } },
desktop: { viewport: { width: 1200, height: 800 } }
};
// Component story
export const Button: Story = {
parameters: {
chromatic: {
modes: {
'light desktop': allModes['light'],
'dark desktop': { ...allModes['dark'], ...allModes['desktop'] },
'light mobile': { ...allModes['light'], ...allModes['mobile'] }
}
}
}
};
name: Chromatic
on: push
jobs:
chromatic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for accurate baselines
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
autoAcceptChanges: main
onlyChanged: true
chromatic:
stage: test
image: node:20
script:
- npm ci
- npx chromatic --project-token=$CHROMATIC_PROJECT_TOKEN
only:
- merge_requests
- main
Only test stories affected by code changes:
npx chromatic --only-changed
Configure in CI:
- uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
onlyChanged: true
traceChanged: expanded # Track changes across files
export const WithTimestamp: Story = {
parameters: {
chromatic: {
diffIncludeAntiAliasing: false
}
},
decorators: [
(Story) => (
<>
<Story />
<span data-chromatic="ignore">
{new Date().toISOString()}
</span>
</>
)
]
};
export const UserProfile: Story = {
parameters: {
chromatic: { delay: 500 }
},
loaders: [
async () => ({
user: { name: 'Test User', avatar: '/mock-avatar.png' }
})
]
};
# Auto-accept on main branch
npx chromatic --auto-accept-changes=main
# Accept specific branches
npx chromatic --auto-accept-changes="main|release/*"
# Skip CI for specific patterns
npx chromatic --skip="dependabot/**"
# Skip with commit message
git commit -m "docs: update readme [skip chromatic]"
// Increase delay for async content
parameters: {
chromatic: {
delay: 1000,
diffThreshold: 0.1
}
}
// Wait for fonts in preview.js
export const decorators = [
(Story) => {
const [fontsLoaded, setFontsLoaded] = useState(false);
useEffect(() => {
document.fonts.ready.then(() => setFontsLoaded(true));
}, []);
return fontsLoaded ? <Story /> : null;
}
];
{
"externals": [
"public/fonts/**",
"public/images/**"
]
}
See references/configuration.md for complete CLI options and references/ci-integration.md for advanced CI setups.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience