Skip to main content
rule CX Codex

playwright-e2e-testing — Claude Code rule for Playwright E2E tests

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

AGPL-3.0 ★ 267 updated 2026-02-20

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/playwright-e2e-testing.mdc
Open on GitHub

What playwright-e2e-testing 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.

What it helps with

  • 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 for the agent

  • 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

How to install playwright-e2e-testing

Manually: put the files in place

.cursor/rules/playwright-e2e-testing.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about playwright-e2e-testing

How do I install playwright-e2e-testing in Claude Code?

Place the rule file at .claude/rules/playwright-e2e-testing.md in your project root. Claude Code will pick it up and apply it when you reference it in an E2E testing task.

What does the playwright-e2e-testing rule do?

It tells the agent to generate Playwright tests with Chromium/Desktop Chrome only, Page Object Model in ./e2e/page-objects, locator-based element selection, Arrange-Act-Assert structure, and parallel execution.

Does this rule apply to every Claude Code prompt automatically?

No. The rule has alwaysApply: false, so it only takes effect when explicitly included in the task or session context.

Similar IDE rules

All IDE rules for Testing and QA →

From the same set24

The whole set →
shadcn-init The shadcn-init command sets up shadcn/ui in a project and adds a defined set of components. Use it when you want the UI files placed in the expected directory with the new-york theme. CX Codex +1 ★ 267repo stars shadcn-status-checkpoint shadcn-status-checkpoint — a command that documents implementation progress for UI components in a structured markdown file. Keeps your work history clear when developing complex views across multiple AI conversations. CX Codex +1 ★ 267repo stars astro Guidelines for Claude Code to generate server-side pages and endpoints in Astro. Ensures type safety, middleware handling, and request validation. CX Codex +1 ★ 267repo stars react-development react-development sets coding standards for React components inside an Astro app: hooks over classes, memoization, Tailwind-driven responsiveness. CX Codex +1 ★ 267repo stars github-action Guides Claude Code in generating GitHub Actions workflows with scoped secrets, composite steps, and upstream version checks. CX Codex +1 ★ 267repo stars shadcn-resume-implementation shadcn-resume-implementation is a Claude Code command that resumes frontend work from a saved status. It uses the implementation plan, frontend rules, and type definitions. CX Codex +1 ★ 267repo stars shadcn-plan-summary shadcn-plan-summary — a command that captures decisions from UI architecture sessions. Extracts choices about layout, flows, API integration, and state management, then compiles them into a structured report for the next development phase. CX Codex +1 ★ 267repo stars test-plan test-plan is a Claude Code rule that builds a project-specific test plan from the codebase and tech stack. It writes the result in Polish as Markdown. CX Codex +1 ★ 267repo stars

Project sponsors

Companies that keep this analytics open