Files
kooltab-backoffice/docs/testing.md
T
2026-09-19 22:19:35 +02:00

56 lines
1.1 KiB
Markdown

# Testing
## Running Tests
```bash
# All unit tests
pnpm test
# E2E tests
pnpm test:e2e
# Specific test file
cd apps/api
npx jest --testPathPattern="auth.service.spec.ts"
```
## Test Structure
### Unit Tests
Located in `apps/api/src/` alongside source files with `.spec.ts` suffix.
- Authentication service tests
- Device token generation and validation
- Command creation and acknowledgement
- Venue isolation enforcement
- Rate limiting
### Integration/E2E Tests
Located in `apps/api/test/` with `.e2e-spec.ts` suffix.
- Login flow
- Device registration and sync
- Command lifecycle (create → sync → ack)
- Device revocation
- Cross-venue access prevention
## Writing Tests
```typescript
import { Test, TestingModule } from '@nestjs/testing';
import { AuthService } from './auth.service';
describe('AuthService', () => {
let service: AuthService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [AuthService, /* mocks */],
}).compile();
service = module.get<AuthService>(AuthService);
});
it('should generate valid device tokens', () => {
// ...
});
});
```