E2e Setup Action
Comprehensive command designed for configure, comprehensive, testing, suite. Includes structured workflows, validation checks, and reusable patterns for testing.
E2e Setup Action
E2e Setup Action is a command that configures a complete end-to-end testing environment for your application, covering framework selection, project scaffolding, page object model creation, test data management, and CI/CD integration. End-to-end tests validate your application from the user's perspective by driving a real browser through actual workflows, catching integration issues that unit and integration tests cannot detect. This command handles the substantial boilerplate involved in getting an E2E suite running reliably.
When to Use This Command
Run this command when...
- You are starting a new web application project and want to establish E2E testing infrastructure from the beginning rather than retrofitting it later.
- Your application has grown beyond what unit and integration tests can adequately cover, and user-facing workflows need automated validation.
- You are migrating from one E2E framework to another (e.g., from Cypress to Playwright) and need a structured setup for the new framework.
- Your team needs cross-browser testing capabilities and you want the framework configured to run tests against Chrome, Firefox, and Safari in CI.
- Critical user flows like checkout, authentication, and onboarding have broken in production despite passing unit tests, indicating a gap in end-to-end coverage.
Consider alternatives when...
- Your application is an API-only service with no browser-based interface; API integration tests are more appropriate.
- You need to test a single page or component in isolation; component testing tools like Storybook or Testing Library are better suited.
- Your team lacks the bandwidth to maintain E2E tests, which require more upkeep than other test types due to their dependency on UI structure.
Quick Start
# e2e.config.yml framework: playwright # playwright | cypress | webdriver browsers: [chromium, firefox] base_url: http://localhost:3000 page_objects: true test_data: strategy: fixtures # fixtures | seeding | api cleanup: after_each ci: provider: github-actions parallel: 3 retries: 2
Example invocation:
e2e-setup-action "playwright with github-actions for react app"
Example output:
E2E Testing Setup Complete
---------------------------
Framework: Playwright v1.44
Browsers: Chromium, Firefox, WebKit
Base URL: http://localhost:3000 (auto-detected from package.json)
App Framework: React (detected)
Project Structure Created:
e2e/
fixtures/ - Test data and shared state
pages/ - Page object models
login.page.ts
dashboard.page.ts
navigation.ts
tests/
auth.spec.ts - Login/logout/signup flows
navigation.spec.ts
playwright.config.ts
.github/workflows/
e2e-tests.yml - Parallel CI pipeline (3 shards)
Page Objects Generated:
LoginPage - email, password, submit, errorMessage selectors
DashboardPage - navigation, userMenu, contentArea selectors
Run locally: npx playwright test
Run with UI: npx playwright test --ui
Core Concepts
| Concept | Purpose | Details |
|---|---|---|
| Page Object Model | Encapsulates page structure for maintainability | A class representing a page or component that exposes user-facing actions (login, search) rather than raw selectors, reducing test brittleness |
| Test Fixture | Provides reusable test state and data | Predefined data sets and browser contexts that tests can consume, ensuring consistent starting conditions without manual setup |
| Browser Context | Isolates tests from each other | A separate browser session with its own cookies, storage, and cache, preventing one test's state from leaking into another |
| Test Sharding | Distributes tests across parallel runners | Splits the test suite into groups that run simultaneously on separate CI machines, reducing total pipeline duration |
| Auto-waiting | Handles asynchronous UI automatically | The framework waits for elements to be visible, enabled, and stable before interacting, eliminating explicit sleep statements |
E2E Setup Action Architecture
+----------------------------------------------------------+
| APPLICATION UNDER TEST |
| [Dev Server] <--> [Database] <--> [External Services] |
+----------------------------------------------------------+
^
| HTTP / WebSocket
v
+----------------------------------------------------------+
| BROWSER AUTOMATION LAYER |
| [Playwright/Cypress Driver] --> [Browser Instances] |
| Chromium | Firefox | WebKit |
+----------------------------------------------------------+
^
|
v
+----------------------------------------------------------+
| TEST LAYER |
| [Page Objects] --> [Test Specs] --> [Assertions] |
| fixtures/ --> test data | cleanup | state management |
+----------------------------------------------------------+
|
v
+----------------------------------------------------------+
| CI/CD PIPELINE |
| [Shard 1] [Shard 2] [Shard 3] --> Merge Reports |
+----------------------------------------------------------+
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
framework | string | playwright | E2E testing framework to install and configure: playwright, cypress, or webdriver |
browsers | array | [chromium] | List of browsers to test against; options include chromium, firefox, webkit, and msedge |
base_url | string | auto-detect | The application URL that tests navigate to; auto-detected from dev server configuration if not specified |
parallel | integer | 1 | Number of parallel shards to use when running tests in CI, reducing total execution time |
retries | integer | 0 | Number of times to retry a failing test before marking it as failed; helps manage flaky tests |
Best Practices
-
Use data-testid attributes for element selection. CSS classes change when designers update styles. Text content changes when copywriters revise wording. IDs change when developers refactor. The
data-testidattribute is the only selector that exists purely for testing and has no other reason to change. Establish a team convention to add these attributes to all interactive elements from the start rather than retrofitting them later. -
Keep tests focused on user-visible behavior, not implementation details. An E2E test should describe what a user does and what they see, not how the application achieves it internally. Test that clicking "Submit" shows a success message, not that a specific API endpoint was called with specific parameters. This insulates tests from refactoring and keeps them stable as the architecture evolves.
-
Implement test data isolation to prevent inter-test contamination. Each test should create its own data, operate on it, and clean up afterward. Never rely on data left behind by a previous test. Use API calls or database seeding in beforeEach hooks to establish test state, and ensure cleanup runs even when tests fail. Shared mutable state is the primary cause of flaky E2E suites.
-
Configure retries judiciously but investigate repeated failures. Retries are a pragmatic tool for handling genuine environmental flakiness like network timeouts or race conditions. However, a test that consistently needs retries to pass has an underlying issue. Track retry rates per test and prioritize fixing tests that retry more than 10% of the time rather than relying on retries as a permanent crutch.
-
Run E2E tests against a production-like environment. Testing against a development server with mocked external services catches fewer bugs than testing against a staging environment with real (or realistic) backends. Configure the E2E pipeline to deploy to a staging environment before running tests. This catches deployment configuration issues, environment variable problems, and service integration bugs that only manifest in production-like conditions.
Common Issues
Tests pass locally but fail in CI due to timing issues. Local machines are typically faster than CI containers, and elements that appear instantly locally may take longer in CI. Ensure you are using the framework's built-in auto-waiting rather than explicit timeouts. If specific elements are slow, add explicit wait conditions like waitForSelector or waitForResponse targeting the specific asynchronous operation rather than adding arbitrary sleep durations.
Page object selectors break frequently after UI changes. This indicates that selectors are tied to implementation details like CSS class names or DOM hierarchy. Migrate selectors to use data-testid attributes, which are stable across redesigns. Also consolidate selectors in page object files so that when a selector does change, you update it in exactly one place rather than across dozens of test files.
E2E test suite takes too long to run in CI. As the test count grows, serial execution becomes impractical. Enable test sharding to distribute tests across parallel CI runners. Also evaluate whether every test genuinely needs to exercise the full stack or whether some could be converted to faster API-level integration tests. A well-balanced testing pyramid keeps the E2E layer thin and focused on critical user journeys only.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Git Commit Message Generator
Generates well-structured conventional commit messages by analyzing staged changes. Follows Conventional Commits spec with scope detection.
React Component Scaffolder
Scaffolds a complete React component with TypeScript types, Tailwind styles, Storybook stories, and unit tests. Follows project conventions automatically.
CI/CD Pipeline Generator
Generates GitHub Actions workflows for CI/CD including linting, testing, building, and deploying. Detects project stack automatically.