visual-regression
它能做什么
这个技能设置视觉测试,随时间对比页面或组件的截图。它面向希望在上线前发现意外设计变化的团队。
适用场景
- ✓CSS 修改可能破坏单元测试没有检查的布局的时候。
- ✓项目的持续集成流程中没有任何视觉检查的时候。
- ✓关键组件需要一个稳定的视觉基准的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/visual-regression/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我们修改了一些 CSS,现在页面的部分内容看起来不对,但测试仍然通过。请帮我们添加视觉检查吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会找出关键页面或组件,并截取基准截图。之后的运行会把新截图与基准进行比较,并标出超过设定阈值的差异。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use visual regression testing
Functional tests verify behavior but don't see your page. A CSS refactor might pass all unit and integration tests while completely breaking the layout — text overlapping images, buttons invisible, wrong colors. Visual regression testing acts as a safety net that reviews your actual rendered output, catching changes that no amount of JavaScript testing can detect.
Quick Reference
- Visual regression tests catch CSS regressions that functional tests miss
- Run screenshot comparisons in CI to block merges that break visual appearance
- Use component-level (Storybook) tests for focused, fast visual coverage
- Set pixel difference thresholds to avoid flaky tests from sub-pixel rendering
Check
Does this project have visual regression testing? What critical components or pages would benefit most from visual baselines?
Fix
Set up visual regression tests for the key components using Playwright's screenshot comparison or a tool like Chromatic.
Explain
Explain visual regression testing, how it differs from functional tests, and how to set up screenshot comparison in a CI pipeline.
Code Review
Review tests, CI workflows, and enforcement points related to Use visual regression testing. Flag exact gaps where the rule is not automatically verified or where failures do not block regressions.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/testing/visual-regression
常见问题
什么工具可以做到这一点?
这个技能提到了 Playwright 截图对比和 Chromatic 作为可选方案。
为什么要设置差异阈值?
微小的渲染差异可能导致测试不稳定,阈值可以避免因细微改动而失败。
视觉测试应该在 CI 中运行吗?
应该。这个技能建议在 CI 中运行截图对比,阻止会破坏外观的合并。
详情
作者的原始描述
Use when reviewing CI coverage, automated checks, or test strategy related to Use visual regression testing. Focus on whether the rule is continuously verified, not just documented.
热度
- GitHub 星标
- 75k
- 排名
- #3080
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。