用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Dev-Toolbelt/dev-team-agents --skill visual-regression命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | visual-regression |
| description | Visual regression — screenshot diffing, Playwright/Chromatic, CI. |
| Tool | Best for | Hosting |
|---|---|---|
| Playwright screenshot comparison | Custom workflows; full-page and component screenshots; already in stack | Self-hosted |
| Storybook + Chromatic | Design system components; story-level diffing; team review UI | SaaS (Chromatic) |
| Percy | Cross-browser visual testing; integrates with many CI platforms | SaaS |
| Applitools Eyes | AI-powered diffing; reduced false positives; enterprise scale | SaaS |
| Loki | Storybook-only; lightweight; open source | Self-hosted |
Recommendation: use Playwright for integration-level flows; use Chromatic for component/design system work.
| Use visual regression for | Do NOT use for |
|---|---|
| Design system components (Button, Card, Modal) | Every component — adds test maintenance burden |
| Marketing and landing pages | Logic-heavy components with no visual output |
| Critical user flows (checkout, onboarding) | Components that change every sprint |
| Responsive layout breakpoints | Feature flags that render entirely different UIs |
Principle: visual regression tests are high-signal, low-quantity. Prefer 20 meaningful screenshots over 200 noisy ones.
git tag visual-baseline-YYYY-MM-DD# Regenerate all baselines
npx playwright test --update-snapshots
# Update a specific test file
npx playwright test tests/visual/button.spec.ts --update-snapshots
| Difference | Action |
|---|---|
| 0% – 0.1% | Acceptable — sub-pixel anti-aliasing variation |
| 0.1% – 1.0% | Always review — may be font rendering, shadow, or real regression |
| > 1.0% | Treat as a regression until proven otherwise; block merge |
// playwright.config.ts
export default defineConfig({
expect: {
toHaveScreenshot: {
maxDiffPixelRatio: 0.001, // 0.1% threshold
threshold: 0.2, // per-pixel color tolerance (0–1)
},
},
});
mainmain to catch environmental driftvisual-regression:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npx playwright install --with-deps chromium
- run: npx playwright test tests/visual/
- uses: actions/upload-artifact@v4
if: failure()
with:
name: visual-regression-diff
path: test-results/
Always upload diff artifacts on failure — reviewers need to see what changed without re-running locally.
| Cause | Fix |
|---|---|
| Animation not complete at screenshot time | Wait for animation end: await page.waitForTimeout(300) or disable animations in test |
| Font loading inconsistency | Use page.waitForLoadState('networkidle') or self-host fonts in tests |
| Dynamic content (dates, counts) | Mock or freeze dynamic data before screenshotting |
| OS font rendering differences | Run all visual tests in the same Docker image |