一键导入
e2e-testing
Write end-to-end tests using Playwright. Test user behavior, not implementation details. Also useful for non-test Playwright scripting.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Write end-to-end tests using Playwright. Test user behavior, not implementation details. Also useful for non-test Playwright scripting.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Guide for diagnosing and fixing snapshot failures, flakiness, and comparison issues in Chromatic.
Write React components following idiomatic patterns, hooks best practices, and performance optimizations
Write React components designed to be easily tested with Playwright and Testing Library — semantic HTML, clear boundaries, no test-specific hacks
| name | e2e-testing |
| description | Write end-to-end tests using Playwright. Test user behavior, not implementation details. Also useful for non-test Playwright scripting. |
Test what users see and do, never implementation details. Every selector choice should be semantic.
| Priority | Method | Use when |
|---|---|---|
| 1 | getByRole('button', { name: /submit/i }) | Any semantic element |
| 2 | getByLabel('Email') | Form inputs |
| 3 | getByPlaceholder(...) | Inputs without labels |
| 4 | getByAltText(...) | Images |
| 5 | getByTitle(...) | Icon buttons with no text |
| 6 | getByTestId(...) | Last resort only |
| 7 | getByText(...) | Non-interactive text only |
| ❌ | locator('.class') / XPath | Never |
await expect)await expect(page.getByRole('button', { name: 'Save' })).toBeVisible()
await expect(page.getByLabel('Email')).toHaveValue('user@example.com')
await expect(page.getByRole('checkbox')).toBeChecked()
await expect(page.getByRole('listitem')).toHaveCount(5)
await expect(page).toHaveURL('/dashboard')
Never use waitForTimeout() or waitForSelector() — await expect() auto-retries.
beforeEach for common setup within a suiteafterEach for cleanup (prefer API calls over UI)waitForTimeout() / arbitrary sleeps