Unit Testing with Vitest in MakerKit
Run and write unit tests with the Vitest setup used by the current monorepo.
Unit tests live across packages and run through Vitest.
Run Tests
All unit tests:
pnpm test:unitSingle package:
pnpm --filter @kit/rbac test:unitpnpm --filter @kit/database test:unitWatch mode is only available in packages that define test:unit:watch:
pnpm --filter @kit/rbac test:unit:watchCoverage
There is no repo-wide (root) test:unit:coverage script. Some packages ship their own test:unit:coverage script (vitest run --coverage) — for example @kit/rbac, @kit/policies, and @kit/shared. Run coverage per package:
pnpm --filter @kit/rbac test:unit:coverageFor packages without that script, run Vitest directly for the package.
Where Tests Live
Tests usually sit near the code they cover, for example:
packages/rbac/src/core/__tests__/packages/database/src/services/packages/organization/core/src/services/__tests__/Good Candidates
- pure functions
- service logic
- schema validation
- RBAC and policy behavior
- database helpers and test utilities