Testing Overview
Balda.js provides comprehensive testing capabilities with support for multiple JavaScript runtimes and a powerful MockServer for testing HTTP endpoints without starting a real server.
Multi-Runtime Support
Balda.js supports testing across multiple JavaScript runtimes:
- Node.js - Primary runtime with full feature support
- Bun - Fast alternative runtime with native TypeScript support
- Deno - Modern runtime with built-in security features
Test Structure
test/
├── suite/ # Test suites for different features
│ ├── users.test.ts
│ ├── upload.test.ts
│ └── urlencoded.test.ts
├── controllers/ # Controller implementations for testing
│ ├── users.ts
│ ├── file_upload.ts
│ └── urlencoded.ts
├── server/ # Test server configuration
│ ├── instance.ts
│ └── index.ts
└── benchmark/ # Performance testing
└── index.ts
Running Tests
Node.js
# Run all tests
yarn test
# Run tests in watch mode
yarn test:watch
# Run tests with coverage
yarn test:coverage
Bun
# Run tests with Bun
yarn test:bun
Deno
# Run tests with Deno
yarn test:deno
Test Scripts
The project includes several test-related scripts:
test- Run tests with Vitesttest:watch- Run tests in watch modetest:coverage- Run tests with coverage reportingtest:bun- Run tests with Buntest:deno- Run tests with Denobenchmark- Run performance benchmarks
Pre-commit Testing
Tests are automatically run on pre-commit hooks across all supported runtimes to ensure compatibility and prevent regressions.
Next Steps
- MockServer Guide - Learn how to use MockServer for testing
- Testing Examples - Practical testing examples and patterns