Testing Web Applications End to End
Core principle
Use end-to-end tests to prove a small set of critical user journeys through the assembled product. Interact with the application as a user would and inspect browser evidence when the journey fails.
Journey workflow
- Define the user goal, starting state, and completion condition before writing selectors or actions.
- Keep the journey focused. Cover the minimum sequence of features that must work together to achieve the goal.
- Start from controlled state: deterministic data, explicit authentication state, known feature flags, and an isolated browser context.
- Navigate and interact through user-facing contracts such as roles, labels, text, URLs, and visible state. Avoid selectors coupled to styling or implementation internals.
- Assert meaningful outcomes rather than every intermediate DOM mutation.
- When a failure occurs, inspect the browser before patching code: visible UI, URL, console errors, failed requests, response status/body, storage/state, and screenshots when visual evidence matters.
- Test negative or recovery paths only when they are critical to the journey: rejected auth, validation, failed request, retry, expired state, or interrupted navigation.
- Keep tests independent. No journey should require another test to have run first.
Browser evidence
Capture the evidence needed to distinguish product defects from test defects:
- the final visible state and URL;
- console exceptions;
- relevant request/response failures;
- screenshot or trace for visual/timing failures;
- exact reproduction steps and test data.
A screenshot alone is not root-cause evidence when console, network, or state explains the failure.
Scope discipline
Do not move every edge case into the browser. If a failure can be proven at a narrower layer with equal confidence, test it there and keep only enough end-to-end coverage to prove the assembled journey.
Do not make Playwright, Cypress, or another runner part of the method itself. Use the browser tooling available in the environment; when Playwright is available, prefer its user-facing locators, isolation model, traces, console/network inspection, and auto-waiting rather than arbitrary sleeps.
Verification
A good E2E suite answers two questions quickly: “Can users complete the critical journey?” and, when not, “What observable browser evidence narrows the failure?” If it cannot do both, reduce scope or improve observability.
References
1---2name: testing-web-applications-end-to-end3description: Use when a web application's assembled browser experience, critical user journeys, routing, forms, authentication, client state, or network behavior must be verified beyond component and integration tests.4---56# Testing Web Applications End to End78## Core principle9Use end-to-end tests to prove a small set of critical user journeys through the assembled product. Interact with the application as a user would and inspect browser evidence when the journey fails.1011## Journey workflow121. Define the user goal, starting state, and completion condition before writing selectors or actions.132. Keep the journey focused. Cover the minimum sequence of features that must work together to achieve the goal.143. Start from controlled state: deterministic data, explicit authentication state, known feature flags, and an isolated browser context.154. Navigate and interact through user-facing contracts such as roles, labels, text, URLs, and visible state. Avoid selectors coupled to styling or implementation internals.165. Assert meaningful outcomes rather than every intermediate DOM mutation.176. When a failure occurs, inspect the browser before patching code: visible UI, URL, console errors, failed requests, response status/body, storage/state, and screenshots when visual evidence matters.187. Test negative or recovery paths only when they are critical to the journey: rejected auth, validation, failed request, retry, expired state, or interrupted navigation.198. Keep tests independent. No journey should require another test to have run first.2021## Browser evidence22Capture the evidence needed to distinguish product defects from test defects:23- the final visible state and URL;24- console exceptions;25- relevant request/response failures;26- screenshot or trace for visual/timing failures;27- exact reproduction steps and test data.2829A screenshot alone is not root-cause evidence when console, network, or state explains the failure.3031## Scope discipline32Do not move every edge case into the browser. If a failure can be proven at a narrower layer with equal confidence, test it there and keep only enough end-to-end coverage to prove the assembled journey.3334Do not make Playwright, Cypress, or another runner part of the method itself. Use the browser tooling available in the environment; when Playwright is available, prefer its user-facing locators, isolation model, traces, console/network inspection, and auto-waiting rather than arbitrary sleeps.3536## Verification37A good E2E suite answers two questions quickly: “Can users complete the critical journey?” and, when not, “What observable browser evidence narrows the failure?” If it cannot do both, reduce scope or improve observability.3839## References40- Playwright, Best Practices: https://playwright.dev/docs/best-practices41- Google Testing Blog, How Much Testing is Enough?: https://testing.googleblog.com/2021/06/how-much-testing-is-enough.html42- Google Testing Blog, Just Say No to More End-to-End Tests: https://testing.googleblog.com/2015/04/just-say-no-to-more-end-to-end-tests.html