Test Framework
Hitler uses Vitest for testing. Vitest is fast, compatible with Jest APIs, and works great with TypeScript.Running Tests
Test Structure
Writing Tests
Unit Tests
For pure functions without side effects:Using Test Factories
Create consistent test data with factories:Testing with Mocks
For tests that need external dependencies:Integration Tests
For testing services with mocked database:Test Utilities
Factories
Located intests/utils/factories.ts:
Helpers
Located intests/utils/test-helpers.ts:
Coverage Targets
| Package | Target | Why |
|---|---|---|
@hitler/rules | 95%+ | Pure business logic, critical |
@hitler/shared | 95%+ | Validation schemas, foundational |
@hitler/sdk | 75%+ | API client, external dependency |
@hitler/api | 70%+ | Service logic with mocked DB |
Best Practices
Keep tests independent
Keep tests independent
Each test should be able to run in isolation. Use
beforeEach to reset state.Test behavior, not implementation
Test behavior, not implementation
Focus on what the function does, not how it does it.
Use descriptive test names
Use descriptive test names
Test names should describe the scenario and expected outcome.
Avoid testing external libraries
Avoid testing external libraries
Don’t test that Zod validates correctly. Test your schemas work as expected.
Debugging Tests
Run a specific test file
Run tests matching a pattern
Verbose output
Debug in VS Code
Add this to.vscode/launch.json: