Skip to content

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

  1. 1Test pyramid and testing trophyChoose the test mix whose observations justify its cost for this product.
  2. 2Test doubles and boundariesChoose the collaborator to control, then preserve the behavior being examined.
  3. 3Contract testing between servicesA schema lists what is allowed; a pact lists what is used.
  4. 4TDD: red, green, refactorOne failing test at a time: make it run, then make it right.

Testing your stack

  1. 5Testing React components with Testing LibraryExpress the interaction through a meaningful query, realistic input, and an observation that matches the UI lifecycle.
  2. 6Testing NestJS: modules, overrides and a real databaseFake only the edges, keep Postgres real, and give every test a clean database of its own.
  3. 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.

Trustworthy suites

  1. 8Flaky tests: causes and curesMake the failure repeat on demand, fix its cause, and never let a retry decide.
  2. 9Coverage vs mutation testingCoverage shows what your tests ran; mutation testing shows what they would catch.