best-practices-for-writing-playwright-e2e-testing

best-practices-for-writing-playwright-e2e-testing is a cursor rule for Cursor from fumito-ito/mdcvalult. It costs 0 tokens per session (1,010 once invoked), scanned A, original, MIT.

A set of standards for Playwright, a tool that tests websites in a real browser. It focuses on end-to-end tests, which check complete user journeys, including project setup, test organization, retries, reports, screenshots, and videos.

In plain words
What is it for?
Use it to organize and configure Playwright tests for pages, authentication, APIs, and components. It helps start the development server, run tests in Chromium, retry failures, and produce reports and failure recordings.
Why use it?
It gives the team a consistent structure for browser tests and useful evidence when a test fails. This reduces differences between local testing and testing in continuous integration systems.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it to organize and configure Playwright tests for pages, authentication, APIs, and components. It helps start the development server, run tests in Chromium, retry failures, and produce reports and failure recordings.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/fumito-ito/mdcvalult/best-practices-for-writing-playwright-e2e-testing
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/fumito-ito/mdcvalult

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for best-practices-for-writing-playwright-e2e-testing

README.md
[![agentmods](https://agentmods.dev/badge/rules/fumito-ito/mdcvalult/best-practices-for-writing-playwright-e2e-testing/github.svg)](https://agentmods.dev/rules/fumito-ito/mdcvalult/best-practices-for-writing-playwright-e2e-testing)
Your own site
<a href="https://agentmods.dev/rules/fumito-ito/mdcvalult/best-practices-for-writing-playwright-e2e-testing"><img src="https://agentmods.dev/badge/rules/fumito-ito/mdcvalult/best-practices-for-writing-playwright-e2e-testing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for best-practices-for-writing-playwright-e2e-testing

Your own site · 80×15
<a href="https://agentmods.dev/rules/fumito-ito/mdcvalult/best-practices-for-writing-playwright-e2e-testing"><img src="https://agentmods.dev/badge/rules/fumito-ito/mdcvalult/best-practices-for-writing-playwright-e2e-testing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,010 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01010
Opus 5 $0.00000 $0.00505
Sonnet 5 $0.00000 $0.00202
Haiku 4.5 $0.00000 $0.00101

Measured 9d ago against content hash 8ff62199a224, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

best-practices-for-writing-playwright-e2e-testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

mdc/best-practices-for-writing-playwright-e2e-testing.mdc · 220 lines

How it starts

The opening of the file, as written. The whole thing — 220 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Playwright Testing Standards

Configuration

Base Setup

requirements:
  version: "^1.50.1"
  dependencies:
    - "@playwright/test"
  files:
    - playwright.config.ts: Test configuration
    - tests/e2e/: Test files

Project Configuration

// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  testDir: './tests/e2e',
  fullyParallel: false,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,
  
  reporter: [
    ['html'],
    ['list'],
    ['json', { outputFile: 'test-results/test-results.json' }]
  ],
  
  use: {
    baseURL: 'http://localhost:3000',
    trace: 'on-first-retry',
    video: 'on-first-retry',
    screenshot: 'only-on-failure',
  },
  
  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },
  ],
  
  webServer: {
    command: 'npm run dev',
    url: 'http://localhost:3000',
    reuseExistingServer: !process.env.CI,
  },
});

Test Structure

Test Organization

directory_structure:
  tests/e2e:
    - auth/: Authentication tests
    - pages/: Page tests
    - api/: API tests
    - components/: Component tests
    - utils/: Test utilities

Test File Pattern

// tests/e2e/auth/login.spec.ts
import { test, expect } from '@playwright/test';

test.describe('Login Flow', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/login');
  });

  test('successful login', async ({ page }) => {
    // Test implementation
  });

  test('invalid credentials', async ({ page }) => {
    // Test implementation
  });
});

Testing Standards

Page Object Pattern

// tests/e2e/pages/login.page.ts
export class LoginPage {
  constructor(private page: Page) {}

  async goto() {
    await this.page.goto('/login');
  }

  async login(email: string, password: string) {
    await this.page.fill('[name=email]', email);
    await this.page.fill('[name=password]', password);
    await this.page.click('button[type=submit]');
  }

  async getErrorMessage() {
    return this.page.textContent('.error-message');
  }
}

Read the full file on GitHub · 220 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 220 lines · 0 tokens per session scan A 8ff62199a224

Subscribe to this mod's changes

best-practices-for-writing-playwright-e2e-testing is a cursor rule published in the GitHub repository fumito-ito/mdcvalult (33 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,010 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.