Test Types
Unit Tests
Test a single function or class in complete isolation. Mock all external dependencies. Use the
.test.ts suffix. These run on every save and should complete in milliseconds.Integration Tests
Test multiple modules together or verify a service boundary such as a database query or HTTP handler. Use the
.spec.ts suffix. These may spin up real infrastructure using containers.E2E Tests
Test full user flows from the outside — HTTP request to response, or browser interaction to assertion. Live in
tests/e2e/. Run in CI against a staging environment.Test Framework
All Figentra projects use Vitest as the test runner. Vitest provides native TypeScript support, a Jest-compatible API, and first-class support for ESM — no transpilation step required. Add avitest.config.ts at the root of each package:
vitest.config.ts
globals: true makes describe, it, and expect available without explicit imports — matching the Jest experience most contributors already know.
Writing a Unit Test
The example below tests aUserService class. Notice that the test file lives in tests/ and imports from ../src/:
user-service.test.ts
it block. Keep each test focused on a single behaviour so failures are easy to diagnose.
Coverage Requirements
1
80%+ line coverage on all packages
Every published package must reach at least 80% line coverage. The build will fail if any package falls below this threshold, so check your coverage report before publishing.
2
100% coverage on critical paths
Error handling code, authentication logic, and data validation must have 100% line and branch coverage. Mark these files explicitly in your
vitest.config.ts using the include option under coverage.3
No untested exports
Every symbol exported from
src/index.ts must have at least one direct test. Use the coverage report to identify untested exports before opening a pull request.