Master end-to-end testing with Playwright

E2e testing patterns

by wshobson · MIT license · ★ 39,857 on GitHub · updated Sep 21

E2e testing patterns cover

Master end-to-end testing with Playwright and Cypress to build reliable test suites that catch bugs, improve confidence, and enable fast deployment. Use when implementing E2E tests, debugging flaky tests, or establishing testing standards.

---
name: e2e-testing-patterns
description: Master end-to-end testing with Playwright and Cypress to build reliable test suites that catch bugs, improve confidence, and enable fast deployment. Use when implementing E2E tests, debugging flaky tests, or establishing testing standards.
---

# E2E Testing Patterns

Build reliable, fast, and maintainable end-to-end test suites that provide confidence to ship code quickly and catch regressions before users do.

## When to Use This Skill

- Implementing end-to-end test automation
- Debugging flaky or unreliable tests
- Testing critical user workflows
- Setting up CI/CD test pipelines
- Testing across multiple browsers
- Validating accessibility requirements
- Testing responsive designs

Overview

Build reliable, fast, and maintainable end-to-end test suites that provide confidence to ship code quickly and catch regressions before users do.

Manual install (npx, ZIP)
Claude Codenpx skills add wshobson/agents --skill e2e-testing-patterns -g -a claude-code
Claude Code (manual)mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/wshobson/agents/tar.gz/4236bb91f839 \ | tar -xz -C ~/.claude/skills --strip-components=4 agents-4236bb91f839/plugins/developer-essentials/skills/e2e-testing-patterns
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/9de718e6e6616bb5041d/e2e-testing-patterns.zip" -OutFile "$env:TEMP\e2e-testing-patterns.zip"; Expand-Archive "$env:TEMP\e2e-testing-patterns.zip" -DestinationPath "$HOME\.claude\skills" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md3.9 KB
  • references/1 file · 10.0 KB
Read the files here
wshobson/4236bb92 files
SKILL.md
Show the full text128 lines

E2E Testing Patterns

Build reliable, fast, and maintainable end-to-end test suites that provide confidence to ship code quickly and catch regressions before users do.

When to Use This Skill

  • Implementing end-to-end test automation
  • Debugging flaky or unreliable tests
  • Testing critical user workflows
  • Setting up CI/CD test pipelines
  • Testing across multiple browsers
  • Validating accessibility requirements
  • Testing responsive designs
  • Establishing E2E testing standards

Core Concepts

1. E2E Testing Fundamentals

What to Test with E2E:

  • Critical user journeys (login, checkout, signup)
  • Complex interactions (drag-and-drop, multi-step forms)
  • Cross-browser compatibility
  • Real API integration
  • Authentication flows

What NOT to Test with E2E:

  • Unit-level logic (use unit tests)
  • API contracts (use integration tests)
  • Edge cases (too slow)
  • Internal implementation details
2. Test Philosophy

The Testing Pyramid:

        /\
       /E2E\         ← Few, focused on critical paths
      /─────\
     /Integr\        ← More, test component interactions
    /────────\
   /Unit Tests\      ← Many, fast, isolated
  /────────────\

Best Practices:

  • Test user behavior, not implementation
  • Keep tests independent
  • Make tests deterministic
  • Optimize for speed
  • Use data-testid, not CSS selectors

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Best Practices

  1. Use Data Attributes: data-testid or data-cy for stable selectors
  2. Avoid Brittle Selectors: Don't rely on CSS classes or DOM structure
  3. Test User Behavior: Click, type, see - not implementation details
  4. Keep Tests Independent: Each test should run in isolation
  5. Clean Up Test Data: Create and destroy test data in each test
  6. Use Page Objects: Encapsulate page logic
  7. Meaningful Assertions: Check actual user-visible behavior
  8. Optimize for Speed: Mock when possible, parallel execution
// ❌ Bad selectors
cy.get(".btn.btn-primary.submit-button").click();
cy.get("div > form > div:nth-child(2) > input").type("text");

// ✅ Good selectors
cy.getByRole("button", { name: "Submit" }).click();
cy.getByLabel("Email address").type("[email protected]");
cy.get('[data-testid="email-input"]').type("[email protected]");

