What is the difference between an integration test and an end-to-end test?
Quick Answer
An integration test exercises a slice of the system with some real components (the API + a real database, but no browser). An end-to-end test drives the whole system the way a user does — usually through the browser (Playwright, Selenium) against a deployed environment. E2E has the highest confidence and the highest cost/flakiness.
An integration test wires up a real slice — for a Web API that's the app plus a real database, running in memory, no browser. An end-to-end test goes all the way: it opens a browser with Playwright or Selenium and clicks through the actual UI against a deployed environment. E2E gives you the most confidence because it tests everything together, but it's slow, it's flaky, and it's a lot to maintain, so you keep the number small — a few critical user journeys — and rely on unit and integration tests for the breadth.
- Test pyramid: many unit, some integration, few E2E — because E2E is slow, brittle and expensive to maintain.
- Integration tests can run in CI in seconds with a containerised DB; E2E needs a running environment and is minutes.
- Contract tests (Pact) verify two services agree on an interface without a full E2E deployment.