generate 用于根据用户故事、URL、组件名或功能描述生成可直接使用的 Playwright 测试。输入通过 $ARGUMENTS 提供,例如“user can log in with email and password”“the checkout flow”“src/components/UserProfile.tsx”或“the search page with filters”。
主要能力:解析目标是用户故事、组件路径还是页面/URL;用 Explore 子代理读取 playwright.config.ts(testDir、baseURL、projects)、testDir 下的既有测试、组件源码、pages/、fixtures/ 及 auth.setup.ts 或 storageState 配置;按登录、CRUD、结账、搜索、表单、仪表盘、设置、引导、API、无障碍等类型从 templates/ 选择模板并替换占位符;按项目约定生成 .spec.ts 或 .spec.js,优先复用既有页面对象、自定义 fixtures 与 test-data/;在需要时额外生成页面对象、fixture 或测试数据。
用法:生成的测试使用 test.describe 与 test 结构,定位器优先 getByRole、getByLabel、getByText、getByPlaceholder,其次 getByTestId;断言使用 web-first 形式(如 toBeVisible、toHaveText);禁止 page.waitForTimeout、page.$/$$、无必要裸 CSS 选择器及用 page.evaluate 替代定位器;导航使用 baseURL 相对路径。生成后运行 npx playwright test <generated-file> --reporter=list 验证,失败时先修测试而非应用,应用问题报告给用户。输出包含文件路径、支持文件、运行结果和覆盖说明。
限制:资料未提供收费、价格、平台或其他限制信息。