Overview
This issue tracks the implementation of a comprehensive test suite for the entire syncup backend, covering all existing modules as well as any new modules added in future PRs.
Background
Raised during review of PR #22 (feat(tasks): Implement task CRUD API endpoints).
Original review comment: #22 (comment)
Requested by: @Zafar7645
Scope
Existing Modules to Cover
| Module |
Controller Spec |
Service Spec |
Notes |
auth |
auth.controller.spec.ts |
auth.service.spec.ts |
Already has basic spec; expand with full coverage |
users |
users.controller.spec.ts |
users.service.spec.ts |
Already has basic spec; expand with full coverage |
projects |
projects.controller.spec.ts |
projects.service.spec.ts |
Verify/expand coverage |
board-columns |
board-columns.controller.spec.ts |
board-columns.service.spec.ts |
Needs mocked providers; currently uses concrete service |
tasks |
tasks.controller.spec.ts |
tasks.service.spec.ts |
Needs mocked providers; currently uses concrete service |
Testing Standards to Follow
- Controller specs: Use
useValue mocks for all service dependencies (avoid injecting concrete services with TypeORM repository dependencies). Stub all public service methods with jest.fn().
- Service specs: Use
getRepositoryToken() and useValue mocks for all TypeORM repository dependencies.
- Coverage targets: Happy path + key error paths (e.g.,
NotFoundException, ForbiddenException, UnauthorizedException).
- Guard testing: Mock
JwtAuthGuard where needed in controller tests.
Future Modules
Any new module added to the project should include:
- A controller spec with mocked service providers.
- A service spec with mocked repository providers.
- Tests for all public methods covering both success and error cases.
Acceptance Criteria
Overview
This issue tracks the implementation of a comprehensive test suite for the entire syncup backend, covering all existing modules as well as any new modules added in future PRs.
Background
Raised during review of PR #22 (feat(tasks): Implement task CRUD API endpoints).
Original review comment: #22 (comment)
Requested by: @Zafar7645
Scope
Existing Modules to Cover
authauth.controller.spec.tsauth.service.spec.tsusersusers.controller.spec.tsusers.service.spec.tsprojectsprojects.controller.spec.tsprojects.service.spec.tsboard-columnsboard-columns.controller.spec.tsboard-columns.service.spec.tstaskstasks.controller.spec.tstasks.service.spec.tsTesting Standards to Follow
useValuemocks for all service dependencies (avoid injecting concrete services with TypeORM repository dependencies). Stub all public service methods withjest.fn().getRepositoryToken()anduseValuemocks for all TypeORM repository dependencies.NotFoundException,ForbiddenException,UnauthorizedException).JwtAuthGuardwhere needed in controller tests.Future Modules
Any new module added to the project should include:
Acceptance Criteria
useValuemocks instead of concrete service classes.getRepositoryToken().