Skip to main content

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 in tests/utils/factories.ts:

Helpers

Located in tests/utils/test-helpers.ts:

Coverage Targets

Check coverage with:

Best Practices

Each test should be able to run in isolation. Use beforeEach to reset state.
Focus on what the function does, not how it does it.
Test names should describe the scenario and expected outcome.
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: