1.1 KiB
1.1 KiB
Testing
Running Tests
# 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
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', () => {
// ...
});
});