Skip to content

Test layers

The four kinds of test in the repository: where each lives, what it runs against, and the command that runs it.

<!-- source: packages/test-utils, packages/*/vitest.integration.config.ts, services/web/playwright.config.ts, tools/merge-coverage.ts -->

Layers

LayerAnswersLives inRuns againstCommand
Unitdoes this function do the right thing in isolation?<package>/tests/*.test.tsnothing: no database, no networkpnpm test
Integrationdo the module's queries, procedures and subscribers work together?<package>/tests/integration/**/*.test.tsa fresh postgres:16-alpine container per runpnpm test:integration
Componentdoes this React component render and behave with known data?services/web/tests/components/*.test.tsxjsdom, the real en catalog, stubbed tRPC callspnpm test
End-to-endcan a person complete this flow in a browser?services/web/tests/e2e/*.spec.tsthe running app: Supabase, api and webpnpm test:e2e

Other suites: pnpm test:tools runs the tests for the repository scripts in tools/; services/api/tests/integration/mcp-e2e.test.ts drives the MCP server against a real API.

Tooling

LayerTools
UnitVitest
IntegrationVitest, Testcontainers; @monark/test-utils (global-setup, assert-test-db, truncate)
ComponentVitest, Testing Library, msw; renderWithIntl from services/web/tests/test-utils.tsx
End-to-endPlaywright (Chromium only), @axe-core/playwright for the accessibility sweep

Integration harness

SettingValue
Config filevitest.integration.config.ts in the package
globalSetup@monark/test-utils/global-setup: starts the container, applies migrations, sets DATABASE_URL / DIRECT_URL
setupFiles@monark/test-utils/assert-test-db: aborts unless DATABASE_URL contains /monark_test
Concurrencyserial (fileParallelism: false); turbo runs packages with --concurrency=1
Reset between teststruncate(getDb(), ["Table", …]) in beforeEach
RequiresDocker running

End-to-end settings

VariablePurpose
E2E_FULL_STACK=1runs the full-stack specs; without it they are skipped
E2E_USER_EMAIL, E2E_USER_PASSWORDthe member test account
E2E_ADMIN_EMAIL, E2E_ADMIN_PASSWORDthe admin test account
INBUCKET_URLthe local mail catcher, http://localhost:54324
API_URLthe api, http://localhost:4000

Seed the test accounts with pnpm tsx tools/seed-e2e-users.ts.

Coverage

ItemValue
Unit output<package>/coverage/unit/
Integration output<package>/coverage/integration/
Merge and gatepnpm coverage:merge fuses both per package and checks the floors
Floorsper package and per metric (lines, statements, functions, branches), in THRESHOLDS in tools/merge-coverage.ts
Missing floora package that produces coverage without a THRESHOLDS entry fails the merge

In CI

JobRuns
unit-testspnpm test:coverage
integration-testspnpm test:integration:coverage
coverage-uploadpnpm coverage:merge
repo-checkspnpm test:tools among the repository checks
e2e.ymlPlaywright, on manual dispatch only

Related