chromatic
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "chromatic":https://skillpi.com/zh/skills/deepskill-3841bc1f6470551b5c77c7181a9ba15b50817f0746251251faf867b08ff3e3b9。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
用于在带有 Storybook 集成的项目中执行视觉回归测试。适用于需要使用 Chromatic 进行 UI 审查、组件快照测试或检测视觉差异的情形;当用户提到“chromatic”、“视觉回归”、“Storybook 测试”、“UI 审查”或“视觉差异”等关键词时使用。对于一般截图比较,请参见 percy。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 软件、账号及付费要求
- 贝什
- 实测状态
- 未测试
文件浏览
Frontmatter
name: chromatic
description: When the user wants to perform visual regression testing with Storybook integration using Chromatic. Also use when the user mentions "chromatic," "visual regression," "Storybook testing," "UI review," "visual diff," or "component snapshot testing." For general screenshot comparison, see percy.
metadata:
author: terminal-skills
version: "1.0.0"
category: development
tags:
- visual-testing
- storybook
- regression
- ui-reviewChromatic
Overview
You are an expert in Chromatic, the visual testing and review platform built by the Storybook team. You help users set up Chromatic for automated visual regression testing, configure it to capture snapshots of every Storybook story, review visual diffs in the Chromatic UI, manage baselines, and integrate Chromatic into CI for pull request checks.
Instructions
Initial Assessment
- Storybook — Already using Storybook? Which version?
- Components — How many stories exist? Any interaction tests?
- CI — Which CI provider?
- Team — Who reviews visual changes? (designers, developers)
Setup
# setup-chromatic.sh — Install Chromatic and connect to your project.
# Requires a Storybook project and Chromatic project token.
# Install
npm install --save-dev chromatic
# Run first build (get project token from chromatic.com)
npx chromatic --project-token=chpt_xxxxxxxxxxxx
Story-Level Configuration
// src/components/Button.stories.tsx — Storybook stories with Chromatic config.
// Controls snapshot behavior per-story and per-component.
import type { Meta, StoryObj } from '@storybook/react';
import { Button } from './Button';
const meta: Meta<typeof Button> = {
component: Button,
parameters: {
chromatic: {
viewports: [320, 768, 1200],
delay: 300,
diffThreshold: 0.063,
},
},
};
export default meta;
type Story = StoryObj<typeof Button>;
export const Primary: Story = {
args: { variant: 'primary', children: 'Click me' },
};
export const Loading: Story = {
args: { variant: 'primary', loading: true, children: 'Loading...' },
parameters: {
chromatic: { delay: 1000 },
},
};
export const AnimatedEntry: Story = {
args: { variant: 'primary', children: 'Hello', animate: true },
parameters: {
chromatic: { disableSnapshot: true },
},
};
Interaction Testing with Chromatic
// src/components/Dropdown.stories.tsx — Storybook interaction test snapshotted by Chromatic.
// Opens the dropdown before Chromatic takes the screenshot.
import type { Meta, StoryObj } from '@storybook/react';
import { within, userEvent } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
import { Dropdown } from './Dropdown';
const meta: Meta<typeof Dropdown> = {
component: Dropdown,
};
export default meta;
type Story = StoryObj<typeof Dropdown>;
export const Opened: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const trigger = canvas.getByRole('button', { name: 'Options' });
await userEvent.click(trigger);
await expect(canvas.getByRole('menu')).toBeVisible();
},
};
Configuration
// chromatic.config.js — Chromatic configuration for snapshot behavior.
// Controls which stories to snapshot and how.
module.exports = {
projectToken: process.env.CHROMATIC_PROJECT_TOKEN,
autoAcceptChanges: 'main',
exitZeroOnChanges: true,
exitOnceUploaded: true,
onlyChanged: true,
externals: ['public/**'],
skip: 'dependabot/**',
};
CI Integration
# .github/workflows/chromatic.yml — Run Chromatic on every PR.
# Posts visual diff status check back to GitHub.
name: Chromatic
on: push
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
- uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
autoAcceptChanges: main
onlyChanged: true
Modes (Theme/Locale Testing)
// .storybook/modes.ts — Define modes to test stories in different themes and locales.
// Chromatic snapshots each mode separately.
export const allModes = {
'light desktop': { theme: 'light', viewport: 1200 },
'dark desktop': { theme: 'dark', viewport: 1200 },
'light mobile': { theme: 'light', viewport: 375 },
'dark mobile': { theme: 'dark', viewport: 375 },
};当前收录版本
1.0.0
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 解决前端开发中 UI 变更检测的核心痛点
- 提供完整的视觉回归测试解决方案
- 适用于广泛的前端开发团队和项目
亮点
- 触发词覆盖全面,包含核心关键词和场景描述
- 边界清晰,与其他工具(如 percy)有明确区分
亮点
- 文档结构清晰,包含完整的 setup、配置、CI 集成示例
- 提供了丰富的代码示例和实际使用场景
亮点
- 工具来源明确,参数配置合理
- 覆盖了主要的使用场景和异常处理
- 提供了完整的 CI/CD 集成方案
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 37, 40 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
贝什
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。