Unit Testing Standards
Principles
Unit tests verify the correctness of isolated business logic without requiring database connections, external APIs, or network sockets.
Requirements
-
New Services Require Tests:
- Every service file introduced in a pull request must have a corresponding test file (e.g.
OrderService.test.tsorOrderService.spec.ts). - Services hold domain business logic, which represents the highest ROI for unit tests.
- Enforced by rule
TEST-001.
- Every service file introduced in a pull request must have a corresponding test file (e.g.
-
Complex Logic Must Have Dedicated Test Cases:
- Methods containing extensive branching, loops, or complex business calculations (>15 lines) must have targeted test cases covering boundary conditions.
- Enforced by rule
TEST-002.
-
No Disabled Tests to Pass CI:
- Tests must not be bypassed or ignored using
.skip,xit, orxdescribeto force CI checks to pass. - Enforced by rule
TEST-004.
- Tests must not be bypassed or ignored using