All posts Engineering

Why End-to-End Tests Matter (and How to Keep Them Useful)

Unit tests tell you each piece works. End-to-end tests tell you a customer can actually use your product. Why E2E tests matter, what to cover, and how to keep them fast and reliable instead of slow and flaky.

Every unit test passed. The integration tests were green. The deploy went out at 4 p.m., and by 4:20 the support inbox was filling up: nobody could log in. A backend endpoint had been renamed. The frontend tests mocked the API, so they never noticed. The backend tests never knew the login form existed. Every piece worked on its own. The product didn't.

That gap, between "each part works" and "a customer can actually use this," is exactly what end-to-end tests exist to close.

What an end-to-end test actually is

An end-to-end (E2E) test checks your system the way a user uses it. It opens a real browser or calls your public API, goes through the real frontend, backend, database and third-party services you control, and checks the result a user would see. It doesn't call your functions directly or mock the layers in between.

It helps to compare it with the other kinds of tests most teams already have:

  • Unit tests check one function or class in isolation. They're fast and precise, but they can't tell you whether the pieces fit together.
  • Integration tests check that two or three components work together, like your API and your database. They catch more, but usually still skip the UI and the deployed configuration.
  • End-to-end tests check a complete user journey, such as "sign up, verify email, create a project." They're slower and broader, and they're the only tests that answer the question your customers care about: does it work?

Why end-to-end tests matter

They test what your customers actually experience

Customers don't use your functions or your endpoints. They use flows. A unit test can prove that your password hashing is correct while the login button does nothing because a script failed to load. E2E tests are written from the outside in, so a passing suite means something concrete: a person could have done this.

They catch the bugs that live between the pieces

Many production bugs aren't inside any one component. They live in the seams: a renamed field in an API response, a missing environment variable, a database migration that ran in the wrong order, a cookie that's no longer sent because of a domain change, a redirect rule that loops. Each component's own tests pass, because each component is fine. Only a test that crosses all the boundaries at once sees the problem.

They make big changes safer

Framework upgrades, dependency bumps, a move to a new hosting provider, a large refactor: these are the changes that make teams nervous, because they touch everything and unit tests are often rewritten along with the code. E2E tests don't care how the inside is built. If the same user journeys still pass before and after, you have real evidence that the change didn't break anything that matters.

They document the flows that matter

A well-named E2E suite reads like a list of what your product promises: "user can sign up," "admin can invite a teammate," "customer can upgrade their plan." New engineers can read it to understand the important paths, and the team has a shared, executable answer to "what must never break?"

They're cheaper than incidents

An E2E suite costs time to write and keep running. A broken signup flow that nobody notices for six hours costs lost customers, support tickets, an incident, a status page update and a postmortem. Catching the same bug in CI costs one red build. Most teams that invest in a small, reliable E2E suite find it pays for itself the first time it blocks a bad deploy.

Why teams avoid them

If E2E tests are so useful, why do so many teams have few or none? Because done badly, they earn their bad reputation:

  • They're slow. Driving a browser through a full flow takes seconds per test, not milliseconds.
  • They're flaky. Timing issues, shared test data and unstable environments cause random failures that nobody trusts.
  • They're brittle. A test that clicks the third button in the second div breaks every time someone changes the layout.

All three are real, and all three are fixable. The answer isn't to skip E2E tests. It's to have fewer of them, aimed at the right things, and written carefully. The classic test pyramid puts it well: lots of fast unit tests at the bottom, fewer integration tests in the middle, and a small number of end-to-end tests at the top. Small doesn't mean unimportant. The top of the pyramid is where you check that everything below it adds up to a working product.

What to cover

You don't need an E2E test for every feature. Start with your critical user journeys: the handful of flows where a failure would be an incident. A useful question is: if this broke at 3 a.m., would we wake someone up? If yes, it deserves an E2E test.

For most products, that list looks something like this:

  • Sign up and log in, including password reset. If people can't get in, nothing else matters.
  • The core action your product exists for. For a status page product, that's posting an incident and seeing it on the public page. For a store, it's adding to cart and checking out.
  • Payments and upgrades. Money flows are high-stakes and often depend on third parties.
  • Anything that has broken before. Every incident is a hint about where your other tests have a blind spot. Turning a postmortem's root cause into an E2E test makes sure that particular failure can't return quietly.

Five to twenty well-chosen journeys will catch a surprising share of the bugs that would otherwise reach production.

What a good end-to-end test looks like

Here's a short example using Playwright. It signs in like a real user and checks what the user would see:

login.spec.ts

import { test, expect } from '@playwright/test';

