# playwright Official Playwright end-to-end testing best practices for AI coding agents. ```bash npx rulepack add playwright ``` ## What it covers - **Locators** — prefer user-facing locators (`getByRole`, `getByText`, `getByLabel`) over CSS/XPath; chain and filter to disambiguate. - **Assertions** — use web-first auto-retrying assertions (`await expect(locator).toBeVisible()`); avoid manual `isVisible()` checks and manual waits. - **Test isolation** — independent storage/cookies/data per test; shared setup via `beforeEach`/`afterEach` and `storageState`. - **Tooling & CI** — cross-browser projects, traces on first retry, lint with `no-floating-promises`, keep Playwright updated. - **Scope** — test user-visible behaviour, not implementation; mock third-party services with `page.route()`. ## Source Distilled from the official Playwright documentation: https://playwright.dev/docs/best-practices ## License MIT