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
.cursor/rules/playwright-e2e-testing.mdcWhat 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.tsfor Chromium only with parallel test execution
How to install playwright-e2e-testing
Manually: put the files in place
.cursor/rules/playwright-e2e-testing.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/playwright-e2e-testing.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/playwright-e2e-testing.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/playwright-e2e-testing.mdManually: put the files in place
.clinerules/playwright-e2e-testing.mdStep 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.