Testing Strategy
We maintain a high standard of code quality through a three-tier testing strategy.
1. Unit Tests (tests/unit)
- Tool: Vitest
- Focus: Individual functions, services, and middlewares in isolation.
- Mocking: database calls and external dependencies are mocked.
2. Integration Tests (tests/integration)
- Tool: Vitest + MongoDB Memory Server (or local DB)
- Focus: API endpoints, database interactions, and service logic.
- Setup: Starts a real MongoDB instance (or container), seeds data, runs request via
supertest, and asserts the response and DB state.
3. End-to-End (E2E) Tests
- Tool: Bruno + Docker Compose
- Focus: Full system verification in a production-like environment.
- Flow:
docker compose -f docker-compose.test.yml up(Clean Mongo instance)- Start Backend with Test Config.
bru run --env e2e(Run Bruno Collection).- Teardown.
SonarQube & Coverage
We use SonarQube to track technical debt and code coverage. * Linting: Biome is strictly enforced. * Coverage: Must be maintained above the defined threshold (e.g. 80%).