You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Backend services currently have little to no test coverage. Changes to business logic in AssetsService, AuthService, or ReportsService can introduce bugs that only surface in production. This issue establishes minimum coverage targets and writes tests for the highest-risk services.
Context
NestJS ships with Jest configuration out of the box — package.json already has the test script
Unit tests should mock the Repository using @golevelup/ts-jest or TypeORM's createMockRepository pattern
Integration tests (for services that hit the DB) should use a test PostgreSQL database via testcontainers-node
Coverage threshold: minimum 70% line coverage per service file
Acceptance Criteria
Configure Jest coverage thresholds in package.json jest config: branches: 70, lines: 70, functions: 80
Overview
Backend services currently have little to no test coverage. Changes to business logic in
AssetsService,AuthService, orReportsServicecan introduce bugs that only surface in production. This issue establishes minimum coverage targets and writes tests for the highest-risk services.Context
package.jsonalready has thetestscriptRepositoryusing@golevelup/ts-jestor TypeORM'screateMockRepositorypatterntestcontainers-nodeAcceptance Criteria
package.jsonjest config:branches: 70, lines: 70, functions: 80AuthService: register (duplicate email → 409), login (wrong password → 401), token refresh (expired token → 401)AssetsService: create asset (valid DTO creates record), update (returns updated data), delete (soft-deletes, audit log created)RolesGuard: ADMIN passes, USER blocked on ADMIN route (403), MANAGER passes on MANAGER routeAssetsService.findAll(): MANAGER only sees own-department assets, ADMIN sees alltest:covscript that fails CI if coverage drops below thresholds