Files
teOS/.claude/agent-memory/backend-specialist/testing.md
Flexomatic81 fe305f6fc8 feat: complete tOS project with HR, LEAN, Dashboard and Integrations modules
Full enterprise web operating system including:
- Next.js 14 frontend with App Router, i18n (DE/EN), shadcn/ui
- NestJS 10 backend with Prisma, JWT auth, Swagger docs
- Keycloak 24 SSO with role-based access control
- HR module (employees, time tracking, absences, org chart)
- LEAN module (3S planning, morning meeting SQCDM, skill matrix)
- Integrations module (PlentyONE, Zulip, Todoist, FreeScout, Nextcloud, ecoDMS, GembaDocs)
- Dashboard with customizable drag & drop widget grid
- Docker Compose infrastructure (PostgreSQL 16, Redis 7, Keycloak 24)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 19:37:55 +01:00

2.1 KiB

tOS Test Infrastructure

Frontend (apps/web) - Vitest

Configuration

  • vitest.config.ts at project root of apps/web
  • Uses @vitejs/plugin-react for JSX transform
  • jsdom environment for DOM testing
  • globals: true so describe/it/expect are global
  • Path alias @ -> ./src matching tsconfig
  • CSS disabled in tests (css: false)
  • Setup file: src/test/setup.ts imports @testing-library/jest-dom/vitest

Dependencies (devDependencies)

  • vitest ^2.1.8
  • @testing-library/react ^16.1.0
  • @testing-library/jest-dom ^6.6.3
  • @testing-library/user-event ^14.5.2
  • @vitejs/plugin-react ^4.3.4
  • jsdom ^25.0.1

Test Files

  • src/lib/utils.test.ts - Tests for cn(), getInitials(), capitalize(), truncate(), safeJsonParse(), generateId(), isServer(), isClient()
  • src/components/ui/badge.test.tsx - Badge component rendering with all variants
  • src/hooks/use-toast.test.ts - Tests reducer logic and toast() function

Run Commands

pnpm --filter web test       # vitest run
pnpm --filter web test:watch # vitest (watch mode)

Backend (apps/api) - Jest

Configuration

  • Inline in package.json under "jest" key
  • ts-jest transform for TypeScript
  • Node test environment
  • Module alias: @/ -> <rootDir>/ (rootDir = src)
  • Test regex: .*\.spec\.ts$

Dependencies (already present)

  • jest ^29.7.0
  • ts-jest ^29.1.1
  • @nestjs/testing ^10.3.0
  • @types/jest ^29.5.11
  • supertest ^6.3.3

Test Files

  • src/health/health.controller.spec.ts - Health controller (check, liveness, readiness)
  • src/common/services/encryption.service.spec.ts - EncryptionService (encrypt/decrypt, objects, empty strings, generateKey, init)

Test Patterns for NestJS

  • Use Test.createTestingModule() for DI setup
  • Mock all dependencies with { provide: X, useValue: mockX }
  • Call module.get<T>(T) to get the instance under test
  • For services with onModuleInit(), call it manually in beforeEach
  • Use jest.clearAllMocks() in afterEach

Run Commands

pnpm --filter api test           # jest
pnpm --filter api test:watch     # jest --watch
pnpm --filter api test:cov       # jest --coverage