test('user can sign in and see the dashboard', async ({ page }) => {
  await page.goto('/login');
  await page.getByLabel('Email').fill('e2e-user@example.com');
  await page.getByLabel('Password').fill(process.env.E2E_PASSWORD!);
  await page.getByRole('button', { name: 'Sign in' }).click();

  await expect(page).toHaveURL(/\/dashboard/);
  await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
});

A few things make this test sturdy. It finds elements by their label and role, the way a person (or a screen reader) would, not by CSS classes that change with every redesign. It never sleeps for a fixed number of seconds; it waits for the page to reach the expected state. And it checks an outcome the user cares about, not an implementation detail.

How to keep E2E tests useful

1. Keep the suite small and focused

Test journeys, not every edge case. Validation rules, error messages and calculations are better covered by unit tests, which are faster and pinpoint the problem. An E2E test should answer "does this flow work?", not "does every field reject every bad input?"

2. Wait for states, not for time

Fixed delays like sleep(3000) are the most common cause of flaky tests. Too short and the test fails on a slow day; too long and the suite crawls. Modern tools such as Playwright and Cypress automatically wait for elements to appear and become usable. Lean on that, and wait explicitly for network responses or visible results when you need to.

3. Use stable selectors

Select elements by accessible role, label or visible text, or add dedicated data-testid attributes for elements that have none. Avoid long CSS paths and positional selectors. As a bonus, tests that find elements by label tend to push your UI toward being more accessible.

4. Give each test its own data

Tests that share an account or depend on running in a certain order fail in confusing ways, especially once you run them in parallel. Have each test create the data it needs, ideally through an API or a seed script rather than clicking through the UI, and clean up afterward or use throwaway accounts.

5. Treat flaky tests as bugs

A test that fails randomly teaches the team to ignore red builds, and that's worse than having no test. When a test flakes, find the cause. Sometimes it's the test; sometimes it's a real race condition in your app that users hit too. If you can't fix it right away, move it out of the blocking path and track it, rather than letting "just retry it" become a habit.

6. Put them in the right place in your pipeline

E2E tests are the slowest part of most test suites, so where they run matters. A common setup is a small smoke subset that gates merging, with the full suite running before deploy or on a schedule. We covered the trade-offs in more detail in why CI pipeline speed matters.

7. Capture evidence when they fail

An E2E failure that just says "element not found" is hard to debug. Save screenshots, videos or traces, plus browser console and server logs, for every failed run. Most tools support this with a line of config, and it turns a frustrating hour of guessing into a two-minute fix.

Don't stop at deploy

Your staging environment is never quite the same as production. Different data, different traffic, different configuration, different third-party accounts. Some bugs only show up for real.

That's why many teams also run a few of their most important E2E checks against production: once right after each deploy, as a final smoke test, and then on a schedule, often called synthetic monitoring. A scheduled check that logs in and loads the dashboard every few minutes tells you about a broken login long before your customers email you about it. Keep these checks read-only or use dedicated test accounts so they never touch real customer data.

Tests reduce incidents. They don't eliminate them.

Even an excellent E2E suite won't catch everything. A third-party API will go down, a traffic spike will expose a slow query, a change will interact with real data in a way nobody predicted. The goal of testing isn't zero incidents. It's fewer of them, caught earlier, with less damage.

When something does get through, two things matter: how fast you fix it, and how well you keep your customers informed while you do. Statusentry gives you a hosted status page to post incident updates and notify subscribers. Afterwards, you can publish a postmortem, and the root cause you find there is a good candidate for your next end-to-end test.

FAQ

What is an end-to-end test?

An end-to-end (E2E) test checks a complete user journey through the real system, the way a user would: through the UI or public API, across the frontend, backend, database and services, without mocking the layers in between. It answers whether a customer can actually complete a task, such as signing up or checking out.

What's the difference between end-to-end and integration tests?

Integration tests check that a few components work together, such as an API and its database, usually without the UI or deployed configuration. End-to-end tests cover the whole flow from the user's point of view, so they catch problems in the seams between components that integration tests can miss.

How many end-to-end tests should you have?

Fewer than unit or integration tests. Focus on critical user journeys, the flows where a failure would be an incident: sign up and login, your product's core action, payments, and anything that has broken before. Five to twenty well-chosen journeys cover a lot for most products.

How do you make end-to-end tests less flaky?

Wait for states instead of using fixed sleeps, select elements by role, label or test IDs instead of CSS paths, give each test its own data, and treat every flaky test as a bug to fix rather than something to retry.

Try Statusentry

Communicate incidents calmly, transparently, instantly.

Start with a 30-day Enterprise trial. Afterwards, keep the free plan with no time limit.