Testing strategy
The trophy not the pyramid: integration tests around API routes, a few Playwright flows for money paths, unit tests for pure logic only.
The mental model
Tests are the smoke detectors in your house, and the classic mistake is buying the wrong number in the wrong rooms. Put a detector in every drawer and you get an alarm every time you make toast — you rip the batteries out, and now the house is unprotected. Put none in the kitchen and the one place fires actually start has no coverage. A good testing strategy is not "more tests"; it is detectors where fires start, sensitive enough to catch real smoke, quiet enough that you never learn to ignore them.
The analogy that sticks: tests exist to let you change code without fear. Their entire value is the confidence to refactor and ship on a Friday. A test that breaks when you rename an internal function — but the user-visible behaviour is unchanged — is a *false alarm*; it taxes every change and teaches you to distrust the suite. A test that keeps passing while a checkout endpoint silently returns the wrong total is a *smoke detector wired to nothing*. You are optimising for a specific ratio: maximum confidence per test, minimum maintenance per test.
The one idea that reorganises everything: test through the seams users actually cross, not the internal ones. The old "test pyramid" (mountains of unit tests, few integration, almost no E2E) optimises for speed and isolation, which pushes you to test private functions and mock everything — producing a suite that is green while the app is broken, because the mocks lie. The modern shape is the testing trophy (Kent C. Dodds): a fat middle of integration tests that hit a real API route against a real database, a thin top of E2E for the money paths, and unit tests reserved for genuinely pure logic. The trophy maximises confidence-per-test because it exercises the same seams your users do.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision