Skip to main content

Testing & Tooling

Unit tests

Run unit tests in band to minimize memory use:

pnpm nx run teetime-backend:test:unit --runInBand

The backend’s Jest config maps @digiwedge/tee-time-services to a lightweight stub during unit tests to avoid heavy ESM dependencies. See apps/teetime/teetime-backend/jest.config.ts.

For the admin portal, tests run the app with a MemoryRouter and mock the auth hooks. The package @digiwedge/teetime-api-client is mapped to source to keep type safety when exercising the admin pages.

Integration tests (data libs)

Integration tests live in Prisma data packages (e.g., libs/prisma/*). Some tests call into @digiwedge/prisma-testing. The helper is schema‑agnostic and expects a concrete Prisma client to be registered via:

  • setPrisma(new PrismaClient()) in the project’s Jest setup, or
  • PRISMA_CLIENT_PACKAGE=@prisma/<schema> in the environment.

Example (payments‑data):

// libs/prisma/payments-data/src/lib/__tests__/jest.setup.int.ts
import { setPrisma } from '@digiwedge/prisma-testing';
// ... create and connect PrismaClient
setPrisma(global.__BILLING_PRISMA__);

Offline workflows

When running fully offline, set the following to skip cache checks and integration tests that require Docker:

export NX_NO_CLOUD=true NX_CLOUD_OFFLINE=true NX_SKIP_NX_CACHE_CHECKS=true
export SKIP_INTEGRATION=1 TESTCONTAINERS_RYUK_DISABLED=true

Linting & formatting

tools/scripts/lint-all.sh --max-warnings=0
pnpm nx format:write