E2e Testing Patterns
Seth HobsonCommunityCreated by Seth Hobson
- Skill
- Guidelines
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a comprehensive framework for implementing end-to-end (E2E) testing. It emphasizes a testing philosophy centered on user behavior rather than implementation details, helping teams build robust suites that catch regressions while maintaining speed. The content covers core concepts like the testing pyramid, best practices for selector strategies, and advanced patterns such as the Page Object Model and test fixtures. It also includes practical guidance on debugging flaky tests and optimizing performance in CI/CD pipelines.
What it does
- Defines best practices for writing deterministic and independent E2E tests.
- Provides patterns for structuring test code using the Page Object Model.
- Offers strategies for managing test data through fixtures.
- Outlines debugging techniques for Playwright and Cypress.
- Establishes criteria for what should and should not be covered by E2E tests.
- Explains how to optimize test suites for speed and reliability.
When to use it
- When implementing a new E2E testing strategy from scratch.
- When debugging flaky or unreliable tests in existing suites.
- When establishing team-wide standards for test automation.
- When setting up or improving CI/CD test pipelines.
- When needing to test complex, multi-step user workflows.
Advantages
- Reduces test flakiness by promoting deterministic practices.
- Improves test maintainability through modular patterns like Page Objects.
- Increases developer confidence by focusing on critical user journeys.
- Optimizes execution time by providing guidance on mocking and parallelization.
- Encourages cleaner test code by discouraging reliance on brittle CSS selectors.
Usage examples
- “How should I structure my Playwright tests to avoid code duplication?”
- The skill recommends using the Page Object Model to encapsulate page logic and selectors, allowing you to reuse methods across multiple test files.
- “What is the best way to handle test data in my Cypress suite?”
- It suggests using fixtures to manage test data, ensuring that data is created before a test and cleaned up afterward to maintain test isolation.
- “My E2E tests are failing randomly, how do I fix them?”
- The skill advises avoiding fixed timeouts, using proper waiting strategies, and utilizing debugging tools like headed mode or trace viewers to identify the root cause.
- “Should I test every single edge case with E2E tests?”
- No, the skill suggests following the testing pyramid, focusing E2E tests on critical user paths and using unit or integration tests for edge cases and internal logic.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/wshobson/e2e-testing-patterns/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip e2e-testing-patterns.zip -d .agents/skills
Documentation by Seth Hobson
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 selectorsAvoid 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 (findBy* commands come from @testing-library/cypress;
// add `import "@testing-library/cypress/add-commands";` to your Cypress support file)
cy.findByRole("button", { name: "Submit" }).click();
cy.findByLabelText("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 (record with `use: { trace: 'on-first-retry' }` in the config)
npx playwright show-trace path/to/trace.zip
await page.screenshot({ path: 'screenshot.png' });
// 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 inspectorFiles
- ATTRIBUTION.mdAdded by AutoGineer1000 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md4.1 KiB
- references/details.md10.1 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Node.js
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Seth Hobson
- Publisher
- Seth Hobson (Community)
- Source
- wshobson/agents · plugins/developer-essentials/skills/e2e-testing-patterns · commit 4bde316
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Seth Hobson or Seth Hobson.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download e2e-testing-patterns.zip