Comprehensive Testing
Confidence in our code is vital to maintaining a fast, safe deployment cadence. FRAME incorporates testing as part of the development process.
TDD (Test-Driven Development)
Section titled “TDD (Test-Driven Development)”FRAME promotes a test-driven development (TDD) approach, where tests are written before functional code. This helps ensure the code is robust and that tests are well defined.
Testing Strategy
Section titled “Testing Strategy”Our strategy follows the testing pyramid: dense unit tests, a focused integration layer, and a small set of risk-based end-to-end journeys.
File naming
Section titled “File naming”| Suffix | Layer | Placement |
|---|---|---|
*.test.ts / *.test.tsx | Unit | Colocated next to the module |
*.spec.ts | Integration / e2e | Under e2e/ or integration/ |
Do not use *.e2e-spec.ts. Do not put unit tests in *.spec.ts.
Unit Tests (Vitest)
Section titled “Unit Tests (Vitest)”They are fast, isolated, and focused on testing pure logic, functions, and components.
- We use Vitest across the monorepo for high execution speed and predictable configuration. Unit configs include only
**/*.test.ts(x). - Apps (
apps/*) unit-test business logic, solitary Nest use-cases/controllers, Zustand slices, hooks, and critical UI interactions. - Packages (
packages/*) unit-test utilities, Zod schemas, codecs, config builders, and exported pure APIs. - Unit tests must not hit real databases, network, or filesystem — mock at the boundary.
Integration and E2E Tests (*.spec.ts)
Section titled “Integration and E2E Tests (*.spec.ts)”These verify module boundaries and user journeys.
- NestJS: Vitest + Nest TestingModule + supertest under
apps/nest/e2e/**/*.spec.ts(HTTP contracts such as CSRF, health, authz, authenticated CRUD against a test database). - Next.js: Playwright under
apps/next/e2e/**/*.spec.tsfor critical browser journeys. MSW backs HTTP client unit tests (*.test.ts). @frame/astro/ docs: Keep Vitest unit/smoke checks and rely on Starlight link validation at build time. No Playwright suite.
Playwright on PRs runs Chromium only; pushes to main run the full browser matrix.
Coverage Gates
Section titled “Coverage Gates”| Type | lines | branches | functions | statements |
|---|---|---|---|---|
| packages | 50% | 50% | 50% | 50% |
| apps | 40% | 30% | 30% | 40% |
Thresholds are enforced with vitest --coverage. Coverage includes src/** (scoped per package) so floors reflect product code. Raise thresholds as coverage improves; prefer patch coverage on new lines for PR honesty.
Optimized Continuous Integration (CI)
Section titled “Optimized Continuous Integration (CI)”Turborepo runs affected packages on pull requests (test:affected, test-e2e:affected) and the full suite on pushes to main. CI always passes --coverage for unit tests so thresholds fail the job when unmet. Coverage and Playwright reports are uploaded as workflow artifacts.