Skip to main content

Running tests

API tests use Jest with config test/jest.json. AGENTS.md places feature specs under test/modules/.

cd pnxt-api-nestjs
yarn test
yarn test:cov
yarn test:debug
yarn verify
yarn architecture:check
yarn di:check
yarn verify:test-pairs
ScriptWhat it runs
yarn testJest --passWithNoTests --forceExit
yarn test:covJest with coverage
yarn test:debugJest under --inspect-brk, --runInBand
yarn verifylint, Prettier check, typecheck, nest build, di:check, test
yarn architecture:checkModule boundary ratchet (scripts/architecture/check.mjs)
yarn di:checkResolves the Nest dependency graph of the API, worker and scheduler without starting them (scripts/di-check.ts)
yarn verify:test-pairsFails when a feature has no paired test

pretest generates the Prisma client. Pre-commit (Husky) runs lint-staged (Prettier and ESLint), yarn di:check, then yarn test.

Admin uses Vitest (pnpm verify in pnxt-admin). The warehouse package.json that was read has no test script.

CI workflows exist at pnxt-api-nestjs/.github/workflows/test.yml and deploy.yml. Read those files for the current steps. This page does not restate them, because they drift.

What the architecture check is for​

It guards the rules in Conventions: feature modules must not import area modules, cycles, and concrete integration imports. A new Prisma model that is missing from the tenancy extension fails test/architecture/backend-architecture.spec.ts (stated in docs/AI_CONTEXT.md).

What the dependency injection check is for​

Unit tests construct services by hand with mocks. Typecheck and nest build only compile. None of them wire Nest modules, so a provider whose dependency is not available in its module (for example a service that injects DatabaseService in a module that does not import DatabaseModule) passes every check and fails only when the process boots:

Nest can't resolve dependencies of the X (?, ...). Please make sure that the argument DatabaseService at index [0] is available in the Y context.

scripts/di-check.ts builds AppModule, WorkerModule and SchedulerModule with NestFactory.createApplicationContext(..., { preview: true }). Preview mode resolves imports and providers but instantiates nothing, so it needs no database or Redis. Required environment variables that are unset get inert placeholders, so it also runs without a .env. It prints ok or Nest's full error per entrypoint and exits non-zero on any failure.

It runs in the Husky pre-commit hook (after lint-staged, before the tests) and in yarn verify. It is not a CI step. It takes about 40 seconds, almost all of it loading the module tree. Run it after adding a provider or changing a module's imports or exports.

Ratchet metrics​

scripts/architecture/baseline.json holds counts that may not increase, including filesOver300, explicitAny and moduleFilesUsingDatabaseService (module files that mention DatabaseService, repositories included). A feature that genuinely adds persistence may raise a baseline; say so in the PR. Prefer splitting a file or reusing an existing repository before raising it.