Testing and quality · Comparison
Unit vs integration vs end-to-end tests
The three layers of the testing pyramid. Each catches different bugs at a different cost, and a healthy suite has many unit tests, a fair number of integration tests and a few end-to-end tests.
3 options · 8 questions side by side · updated
| Compare | Unit tests | Integration tests | End-to-end tests |
|---|---|---|---|
| What it checks | One function or module on its own | Several parts working together | A whole user journey in a browser |
| Speed | Milliseconds each | Fractions of a second to seconds | Seconds to minutes each |
| Setup needed | Almost none | A test database or services | A running app, browser and test data |
| Typical tools | Vitest, Jest, pytest | Vitest, Jest, pytest, Testing Library | Playwright, Cypress |
| Catches | Logic and edge-case bugs | Mismatches between parts | Broken journeys users would hit |
| Flakiness | Rare | Occasional | Most common |
| How many | Many | Some | A few, on key journeys |
| When to run | On every save and every commit | On every pull request | On pull requests and before a release |
How to choose between Unit tests, Integration tests and End-to-end tests
- Write unit tests for logic with rules and edge cases, such as prices, dates and permissions.
- Add integration tests where parts meet: API routes with a real database, forms with their validation.
- Keep end-to-end tests for the journeys that must never break, such as sign-in and checkout.
The options
- Unit testsSmall, fast tests that check one piece of code, such as a single function, on its own, by giving it inputs and checking the output.
- Integration testsTests that check several pieces working together, such as an API route with its real database, or a screen with its form and validation.
- End-to-end testsTests that drive the real app in a real browser the way a user would, clicking, typing and checking what appears on the screen.
More comparisons
- Vitest vs JestTwo JavaScript test runners with nearly the same API. Jest is the long-standing default; Vitest is the newer option built on Vite, with TypeScript and ES modules working out of the box.
- Playwright vs Cypress vs PuppeteerAll three control real browsers. Playwright and Cypress are built for end-to-end testing; Puppeteer is a lower-level automation library that is often used for PDFs and scraping.
- Vercel vs Netlify vs Cloudflare PagesAll three build your site from Git, serve it from a global CDN and give every branch a preview link. They differ in which frameworks they favour, how they bill, and what sits around the hosting.
- Serverless vs VPS vs shared hostingThree very different ways to run the server side of a site. They trade off how much you manage, how costs behave as traffic grows, and what kinds of software you can run.
- AWS vs Google Cloud vs AzureThe three big clouds offer similar building blocks under different names. The choice usually comes down to your team's experience, the ecosystem you already use and a few standout services.
- Fly.io vs Render vs Railway vs HerokuFour platforms that run your backend from Git or a container without you managing servers. They differ in free options, how they bill and how much control they give you.
Crafted in the dark. Shipped to the world.
Tell us what you are building. You get a private project space with a proposal and a line-by-line quote within a day.