用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Dev-Toolbelt/dev-team-agents --skill snapshot-testing命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | snapshot-testing |
| description | Snapshot testing — when to use, maintenance, CI integration. |
| Use snapshots for | Do NOT use snapshots for |
|---|---|
| UI components with stable, complex render output | Business logic with frequently changing return values |
| Serialized data structures (API response shape) | Anything that changes on every run (timestamps, random IDs) |
| Error message strings that must stay stable | Core algorithm correctness — use explicit assertions |
| CLI command output format | Database query results in integration tests |
Rule of thumb: if a snapshot update is expected more than once per sprint for a given component, snapshots are the wrong tool for that component.
--updateSnapshot without visually confirming the new output is correct.expect(value).toBe(...) assertions for critical logic.If a snapshot file exceeds 50 lines, the component under test is too complex. Options:
# Jest
jest --updateSnapshot
# Vitest
vitest --update
# Run only tests for a specific component
jest src/components/Button --updateSnapshot
Before running update:
--updateSnapshot to confirm they pass cleanCommit message when updating snapshots:
test(Button): update snapshot after adding disabled state variant
Always explain WHY the snapshot changed — not just "update snapshots".
.gitignore snapshot directories--updateSnapshot; if a snapshot changed without an update commit, the build fails// jest.config.js
module.exports = {
snapshotSerializers: ['@emotion/jest/serializer'], // if using CSS-in-JS
// CI will fail automatically if snapshots are outdated — no extra config needed
};
src/components/__snapshots__/Button.test.tsx.snap| Mistake | Fix |
|---|---|
| Snapshotting the entire page/route | Snapshot only the component under test |
| Not seeding deterministic test data | Mock Date.now(), UUIDs, and random values |
| Leaving obsolete snapshots after component rename | Run jest --ci with --verbose to find orphaned snapshots |
Committing --updateSnapshot in CI script | CI must never auto-update; only developers update locally |
--updateSnapshot