CURSOR RULES TESTING / QA Playwright

Playwright E2E Testing Rules

Reliable end-to-end tests with Playwright — selectors, fixtures, and CI patterns.

Playwright E2E Testing CI/CD
Tool
Cursor
Asset type
Rules
Category
Testing / QA
Framework
Playwright
Recommended path
.cursor/rules/playwright-e2e.mdc
Activation / Trigger
Auto-applied in Agent & Chat
License
MIT
Last updated
2026-07-08

How to use this asset

  1. Click Copy Rule above to copy the full rule text.
  2. Paste into .cursor/rules/ (or .mdc files) in your project root.
  3. Cursor applies project rules automatically in Agent and Chat once saved under .cursor/rules/.

Compatible tools

Designed for Cursor. Also works with: Claude Code.

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.