#What an end-to-end test is for
AddedKnowing Playwright's API is the easy half. The hard half, and what interviewers probe, is judgement: what to test, how much, and how to tell a test that protects you from one that only looks busy.
An end-to-end (E2E) test drives the whole running app the way a user does: a real browser, the real front end, the real API behind it. It answers one question nothing else can: can a person actually do this? Unit tests can prove that the total function adds tax correctly and that the cart component renders rows, and the checkout can still be broken because the button posts to the wrong URL, a CSS change put an invisible layer over it, or the API and the front end disagree about a field name. An E2E test catches those because it goes through every layer at once.
That reach has a cost. E2E tests are slow (seconds each, not milliseconds), they need the whole system running, they can fail for reasons that aren't bugs (a slow environment, shared data), and when one fails it tells you that something is wrong, not where. So the goal is a small number of E2E tests that cover what matters most, sitting on top of many cheaper tests that check the details.
The mental model: a fire drill. You don't test every smoke detector by running a fire drill; each detector has its own quick test. The drill checks that the whole building works together: alarms sound, doors open, people get out. A few drills, run regularly, on the routes people really use. That's what your E2E suite is.
| You want to know… | The cheapest test that can tell you |
|---|---|
| The total adds express delivery and rounds correctly | a unit test of the pricing function |
| The email field rejects "rohit@" | a unit test of the validator, or a component test of the form |
POST /orders stores the order and returns its id | an API (integration) test |
| The cart page shows a row per item | a component test |
| A signed-in user can find a product, buy it and see a confirmation | an E2E test: nothing smaller covers it |