The Testing Trophy: A Modern Alternative to the Test Pyramid
The testing pyramid has been the dominant mental model for software testing since Mike Cohn introduced it around 2009. Many units at the base, fewer integration tests in the middle, even fewer end-to-end tests at the top. It's clean. It's intuitive. And for a lot of modern frontend and full-stack teams, it's wrong.
Kent C. Dodds proposed the Testing Trophy as a counterweight — a model that better reflects the reality of testing React applications, REST APIs, and the kind of full-stack JavaScript code that now dominates the industry. The trophy isn't a replacement for the pyramid everywhere. It's a more honest model for a specific class of applications, and understanding why it differs tells you a lot about what makes tests actually valuable.
What the Testing Trophy Looks Like
The trophy has four layers, from bottom to top:
- Static analysis — linting, type checking, format enforcement
- Unit tests — individual functions, pure logic, algorithmic code
- Integration tests — the widest layer, and the core of the trophy
- End-to-end tests — a thin slice at the top
The critical shift from the pyramid: integration tests get the most investment, not unit tests. This isn't a mistake or an oversimplification. It's a deliberate claim about where tests produce the most confidence per dollar of maintenance cost.
The Confidence Equation
Dodds frames the entire model around a single question: How much confidence does this test give you that your software works?
Unit tests are fast and deterministic, but they test code in isolation. A function that transforms data correctly tells you nothing about whether the API endpoint assembles the right response, whether the database query returns the right rows, or whether the React component renders the correct UI when that data arrives.
You can have 100% unit test coverage and ship a broken product — because the bugs live in the contracts between units, not inside them.
Integration tests exercise the connections. A test that boots an Express server (in-memory or real), sends an HTTP request, and checks the JSON response is testing your route handler, middleware chain, database query, and serialization layer together. When that test passes, you have genuine confidence that the feature works. When it fails, the failure points to a real problem.
This is what Dodds means by confidence per test. An integration test that covers a user flow gives you more signal than five unit tests that each verify a helper function in isolation.
Static Analysis at the Base
One genuinely novel thing about the trophy is making static analysis an explicit layer. TypeScript, ESLint, Prettier — these aren't tests in the traditional sense, but they catch entire categories of bugs before any code runs.
Type errors are bugs. Import path mistakes are bugs. Using a deprecated API in a way the type system can catch — that's a bug you don't need a test for. Static analysis finds these at zero cost, with zero flakiness, with instant feedback in your editor.
By putting static analysis at the base of the trophy, Dodds is making the point that it's foundational infrastructure, not optional tooling. Teams that skip TypeScript or run ESLint only in CI are leaving cheap confidence on the table.
The pyramid model doesn't have a layer for this. The trophy treats it as load-bearing.
Why Integration Tests Deserve the Wide Middle
There's a persistent belief that integration tests are expensive, slow, and fragile. Sometimes that's true. But it's usually a symptom of poor implementation, not an inherent property.
Modern testing tools make integration tests practical:
- Testing Library (React Testing Library,
@testing-library/user-event) renders components in a real DOM, fires actual user events, and queries by accessible role — not by CSS class or internal state - Supertest lets you test Express/Fastify/Koa handlers without starting a network listener
- Prisma supports test databases and transactions you can roll back after each test
- MSW (Mock Service Worker) intercepts network requests at the service worker level, so you can mock APIs without stubbing
fetchoraxiosin every test
With these tools, an integration test that renders a form, types into it, submits it, and asserts the database state changed is not particularly slow or fragile. It runs in seconds and tests what actually matters.
The reason unit tests dominated historically is that integration tests used to be hard. That's less true now.
How the Trophy Differs From the Pyramid in Practice
The pyramid says: write lots of unit tests, a moderate number of integration tests, very few E2E tests. If you follow it strictly, you end up with thousands of unit tests that mock their dependencies heavily, and a codebase that's simultaneously over-tested and under-confident.
The trophy says: invest in integration tests as your primary verification layer. Write unit tests where the logic is genuinely complex and isolated — algorithm implementations, utility functions, parsers, validators. Use E2E tests selectively for the most critical user flows. Let static analysis handle the structural guarantees.
The practical difference shows up in what you mock. In a unit-test-heavy codebase, you mock everything: the database, the HTTP client, the file system, other modules. In a trophy-oriented codebase, you mock at the boundaries — real database (test schema), real HTTP, real rendering, but mocked external APIs.
Mocking less means your tests fail when the real integration breaks. That's the point.
When to Write a Unit Test vs. an Integration Test
The trophy doesn't eliminate unit tests. It clarifies when they're the right tool.
Write unit tests when:
- The logic is genuinely pure — same inputs always produce same outputs, no I/O
- The edge cases are combinatorial — you need to test 15 input variations and integration overhead would be prohibitive
- The code is a utility used across many features — a date formatter, a currency parser, a permission checker
- TDD is guiding design — small red/green/refactor cycles to shape an algorithm
Write integration tests when:
- Multiple units collaborate to produce an output the user cares about
- You're testing an HTTP handler, a React page, a database query, a message consumer
- You want to verify that configuration wires correctly — middleware applied in the right order, environment variables read correctly
- The failure modes are at the seams — wrong status code, missing field in JSON, incorrect database state
The question isn't "is this unit-testable?" Everything is unit-testable with enough mocking. The question is "what am I actually trying to verify, and does isolating this code into a unit test give me genuine confidence?"
The E2E Slice
End-to-end tests in the trophy are intentionally thin. Not because E2E is bad — because it's expensive to write, slow to run, and flaky under load. When every test that matters runs in your integration layer, you don't need E2E coverage of every feature.
Use E2E for:
- Critical business flows — checkout, authentication, payment
- Smoke tests to verify deployment success — does the app load? Can you log in?
- Flows that cross system boundaries in ways integration tests can't cover — OAuth redirects, multi-tab state, service worker behavior
Playwright and Cypress have made E2E more reliable than Selenium ever was. But reliability isn't free. Every E2E test you add is a test that takes 5–30 seconds, can fail due to timing, and requires a running browser. The trophy says: use that budget on the flows that would catastrophically break your business.
Implementing the Trophy in an Existing Codebase
Migrating from a pyramid-heavy approach doesn't mean deleting unit tests. It means changing where new tests go.
Step 1: Add static analysis if it's missing. TypeScript is the highest-leverage change you can make to a JavaScript codebase's test confidence. ESLint with reasonable rules catches a second category of bugs. This is low-cost, high-value, and orthogonal to everything else.
Step 2: Audit your current unit tests. Group them by what they mock. Tests that mock the database, the HTTP client, and three other modules — those are integration tests pretending to be unit tests. They have the cost of integration tests (setup, mocking complexity) without the confidence. Consider rewriting them as real integration tests.
Step 3: Identify your confidence gaps. Where do bugs keep appearing that tests didn't catch? Usually at integration points. Add integration tests there.
Step 4: Add one E2E test per critical user flow. Not per feature. Per flow — the irreducible sequence of steps a user must complete to get value from your application.
Common Objections
"Integration tests are too slow." A test suite with 200 integration tests using Testing Library and Supertest typically runs in under 30 seconds with parallelization. That's slower than unit tests but faster than waiting for a QA cycle or a production incident.
"Integration tests are too fragile." They're fragile when they test implementation details — internal state, specific mock call counts, CSS classes that change. They're stable when they test user-visible behavior — what's rendered, what the API returns, what's in the database.
"We already have good unit test coverage." Coverage measures how many lines are executed, not how much confidence you have. High unit coverage with low integration coverage means you've tested the parts in isolation but not the whole.
The Real Insight
The Testing Trophy is ultimately about honesty. The pyramid was built in an era when integration tests required a running database, a real server, and network calls — all of which made them slow and fragile. Modern tooling has collapsed that cost substantially.
Given that, the optimal strategy isn't to maximize unit tests. It's to test at the level that gives you the most confidence in the behavior your users experience. For most web applications today, that's integration tests.
Static analysis at the base. Integration tests in the middle. Unit tests where the logic demands it. E2E tests for the flows that can't fail. That's the trophy. And for a large class of modern applications, it's a more honest model than the pyramid ever was.