Testing Overview
The project uses multiple testing approaches:- Go Unit Tests: Test individual Go service components with
go test - Go Integration Tests: Test services with real dependencies (database, gRPC clients)
- Node.js Unit Tests: Test Node.js services with Vitest and supertest
- Smoke Tests: End-to-end tests that verify all services are working together
- Frontend Build: TypeScript type checking ensures type safety
Go Service Testing
Running Go Tests
Run all Go tests:Writing Unit Tests
Unit tests use mocks to isolate the service under test. Example:services/internal/greeter/service_test.go
Writing Integration Tests
Integration tests verify services work with real dependencies. Example:services/internal/greeter/service_integration_test.go
Test Best Practices
Use Table-Driven Tests
Mock External Dependencies
Test Error Cases
Use Context Timeouts
Node.js Service Testing
Running Node.js Tests
Run tests for a specific service:Writing Node.js Tests
Node.js services use Vitest and supertest for HTTP testing. Example:node-services/auth-service/__tests__/auth.test.js
Test Configuration
Add test configuration topackage.json:
vitest.config.js:
Smoke Tests
Smoke tests verify that all services are deployed and functioning correctly in a Kubernetes environment.Running Smoke Tests
Smoke tests require services to be running in Kubernetes:What Smoke Tests Verify
The smoke test script (scripts/smoke-test.sh) checks:
-
Deployment Health: All deployments are ready
-
HTTP Health Endpoints: Services respond to health checks
-
gRPC Functionality: gRPC services accept and respond to calls
-
Authentication Flow: Auth service can issue and verify tokens
Writing Custom Smoke Tests
Add checks toscripts/smoke-test.sh:
Frontend Testing
While the frontend doesn’t have traditional unit tests, it has type checking via TypeScript:CI/CD Testing
Tests run automatically in GitHub Actions:Pre-commit Testing
Tests run automatically on commit via git hooks:go test ./...- Runs before committing Go filesgolangci-lint run- Lints Go codebiome check- Lints TypeScript code
Common Testing Commands
See Also
- Debugging Guide - Debug failing tests and services
- Adding a Go Service - Learn about Go service structure
- Adding a Node.js Service - Learn about Node.js service structure