# playwright-e2e-testing

A Claude Code rule that enforces Playwright E2E testing standards: Page Object Model, locators, browser context isolation, and parallel runs.

- rule · `type=rule` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline · ★ 267 repo stars
- Author: przeprogramowani
- License: AGPL-3.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/przeprogramowani/ai-rules-builder/tree/HEAD/.cursor/rules/playwright-e2e-testing.mdc
- Updated: 2026-02-20
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/playwright-e2e-testing

## What it does

The rule lives at `.claude/rules/playwright-e2e-testing.md` and takes effect whenever the agent works on E2E testing tasks. Configuration is scoped to Chromium/Desktop Chrome; browser contexts handle environment isolation between test runs. Page objects go into `./e2e/page-objects`.

Element selection relies on Playwright locators rather than raw CSS or XPath, which keeps tests stable when markup changes. Visual regression uses `expect(page).toHaveScreenshot()`, and backend validation happens through API calls within the same test suite. Test hooks cover setup and teardown; the trace viewer is the prescribed tool for debugging failures.

Because `alwaysApply` is set to `false`, the rule does not activate on every prompt — it needs to be referenced explicitly in the task. Parallel execution is part of the rule's requirements, so the agent will configure it wherever Playwright's own setup allows.

## Requirements
- Works with: Playwright

## Install

### Cursor (native platform)

**Manually: put the files in place**
- File: `.cursor/rules/playwright-e2e-testing.mdc` — Frontmatter: description, globs, alwaysApply

### Claude Code

**Manually: put the files in place**
- File: `.claude/rules/playwright-e2e-testing.md` — The paths frontmatter field limits the files: move globs from the source into paths

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/playwright-e2e-testing.instructions.md` — The applyTo field sets which files it applies to: move globs from the source into applyTo

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/playwright-e2e-testing.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/playwright-e2e-testing.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/przeprogramowani/ai-rules-builder/tree/HEAD/.cursor/rules/playwright-e2e-testing.mdc

## When to use it
- set up Playwright config scoped to Chromium with browser context isolation
- generate Page Object Model classes under `./e2e/page-objects`
- add screenshot comparison using `expect(page).toHaveScreenshot()`
- structure tests with Arrange-Act-Assert from the start
- validate backend responses through API calls inside an E2E test suite

## Example prompts
- Write an E2E test for the login form using Page Object Model in `./e2e/page-objects`
- Add visual regression for the dashboard with `expect(page).toHaveScreenshot()`
- Configure `playwright.config.ts` for Chromium only with parallel test execution

## Similar
- [e2e-playwright-testing](https://affpapa.org/en/nevibecode/skills/e2e-playwright-testing.md) — skill · 880 installs
- [playwright-e2e-testing-cursorrules-prompt-file](https://affpapa.org/en/nevibecode/rules/playwright-e2e-testing-cursorrules-prompt-file.md) — rule · ★ 41178 repo stars
- [playwright-best-practices](https://affpapa.org/en/nevibecode/skills/playwright-best-practices.md) — skill · 107500 installs
- [playwright-e2e-builder](https://affpapa.org/en/nevibecode/skills/playwright-e2e-builder.md) — skill · 271 installs
- [playwright-e2e-tester](https://affpapa.org/en/nevibecode/skills/playwright-e2e-tester.md) — skill · 200 installs
- [e2e-panther-playwright](https://affpapa.org/en/nevibecode/skills/e2e-panther-playwright.md) — skill · ★ 234 repo stars

From the same set: [przeprogramowani/ai-rules-builder](https://affpapa.org/en/nevibecode/by/przeprogramowani/ai-rules-builder.md) — 24 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
