E2E Test Generator
Generate end-to-end tests covering full user workflows.
Workflow
Detect the E2E framework:
- Check for existing config:
playwright.config.*, cypress.config.*, wdio.conf.*.
- Check
package.json for Playwright, Cypress, Selenium, Puppeteer, or similar.
- For API-only: check for Supertest, httpx, REST-assured.
- If none exists, recommend Playwright (most versatile) and help set it up.
Identify the user flow to test:
- Ask the user or infer from the feature being discussed.
- Map out the steps: navigation, input, actions, expected outcomes.
- Identify preconditions (auth state, seed data, feature flags).
Generate the test:
For Browser E2E (Playwright/Cypress)
- Navigate to the page.
- Interact with elements using accessible selectors (role, label, text).
- Assert on visible outcomes (text content, URL, element state).
- Handle async loading (wait for network idle, element visibility).
For API E2E
- Set up auth headers/tokens.
- Make requests in the order a real client would.
- Assert on status codes, response bodies, and side effects.
- Clean up test data.
Add robustness:
- Use data-testid or accessible selectors, not brittle CSS selectors.
- Add proper waits instead of fixed timeouts.
- Handle flakiness: retry logic, deterministic test data.
- Set up and tear down test state.
Run the test to verify it passes.
Test Structure
describe('User flow: <flow name>')
before: Set up preconditions (login, seed data)
test: Step-by-step user actions with assertions
after: Clean up (delete test data, logout)
Guidelines
- E2E tests should mirror real user behavior — interact via the UI, not internal APIs.
- Keep E2E tests focused on critical paths (login, checkout, core CRUD).
- Use accessible selectors:
getByRole, getByLabel, getByText over CSS.
- Isolate test data — don't depend on shared mutable state.
- E2E tests are slow; keep the suite lean. Test edge cases in unit tests.
- For flaky tests, add retry annotations rather than arbitrary sleeps.
- Include visual regression snapshots for UI-critical flows if the framework supports it.
1---2name: e2e3description: Generate end-to-end tests for applications. Use when the user says /e2e, asks for end-to-end tests, integration tests, browser tests, API tests, or wants to test a full user workflow. Triggers: e2e, end-to-end, integration test, browser test, playwright, cypress, selenium, API test, smoke test, user flow.4---56# E2E Test Generator78Generate end-to-end tests covering full user workflows.910## Workflow11121. **Detect the E2E framework:**13 - Check for existing config: `playwright.config.*`, `cypress.config.*`, `wdio.conf.*`.14 - Check `package.json` for Playwright, Cypress, Selenium, Puppeteer, or similar.15 - For API-only: check for Supertest, httpx, REST-assured.16 - If none exists, recommend Playwright (most versatile) and help set it up.17182. **Identify the user flow to test:**19 - Ask the user or infer from the feature being discussed.20 - Map out the steps: navigation, input, actions, expected outcomes.21 - Identify preconditions (auth state, seed data, feature flags).22233. **Generate the test:**2425### For Browser E2E (Playwright/Cypress)2627```28- Navigate to the page.29- Interact with elements using accessible selectors (role, label, text).30- Assert on visible outcomes (text content, URL, element state).31- Handle async loading (wait for network idle, element visibility).32```3334### For API E2E3536```37- Set up auth headers/tokens.38- Make requests in the order a real client would.39- Assert on status codes, response bodies, and side effects.40- Clean up test data.41```42434. **Add robustness:**44 - Use data-testid or accessible selectors, not brittle CSS selectors.45 - Add proper waits instead of fixed timeouts.46 - Handle flakiness: retry logic, deterministic test data.47 - Set up and tear down test state.48495. **Run the test** to verify it passes.5051## Test Structure5253```54describe('User flow: <flow name>')55 before: Set up preconditions (login, seed data)56 test: Step-by-step user actions with assertions57 after: Clean up (delete test data, logout)58```5960## Guidelines6162- E2E tests should mirror real user behavior — interact via the UI, not internal APIs.63- Keep E2E tests focused on critical paths (login, checkout, core CRUD).64- Use accessible selectors: `getByRole`, `getByLabel`, `getByText` over CSS.65- Isolate test data — don't depend on shared mutable state.66- E2E tests are slow; keep the suite lean. Test edge cases in unit tests.67- For flaky tests, add retry annotations rather than arbitrary sleeps.68- Include visual regression snapshots for UI-critical flows if the framework supports it.