Write End-to-End Tests
Workflow for writing browser-based end-to-end tests
CLAUDE.md
When writing end-to-end tests:
- Identify the user flow to test. Focus on critical paths: signup, login, core feature, checkout.
- Write the test as the user would experience it: navigate, fill in forms, click buttons, verify results.
- Use stable selectors: data-testid attributes, ARIA roles, or semantic element queries — not CSS classes or XPaths.
- Add wait conditions for async operations — don’t use fixed sleep timers.
- Assert on visible outcomes: text on the page, navigation to a URL, presence of elements.
- Test one complete flow per test. Don’t chain unrelated flows.
- Run the test against a clean state. Seed required data before the test, clean up after.
Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.