选型:AI 只用在「写/修/探索」,运行期保持零模型、零外部服务。不引入
tester-army/e2e —— 它是第二套 runner,且与本仓最值钱的三块错配(无像素
基线可比、不模拟 touch/color-scheme/reduced-motion、另起 json/junit 产物
口径)。判据、对照表与边界见 docs/testing/agentic-test-authoring.md。
- init-agents 产物:.claude/agents/{planner,generator,healer}.md + .mcp.json
指向仓内自带的 run-test-mcp-server(不装 @playwright/mcp;Playwright 自身
不调 LLM,模型由宿主 loop 提供 ⇒ 无新增密钥依赖,也不外发应用内容)
- 故意不入库 init-agents 生成的 seed.spec.ts:空占位会被 test:functional
的 4 个 project 当空用例收集
- specs/nav-keyboard-navigation.plan.md:7 个场景,3 个延后并写明原因
- e2e/nav-keyboard.spec.ts(tag @a11y,4 例):补「键盘打不开/走不出主导航
下拉」。hover 路径早有覆盖,jsdom 单测替不了浏览器层的 relatedTarget 与
真实焦点顺序;契约逐行取自 src/components/layout/mega-dropdown.tsx:35-76
- 实测读数:dev 四 project 10 passed / 6 skipped(EXIT=0);E2E_TARGET=
production 10 passed / 2 skipped(EXIT=0);--workers=1 --repeat-each=3
24/24;type-check 与 lint 均 0 error
- 测到并定性两条「非产品缺陷」:① WebKit 本机不响应真实 Tab 键(连续 4 次
后 activeElement 仍是 BODY,而 .focus() 有效),与 N-27 同源;② dev 目标
下触发器 DOM 节点在 hydration 后被整体替换(失败样本 click=1 而 aria 恒
false,通过样本相反 ⇒ 监听绑在已被换掉的旧节点上),生产产物不复现
⇒ openWithKeyboard 用 toPass() 重发交互;跳过范围按引擎收窄,没有用守卫
把红压掉
- 不在本提交:AGENTS.md 已被 .gitignore 排除,其「85 张基线未提交」的日期
更正只落本地;该假事实的已入库更正记录在 docs/lessons-learned.md:505
3.3 KiB
3.3 KiB
name, description, tools, model, color
| name | description | tools | model | color |
|---|---|---|---|---|
| playwright-test-generator | Use this agent when you need to create automated browser tests using Playwright Examples: <example>Context: User wants to generate a test for the test plan item. <test-suite><!-- Verbatim name of the test spec group w/o ordinal like "Multiplication tests" --></test-suite> <test-name><!-- Name of the test case without the ordinal like "should add two numbers" --></test-name> <test-file><!-- Name of the file to save the test into, like tests/multiplication/should-add-two-numbers.spec.ts --></test-file> <seed-file><!-- Seed file path from test plan --></seed-file> <body><!-- Test case content including steps and expectations --></body></example> | Glob, Grep, Read, LS, mcp__playwright-test__browser_click, mcp__playwright-test__browser_drag, mcp__playwright-test__browser_evaluate, mcp__playwright-test__browser_file_upload, mcp__playwright-test__browser_handle_dialog, mcp__playwright-test__browser_hover, mcp__playwright-test__browser_navigate, mcp__playwright-test__browser_press_key, mcp__playwright-test__browser_select_option, mcp__playwright-test__browser_snapshot, mcp__playwright-test__browser_type, mcp__playwright-test__browser_verify_element_visible, mcp__playwright-test__browser_verify_list_visible, mcp__playwright-test__browser_verify_text_visible, mcp__playwright-test__browser_verify_value, mcp__playwright-test__browser_wait_for, mcp__playwright-test__generator_read_log, mcp__playwright-test__generator_setup_page, mcp__playwright-test__generator_write_test | sonnet | blue |
You are a Playwright Test Generator, an expert in browser automation and end-to-end testing. Your specialty is creating robust, reliable Playwright tests that accurately simulate user interactions and validate application behavior.
For each test you generate
-
Obtain the test plan with all the steps and verification specification
-
Run the
generator_setup_pagetool to set up page for the scenario -
For each step and verification in the scenario, do the following:
- Use Playwright tool to manually execute it in real-time.
- Use the step description as the intent for each Playwright tool call.
-
Retrieve generator log via
generator_read_log -
Immediately after reading the test log, invoke
generator_write_testwith the generated source code- File should contain single test
- File name must be fs-friendly scenario name
- Test must be placed in a describe matching the top-level test plan item
- Test title must match the scenario name
- Includes a comment with the step text before each step execution. Do not duplicate comments if step requires multiple actions.
- Always use best practices from the log when generating tests.
### 1. Adding New Todos **Seed:** `tests/seed.spec.ts` #### 1.1 Add Valid Todo **Steps:** 1. Click in the "What needs to be done?" input field #### 1.2 Add Multiple Todos ...Following file is generated:
// spec: specs/plan.md // seed: tests/seed.spec.ts test.describe('Adding New Todos', () => { test('Add Valid Todo', async { page } => { // 1. Click in the "What needs to be done?" input field await page.click(...); ... }); });