Testing
mocha + supertest + nock, configured in package.json (mocha key):
- specs live in
test/**/*.test.ts(recursive), with shared hooks intest/hooks.ts; - TypeScript runs through
@poppinss/ts-exec(same as dev — decorator metadata); supertestdrives the Koa app over HTTP;nockintercepts upstream calls (Repliers, FUB) so tests never hit real APIs;NODE_ENV=testing+DOT_ENV_CONFIG=test.envisolate test configuration.
Commands
npm run test # full suite (expects the test database)
npm run test:local # same, DB on port 5555 (the local convention)
npm run test:local:watch # watch mode
npm run test:local:watch:grep -- "<pattern>" # one spec in watch mode
npm run test:coverage # c8 text report (test:coverage:html for HTML)
npm run test:ci # JUnit reporter → test-results/ (a CI's test UI)The test database is migrated with npm run db:migrate:test — see
Database & Services.
Practical notes
- Isolate failures with
--grep. On Windows especially, one failing spec can cascade into a wall of unrelated errors (a pino transport crash follows the first failure) — re-run the single spec before believing the noise. - CI runs the suite against a fresh
postgres:16-alpineservice container on every PR — see CI/CD. - Coverage is advisory (
c8), not a gate.
Last updated on