playwright-test-patterns-guide

playwright-test-patterns-guide is a cursor rule for Cursor from verdexhq/verdex-mcp. It costs 115 tokens per session (8,232 once invoked), scanned A, original, Apache-2.0.

A guide to writing Playwright end-to-end tests, which check a complete user flow in a browser. It covers test structure, assertions, navigation, login, test data, and reusable page objects.

In plain words
What is it for?
Turning workflow descriptions into Playwright tests, organizing test suites, checking browser behavior, and managing authentication, navigation, fixtures, and test state.
Why use it?
It helps avoid flaky tests, hidden failures, duplicated setup, and selectors or credentials that break easily.

Cursor rule for Cursor

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.

agentmods
npx agentmods add rules/verdexhq/verdex-mcp/playwright-test-patterns-guide
Clone the repo
git clone --depth 1 https://github.com/verdexhq/verdex-mcp

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 playwright-test-patterns-guide

README.md
[![agentmods](https://agentmods.dev/badge/rules/verdexhq/verdex-mcp/playwright-test-patterns-guide.svg)](https://agentmods.dev/rules/verdexhq/verdex-mcp/playwright-test-patterns-guide)
Your own site
<a href="https://agentmods.dev/rules/verdexhq/verdex-mcp/playwright-test-patterns-guide"><img src="https://agentmods.dev/badge/rules/verdexhq/verdex-mcp/playwright-test-patterns-guide.svg" alt="Measured on agentmods" height="20"></a>
Per session 115 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 8,232 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00115 $0.08232
Opus 5 $0.00057 $0.04116
Sonnet 5 $0.00023 $0.01646
Haiku 4.5 $0.00012 $0.00823

Measured 4d ago against content hash e01e99dbb1fb, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

playwright-test-patterns-guide 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 4d 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.

.cursor/rules/playwright-test-patterns-guide.mdc · 1,320 lines

How it starts

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

Idiomatic Playwright Test Patterns

A comprehensive guide for writing clean, maintainable, and production-ready Playwright E2E tests.


Table of Contents

  1. Core Principles
  2. Test File Structure
  3. Assertion Patterns
  4. Navigation and Waiting
  5. Authentication Strategies
  6. Test Organization
  7. Page Object Models
  8. Test Data Management
  9. Error Handling
  10. Common Patterns Library
  11. Anti-Patterns to Avoid
  12. Complete Examples

Core Principles

✅ Idiomatic Playwright Testing

  1. Auto-waiting is your friend - Trust Playwright's built-in waiting
  2. Explicit is better than implicit - Make intentions clear
  3. Arrange-Act-Assert - Clear test structure
  4. Independent tests - Each test can run alone
  5. Descriptive names - Tests are documentation
  6. Minimal setup - Only what's necessary
  7. Stable selectors - Role-first, semantic locators

❌ Never Do These

  • ❌ Manual waits (page.waitForTimeout(5000)) except for debugging
  • ❌ Broad try/catch blocks that hide failures
  • ❌ Tests that depend on other tests
  • ❌ Hard-coded URLs and credentials in test files
  • ❌ Generic test names like "test 1" or "works correctly"
  • ❌ Unnecessary waitForSelector (built into locators)

Test File Structure

Basic Test File Template

import { test, expect } from '@playwright/test';

test.describe('Feature Name', () => {
  test.beforeEach(async ({ page }) => {
    // Setup before each test
    await page.goto('/starting-point');
  });

  test('should do specific thing', async ({ page }) => {
    // Arrange: Set up test data/state
    
    // Act: Perform user actions
    
    // Assert: Verify expected outcomes
  });

  test('should handle error case', async ({ page }) => {
    // Test error scenarios
  });
});

Read the full file on GitHub · 1,320 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. 4d ago First seen · 1,320 lines · 115 tokens per session scan A e01e99dbb1fb

Subscribe to this mod's changes

playwright-test-patterns-guide is a cursor rule published in the GitHub repository verdexhq/verdex-mcp (17 stars, last pushed 8mo ago), licensed Apache-2.0. It adds 115 tokens to every session and 8,232 once invoked, about $0.0006 per session on Opus 5. 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.