Testing & local infrastructure
Testing & local infrastructure
The test infrastructure is ephemeral for tests and persistent for the dev app — they are intentionally separate.
Test tiers
| Tier | Command | Needs infra? | How |
|---|---|---|---|
| Unit + coverage | pnpm test / pnpm test:cov |
No | Repositories, Redis and SOAP are mocked. Integration specs skip gracefully (describeIfRedis). CI runs this with a dummy DATABASE_URL and no services. |
Integration (*.integration.spec.ts) |
pnpm test:integration |
Yes (Redis) | Spins up an ephemeral Redis via Testcontainers (scripts/runtime/run-testcontainers-command.ts redis) and injects its URL. No *.integration.spec.ts touches a real Postgres, so no DB schema/migration is required. |
E2E (*.e2e-spec.ts) |
pnpm test:e2e |
No | Each suite builds a Nest TestingModule with mocked transports/repositories. |
pnpm agents:test:redis runs only the agents Redis integration suite (same
mechanism, narrower scope).
Why no docker-compose.test.yml
There is already a Testcontainers harness
(test/support/testcontainers/{postgres,redis,app-infra}.ts +
run-testcontainers-command.ts <redis|postgres|app>) that starts disposable
containers per run, injects connection env vars and tears them down. A separate
test compose file would duplicate it.
Local dev app (not tests)
docker-compose.yml provides a persistent db (Postgres) + redis (with ACL,
infra/redis/) for running the application locally:
pnpm infra:up # docker compose up -d db redis
pnpm prisma:migrate:apply
pnpm infra:down
Infra placement (Redis / Postgres)
- Tests → ephemeral & local (Testcontainers / Docker), one per run. Never point tests at a shared remote instance: it breaks isolation, determinism and parallelism.
- Shared dev/staging → persistent service co-located is fine; lock it down
(private bind, ACL/
requirepass, TLS over the network, no public exposure). - Production → managed/dedicated, isolated from the app, with observability.
PostgreSQL version
Keep the Postgres major version aligned across compose, Testcontainers, CI and
production to avoid “passes on a version we don’t run” gaps. The stack is
standardized on Postgres 18 (docker-compose.yml, the Testcontainers
default and the CI services). A bump must be coordinated across all of them.