Backend tests
The backend (api/) supports two kinds of tests:
Unit tests
Mock the Prisma service and test business logic in isolation — no database required. Files live under
test/unit/ with the .spec.ts extension.Integration tests
Use a real database and test the full request/response cycle through the controller endpoints. Files live under
test/integration/ with the .e2e-spec.ts extension.Running unit tests
Unit tests require two environment variables. Create a.env file in the api/ directory before running:
api/ directory:
Running integration tests
From theapi/ directory:
Running with code coverage
Frontend tests
Each frontend site (sites/public and sites/partners) has two layers of tests.
- sites/public
- sites/partners
Run these commands from the
sites/public/ directory.| Command | Description |
|---|---|
yarn test | Cypress E2E tests (requires the app to be running) |
yarn test:headless | Cypress E2E tests in headless mode |
yarn test:unit | Jest unit and integration tests |
yarn test:unit:coverage | Jest unit and integration tests with coverage |
Root-level test commands
The rootpackage.json provides convenience scripts to run tests for any part of the stack without needing to cd into subdirectories.
| Script | What it runs |
|---|---|
yarn test:backend:new | API unit tests (api/ directory) |
yarn test:backend:new:e2e | API integration tests |
yarn test:backend:new:cov | API tests with coverage |
yarn test:app:public | Public site Cypress E2E tests |
yarn test:app:partners | Partners site Cypress E2E tests |
yarn test:app:public:unit | Public site Jest tests with coverage |
yarn test:app:partners:unit | Partners site Jest tests with coverage |
yarn test:shared-helpers | Shared-helpers package tests |
Writing tests
Unit test conventions
- Mock the
PrismaService— unit tests must not touch the database. - Test service functions directly rather than going through the HTTP layer.
- Cover edge cases and error conditions, not just the happy path.
- File extension:
.spec.ts, located undertest/unit/.
Integration test conventions
- Start with an empty database — do not rely on pre-seeded data.
- Clean up all created records after each test or test suite completes.
- Mock as little as possible; the point is to verify real database interactions.
- File extension:
.e2e-spec.ts, located undertest/integration/.
CI test suite
Every pull request triggers the full test suite via GitHub Actions:
No PR that introduces failures in existing tests will be accepted. All coverage benchmarks must be met.