NODEJS Contents

CI Testing Strategy

CI makes tests meaningful: it enforces repeatable execution on every change, blocks regressions, and builds deployment confidence.

On this page

Why CI Is Part of Testing

Tests that only run on a developer laptop are optional. CI makes them mandatory by running them in a clean environment on every pull request and on main. This is the difference between 'we have tests' and 'tests protect production'.

CI Goals

  • Deterministic environment (fresh install, no hidden state)
  • Fast feedback (fail early on lint/type/test)
  • Consistent outputs (coverage, artifacts, logs)

Recommended Pipeline Order

  • Install dependencies
  • Type check (TypeScript)
  • Lint
  • Unit tests
  • Integration tests (with services)

Handling Integration Dependencies

If integration tests require a database or cache, run them via containers in CI and wait for readiness. Avoid race conditions where tests start before dependencies are ready.

Flake Management

Flaky tests destroy trust. Treat flakiness as a bug: fix it or delete the test. Do not add blind retries that hide real failures.

Production Insight

CI is also where you enforce migration safety, schema checks, and build reproducibility. If it does not run in CI, it is not production-grade.