Common Pitfalls

  • Flaky Tests: Use proper waits, not fixed timeouts
  • Slow Tests: Mock external APIs, use parallel execution
  • Over-Testing: Don't test every edge case with E2E
  • Coupled Tests: Tests should not depend on each other
  • Poor Selectors: Avoid CSS classes and nth-child
  • No Cleanup: Clean up test data after each test
  • Testing Implementation: Test user behavior, not internals

Debugging Failing Tests

// Playwright debugging
// 1. Run in headed mode
npx playwright test --headed

// 2. Run in debug mode
npx playwright test --debug

// 3. Use trace viewer
await page.screenshot({ path: 'screenshot.png' });
await page.video()?.saveAs('video.webm');

// 4. Add test.step for better reporting
test('checkout flow', async ({ page }) => {
    await test.step('Add item to cart', async () => {
        await page.goto('/products');
        await page.getByRole('button', { name: 'Add to Cart' }).click();
    });

    await test.step('Proceed to checkout', async () => {
        await page.goto('/cart');
        await page.getByRole('button', { name: 'Checkout' }).click();
    });
});

// 5. Inspect page state
await page.pause();  // Pauses execution, opens inspector
1---
2name: e2e-testing-patterns
3description: Master end-to-end testing with Playwright and Cypress to build reliable test suites that catch bugs, improve confidence, and enable fast deployment. Use when implementing E2E tests, debugging flaky tests, or establishing testing standards.
4---
5 
6# E2E Testing Patterns
7 
8Build reliable, fast, and maintainable end-to-end test suites that provide confidence to ship code quickly and catch regressions before users do.
9 
10## When to Use This Skill
11 
12- Implementing end-to-end test automation
13- Debugging flaky or unreliable tests
14- Testing critical user workflows
15- Setting up CI/CD test pipelines
16- Testing across multiple browsers
17- Validating accessibility requirements
18- Testing responsive designs
19- Establishing E2E testing standards
20 
21## Core Concepts
22 
23### 1. E2E Testing Fundamentals
24 
25**What to Test with E2E:**
26 
27- Critical user journeys (login, checkout, signup)
28- Complex interactions (drag-and-drop, multi-step forms)
29- Cross-browser compatibility
30- Real API integration
31- Authentication flows
32 
33**What NOT to Test with E2E:**
34 
35- Unit-level logic (use unit tests)
36- API contracts (use integration tests)
37- Edge cases (too slow)
38- Internal implementation details
39 
40### 2. Test Philosophy
41 
42**The Testing Pyramid:**
43 
44```
45 /\
46 /E2E\ ← Few, focused on critical paths
47 /─────\
48 /Integr\ ← More, test component interactions
49 /────────\
50 /Unit Tests\ ← Many, fast, isolated
51 /────────────\
52```
53 
54**Best Practices:**
55 
56- Test user behavior, not implementation
57- Keep tests independent
58- Make tests deterministic
59- Optimize for speed
60- Use data-testid, not CSS selectors
61 
62## Detailed patterns and worked examples
63 
64Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
65 
66## Best Practices
67 
681. **Use Data Attributes**: `data-testid` or `data-cy` for stable selectors
692. **Avoid Brittle Selectors**: Don't rely on CSS classes or DOM structure
703. **Test User Behavior**: Click, type, see - not implementation details
714. **Keep Tests Independent**: Each test should run in isolation
725. **Clean Up Test Data**: Create and destroy test data in each test
736. **Use Page Objects**: Encapsulate page logic
747. **Meaningful Assertions**: Check actual user-visible behavior
758. **Optimize for Speed**: Mock when possible, parallel execution
76 
77```typescript
78// ❌ Bad selectors
79cy.get(".btn.btn-primary.submit-button").click();
80cy.get("div > form > div:nth-child(2) > input").type("text");
81 
82// ✅ Good selectors
83cy.getByRole("button", { name: "Submit" }).click();
84cy.getByLabel("Email address").type("[email protected]");
85cy.get('[data-testid="email-input"]').type("[email protected]");
86```
87 
88## Common Pitfalls
89 
90- **Flaky Tests**: Use proper waits, not fixed timeouts
91- **Slow Tests**: Mock external APIs, use parallel execution
92- **Over-Testing**: Don't test every edge case with E2E
93- **Coupled Tests**: Tests should not depend on each other
94- **Poor Selectors**: Avoid CSS classes and nth-child
95- **No Cleanup**: Clean up test data after each test
96- **Testing Implementation**: Test user behavior, not internals
97 
98## Debugging Failing Tests
99 
100```typescript
101// Playwright debugging
102// 1. Run in headed mode
103npx playwright test --headed
104 
105// 2. Run in debug mode
106npx playwright test --debug
107 
108// 3. Use trace viewer
109await page.screenshot({ path: 'screenshot.png' });
110await page.video()?.saveAs('video.webm');
111 
112// 4. Add test.step for better reporting
113test('checkout flow', async ({ page }) => {
114 await test.step('Add item to cart', async () => {
115 await page.goto('/products');
116 await page.getByRole('button', { name: 'Add to Cart' }).click();
117 });
118 
119 await test.step('Proceed to checkout', async () => {
120 await page.goto('/cart');
121 await page.getByRole('button', { name: 'Checkout' }).click();
122 });
123});
124 
125// 5. Inspect page state
126await page.pause(); // Pauses execution, opens inspector
127```
128 
View all files on GitHub →

