Testing
The BE Monorepo uses Bun’s built-in test runner for fast, integrated testing.Test Setup
Test Framework
Tests use Bun’s native test APIs with a Jest-like syntax:Test Location
Tests for the Hono app are located in:Environment Configuration
Tests run with development environment variables automatically loaded:Running Tests
From Repository Root
Run tests for the Hono app:bun test in the @workspace/hono workspace with the development environment file.
From App Directory
Navigate to the app and run tests directly:Watch Mode
Run tests in watch mode for continuous testing during development:Filtering Tests
Run specific test files:Test Patterns
API Endpoint Testing
Tests validate HTTP endpoints by making requests to the Hono app instance:Testing Utilities
Common test utilities are shared intests/util.ts:
Performance Testing
Tests can validate performance characteristics using theServer-Timing header:
Authentication Testing
Tests for authenticated endpoints are intests/llms-auth.test.ts.
Documentation Testing
Tests for documentation endpoints are intests/llms-docs.test.ts.
Test Structure
Organizing Tests
- One test file per feature/route: Keep tests focused and maintainable
- Shared utilities: Place common helpers in
tests/util.ts - Descriptive names: Use clear
describeanditblocks
Example Test Structure
Best Practices
Test Independence
- Each test should be independent and not rely on other tests
- Clean up resources after tests if needed
- Use fresh data for each test
Environment Variables
Tests use.env.dev for configuration. Ensure sensitive values are not committed:
Testing Workflow
When making changes:- Write or update tests
- Run tests locally:
bun run hono:test - Ensure all tests pass before committing
- CI will run tests automatically
Continuous Integration
Tests run automatically in CI as part of thelint-typecheck workflow:
