Skip to main content

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 Vitest
  • test:watch - Run tests in watch mode
  • test:coverage - Run tests with coverage reporting
  • test:bun - Run tests with Bun
  • test:deno - Run tests with Deno
  • benchmark - 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