Testing & QA
End-to-End (E2E) Tests
The idea, in plain English
An end-to-end test acts like a real user clicking through your whole app from start to finish. Instead of checking one function, it checks a complete journey: open the site, log in, add something to the cart, check out — and confirms the goal was reached. It's the dress rehearsal with the full cast, costumes, and lights, not just one actor practicing a line. Because it exercises everything at once, it catches problems that only appear when the whole system runs together.
How it works
- 1Describe a real user goal as a sequence of steps: visit, log in, add to cart, check out.
- 2Drive the app through those steps in order, exactly as a person would, one action after another.
- 3At the end, assert the user reached the goal — the order was placed, the confirmation appeared.
- 4In the real world, a tool automates an actual browser to do all this. Below we simulate the flow in plain code so it can run here.
When you'd use it
Use E2E tests for your most important user journeys — sign-up, login, checkout — the flows that must never break. Real E2E tools drive a live browser, so they aren't shown running here: Cypress and Playwright are modern favorites that open a real browser and click through your app, and Selenium is the long-standing tool that pioneered browser automation across many browsers and languages. Keep E2E tests few, because they're slower and more fragile than unit tests.
Common beginner mistakes
- Trying to cover every tiny case with E2E tests. They're slow and brittle — test the critical journeys end-to-end, and push detailed edge cases down to fast unit tests.
- Forgetting they need a running app and real data set up. An E2E test failing often means the environment was wrong, not that your feature is broken.
Try it — edit and run
Click the code to edit · press ⌘/Ctrl+↵ to run
Editable code. Tab and Shift+Tab indent. Press Escape, then Tab, to move focus out of the editor.
visit home
login
add book
order placed
Flow result: success
PASS: user completed checkoutNot sure this is the right topic? See the learning paths → or where this leads →