Details

Updated
Sep 21, 2026
License
MIT
Stars on the repo
★ 39,857
Checked
Source
wshobson/agents ↗
Creator
wshobson · 179 listings
View creator

Similar skills

See all →
Skill29 production-ready scripts for iOS app testing, buildingIos simulator skillconorluddy/ios-simulator-skill · by conorluddy29 production-ready scripts for iOS app testing, building, and automation. Provides semantic UI navigation, build automation, accessibility testing, and simulator lifecycle management. Optimized for AI agents with minimal token output.★ 1.3k GitHub starsSkillMoAI unified orchestrator for autonomous developmentmodu-ai/moai-adk · by modu-aiMoAI unified orchestrator for autonomous development. Routes natural language or subcommands (plan, run, sync, project, fix, loop, mx, feedback, review, clean, codemaps, gate, e2e, harness, goal, gtd, todo) to specialized agents.★ 1.2k GitHub starsSkillWrite Android unit, Compose UI, and Hilt-integrated testsAndroid Testing StandardsHoangNguyen0403/agent-skills-standard · by HoangNguyen0403Write Android unit, Compose UI, and Hilt-integrated tests. Use when designing test behavior with MockK or coroutine test utilities; defer database/WorkManager-specific recipes to the owning feature skill.★ 569 GitHub starsSkillImplementing any feature or bugfixTest-Driven Development (TDD)obra/superpowers · by obraUse when implementing any feature or bugfix, before writing implementation code★ 290k GitHub starsSkillToolkit for interacting with and testing local webWebapp testinganthropics/skills · by anthropicsToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.★ 178k GitHub starsPromptGuide to fixing bugs using a test-first approachTest first bug fixing approachf/prompts.chat · by Ilker UlusoyGuide to fixing bugs using a test-first approach, ensuring code reliability through systematic testing and implementation.New listing

More from wshobson

SkillMaster C/.NET backend development patterns for buildingwshobson/agents · by wshobsonMaster C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.★ 39.9k GitHub starsSkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliancewshobson/agents · by wshobsonImplement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.★ 39.9k GitHub starsSkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Designwshobson/agents · by wshobsonMaster Material Design 3 and Jetpack Compose patterns for building native Android apps. Use when designing Android interfaces, implementing Compose UI, or following Google's Material Design guidelines.★ 39.9k GitHub starsSkillMigrate from AngularJS to Angular using hybrid modeAngular migrationwshobson/agents · by wshobsonMigrate from AngularJS to Angular using hybrid mode, incremental component rewriting, and dependency injection updates. Use when upgrading AngularJS applications, planning framework migrations, or modernizing legacy Angular code.★ 39.9k GitHub starsSkillUnderstand anti-reversing, obfuscationAnti reversing techniqueswshobson/agents · by wshobsonUnderstand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.★ 39.9k GitHub starsSkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patternswshobson/agents · by wshobsonBuild production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.★ 39.9k GitHub stars