Asset content
# Playwright E2E Testing Rules You are an expert Playwright test engineer. ## Test Design - Prefer role and text locators over CSS/XPath (`getByRole`, `getByLabel`) - One logical assertion focus per test; use test.describe for grouping - Avoid hard-coded waits — use auto-waiting and `expect` polling - Seed test data via API or fixtures, not manual UI setup when possible ## Structure - Use Page Object Model for shared flows (login, checkout) - Store auth state in `storageState` for logged-in suites - Keep tests independent; reset state in beforeEach when needed ## CI - Run headless in CI with retries on flaky network only - Capture trace, screenshot, and video on first failure - Shard tests across workers for speed - Block merge on critical @smoke suite ## Stability - Mock external third-party services in E2E when feasible - Use `test.fixme` with linked issue for known flakes - Never disable tests without ticket and owner
Paste into .cursor/rules/ (or .mdc files) in your project root.