with one click
test
测试清单 — 单测、集成、E2E、TDD 红绿重构;衔接 verify。说「写测试」「TDD」「Playwright」时用。
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
测试清单 — 单测、集成、E2E、TDD 红绿重构;衔接 verify。说「写测试」「TDD」「Playwright」时用。
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
REST/OpenAPI 设计审查。
系统调试循环(/debug)— 复现→假设→隔离→验证→记录;禁止无复现盲改。说「修 bug」「测挂了」「不知道为啥挂」时用。
交付验收(/delivery):视觉 · i18n · 文档对齐 · 后端对接 · 组件完整度 · 可维护性 · 生产就绪。Sprint 收尾或 /release 分支前走查。说「交付验收」「上线前检查」「生产就绪」时用。
磁盘快照(/disk):结构化采集 HOME 与可配置路径占用,写入 .cursorGrowth/disk-snapshots/, 并与上次快照对比变动。说「磁盘快照」「空间变动」「disk snapshot」时也触发。
Git — 分支、提交、合并。需要 git 操作时用。
信息架构(IA)规划与审查(/ia)— 工作流正交、角色入口、分支点、反模式。说「信息架构」「导航迷路」「角色首页」「工作流分支」「Dashboard 太乱」时用。
| name | test |
| description | 测试清单 — 单测、集成、E2E、TDD 红绿重构;衔接 verify。说「写测试」「TDD」「Playwright」时用。 |
验收优先 plan 列命令;无列则用项目 ./scripts/test.sh 或 stack 默认。测试文件细则 → rules/execution/testing.mdc。
与 run 一致:红测不 ✅ task · 须实际运行 task-verify。
吸收自 SkillsMP testing-patterns(协议 only;栈细则仍看 rules/execution/testing.mdc)。
| 手法 | 何时用 | 要点 |
|---|---|---|
| Factory | 实体/DTO 构造重复、字段组合多 | 默认值 + 每测只覆盖差异字段;避免 20 行 arrange |
| Test double | 外部 I/O、时钟、随机、网络 | 优先接口边界注入;单测不真连 DB/HTTP(除非集成层) |
| Mock(函数/模块) | 断言「被调用方式」或隔离慢依赖 | mock 行为而非实现细节;一个测试一个主要 mock 面 |
| Stub | 只需固定返回值、不关心调用次数 | 比 mock 更简单时用 stub/fixture 数据 |
纪律:
vi.useFakeTimers / jest fake timers 等栈等价物| 类型 | 何时 |
|---|---|
| 单元 | 纯逻辑、utils、hooks |
| 集成 | API、DB、模块边界 |
| E2E | 关键用户路径(Playwright/Cypress 若项目已有) |
层定义真源:rules/feedback/verify.mdc §分层验收(L0–L3)。本 skill 不重复该表。
task-verify;L3 进 Sprint Done when 或 nightlylearn/(如 dev-conventions.md),勿写进 .cursor/;聚合脚本仅编排(见 verify.mdc)npx playwright test 或项目 scriptwebServer 配置脚本:scripts/with_server.py(起停 dev server)· scripts/examples/(Playwright 示例)
许可:scripts/LICENSE-anthropics.txt
依赖:pip install playwright · playwright install chromium
黑盒纪律:先 python .cursor/skills/test/scripts/with_server.py --help,勿把脚本源码读入上下文。
决策树:
任务 → 静态 HTML?
├─ 是 → 直接读 HTML 找 selector → 写 Playwright(见 examples/static_html_automation.py)
└─ 否(动态)→ server 已起?
├─ 否 → with_server.py 起服 + 你的 automation.py
└─ 是 → 侦察再行动:goto → networkidle → screenshot/DOM → 再操作
侦察再行动(动态 SPA):
page.wait_for_load_state('networkidle') — 必须先等page.locator(...).all() 探 selector多服(前后端分离):
python .cursor/skills/test/scripts/with_server.py \
--server "cd backend && python server.py" --port 3000 \
--server "cd frontend && npm run dev" --port 5173 \
-- python your_automation.py
与 debug 配合:UI 挂时抓 console(examples/console_logging.py)· 先 networkidle 再断言。