Master end-to-end testing with Playwright
E2e testing patterns

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)
npx skills add wshobson/agents --skill e2e-testing-patterns -g -a claude-codemkdir -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-patternsNew-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" -ForceConnects with Agent Alley MCP · agentalley.io/mcp
Files included
SKILL.md3.9 KBreferences/1 file · 10.0 KB
Read the files here
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
- Use Data Attributes:
data-testidordata-cyfor stable selectors - Avoid Brittle Selectors: Don't rely on CSS classes or DOM structure
- Test User Behavior: Click, type, see - not implementation details
- Keep Tests Independent: Each test should run in isolation
- Clean Up Test Data: Create and destroy test data in each test
- Use Page Objects: Encapsulate page logic
- Meaningful Assertions: Check actual user-visible behavior
- 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 | |
| 2 | name e2e-testing-patterns |
| 3 | 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. |
| 4 | |
| 5 | |
| 6 | # E2E Testing Patterns |
| 7 | |
| 8 | Build 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 | |
| 64 | Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient. |
| 65 | |
| 66 | ## Best Practices |
| 67 | |
| 68 | **Use Data Attributes**: `data-testid` or `data-cy` for stable selectors |
| 69 | **Avoid Brittle Selectors**: Don't rely on CSS classes or DOM structure |
| 70 | **Test User Behavior**: Click, type, see - not implementation details |
| 71 | **Keep Tests Independent**: Each test should run in isolation |
| 72 | **Clean Up Test Data**: Create and destroy test data in each test |
| 73 | **Use Page Objects**: Encapsulate page logic |
| 74 | **Meaningful Assertions**: Check actual user-visible behavior |
| 75 | **Optimize for Speed**: Mock when possible, parallel execution |
| 76 | |
| 77 | |
| 78 | // ❌ Bad selectors |
| 79 | cy.get(".btn.btn-primary.submit-button").click(); |
| 80 | cy.get("div > form > div:nth-child(2) > input").type("text"); |
| 81 | |
| 82 | // ✅ Good selectors |
| 83 | cy.getByRole("button", { name: "Submit" }).click(); |
| 84 | cy.getByLabel("Email address").type("[email protected]"); |
| 85 | cy.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 | |
| 101 | // Playwright debugging |
| 102 | // 1. Run in headed mode |
| 103 | npx playwright test --headed |
| 104 | |
| 105 | // 2. Run in debug mode |
| 106 | npx playwright test --debug |
| 107 | |
| 108 | // 3. Use trace viewer |
| 109 | await page.screenshot({ path: 'screenshot.png' }); |
| 110 | await page.video()?.saveAs('video.webm'); |
| 111 | |
| 112 | // 4. Add test.step for better reporting |
| 113 | test('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 |
| 126 | await page.pause(); // Pauses execution, opens inspector |
| 127 | |
| 128 |
Details
- Updated
- Sep 21, 2026
- License
- MIT
- Stars on the repo
- ★ 39,857
- Checked
- Source
- wshobson/agents ↗
- Creator
- wshobson · 179 listings
Similar skills
See all →
Skill29 production-ready scripts for iOS app testing, buildingIos simulator skill
SkillMoAI unified orchestrator for autonomous development
SkillWrite Android unit, Compose UI, and Hilt-integrated testsAndroid Testing Standards
SkillImplementing any feature or bugfixTest-Driven Development (TDD)
SkillToolkit for interacting with and testing local webWebapp testing
PromptGuide to fixing bugs using a test-first approachTest first bug fixing approachMore from wshobson
SkillMaster C/.NET backend development patterns for building
SkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliance
SkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Design
SkillMigrate from AngularJS to Angular using hybrid modeAngular migration
SkillUnderstand anti-reversing, obfuscationAnti reversing techniques
SkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patterns