Testing strategy
Testing strategy: the pyramid and the trophy, test doubles, contract tests, TDD, testing React, NestJS and end to end, flaky tests and mutation testing.
9 lessons
Strategy
- 1Test pyramid and testing trophyChoose the test mix whose observations justify its cost for this product.
- 2Test doubles and boundariesChoose the collaborator to control, then preserve the behavior being examined.
- 3Contract testing between servicesA schema lists what is allowed; a pact lists what is used.
- 4TDD: red, green, refactorOne failing test at a time: make it run, then make it right.
Testing your stack
- 5Testing React components with Testing LibraryExpress the interaction through a meaningful query, realistic input, and an observation that matches the UI lifecycle.
- 6Testing NestJS: modules, overrides and a real databaseFake only the edges, keep Postgres real, and give every test a clean database of its own.
- 7Playwright end-to-end tests that hold upFind elements the way users do, let assertions wait for the condition, start every test from a clean context, and read the trace.