一键导入
playwright
Playwright E2E testing standards. Use when writing or reviewing end-to-end tests (*.e2e.ts) for browser-based user journeys and visual regression.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Playwright E2E testing standards. Use when writing or reviewing end-to-end tests (*.e2e.ts) for browser-based user journeys and visual regression.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Deep interview for a single feature or module brief that produces a final spec or implementation plan.
@nextnode-solutions/logger standards. Reference this skill when a project uses @nextnode-solutions/logger or when logger integration is being added.
Manage n8n workflows on the NextNode automation instance with the local n8n-cli tool.
NextNode brand guidelines — color palette, typography, logo system, and per-project branding rules. Use when doing UI/frontend work on a NextNode project.
NextNode ecosystem hub. Auto-load when working on any NextNode or SaaS project — covers nextnode.toml config, CI workflows, docker-compose rules, and cross-references to package skills.
Audit a NextNode/SaaS project against all NextNode standards — produces a compliance report with pass/fail/missing status for every required item.
| name | playwright |
| description | Playwright E2E testing standards. Use when writing or reviewing end-to-end tests (*.e2e.ts) for browser-based user journeys and visual regression. |
| user-invocable | false |
E2E tests verify what unit tests can't — real browser rendering, visual correctness, cross-browser behavior, and full user journeys. Playwright tests are complementary to vitest, not a replacement. Don't re-test logic already covered by unit tests.
Verify components render correctly in a real browser — design spec compliance, focus/hover/keyboard behavior, visual regression via screenshots. A Button.tsx deserves both a vitest test (logic, event handlers) and a Playwright test (visual appearance, real browser interactions).
Use for:
toHaveScreenshot())Full user workflows spanning multiple pages and interactions.
Use for:
onClick calls the right handler — vitest covers thatPriority order (same a11y-first philosophy as RTL):
getByRole('button', { name: 'Submit' }) — preferredgetByTestId('checkout-form') — acceptable fallbackAvoid fragile selectors tied to DOM structure or styling classes.
// Navigation
await expect(page).toHaveURL('/dashboard')
await expect(page).toHaveTitle('Dashboard')
// Visibility and state
await expect(locator).toBeVisible()
await expect(locator).toBeEnabled()
await expect(locator).toHaveText('Welcome')
await expect(locator).toHaveAttribute('aria-expanded', 'true')
// Visual regression
await expect(page).toHaveScreenshot('dashboard.png')
await expect(locator).toHaveScreenshot('button-hover.png')
Encapsulate page interactions for maintainability:
class LoginPage {
constructor(private page: Page) {}
readonly emailInput = () => this.page.getByRole('textbox', { name: 'Email' })
readonly passwordInput = () => this.page.getByRole('textbox', { name: 'Password' })
readonly submitButton = () => this.page.getByRole('button', { name: 'Sign in' })
async login(email: string, password: string) {
await this.emailInput().fill(email)
await this.passwordInput().fill(password)
await this.submitButton().click()
}
}
page.route('**/api/users', route => route.fulfill({ json: mockData })) for deterministic testspage.waitForResponse('**/api/users') when testing against a running backendReuse auth state across tests to avoid repeated login flows:
// Global setup: save auth state
await page.context().storageState({ path: 'e2e/.auth/user.json' })
// Test config: reuse auth state
use: { storageState: 'e2e/.auth/user.json' }
toHaveScreenshot() for component and page-level visual checksnpx playwright test --update-snapshotsmaxDiffPixelRatio for tolerance on anti-aliasing differences// playwright.config.ts
use: {
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
}
npx playwright show-trace trace.zippage.pause() during development for step-by-step debugginge2e/
components/ # Component-level E2E tests
button.e2e.ts
sidebar.e2e.ts
journeys/ # Journey-level E2E tests
auth.e2e.ts
checkout.e2e.ts
pages/ # Page Object Models
login-page.ts
dashboard-page.ts
fixtures/ # Shared test fixtures and data
.auth/ # Saved auth state (gitignored)
playwright.config.ts
*.e2e.tse2e/components/ or colocated with sourcee2e/journeys/e2e/pages/use: { headless: true }retries: process.env.CI ? 2 : 0npx playwright test --shard=1/4playwright.config.ts for reproducibility