bunli test command runs tests for your CLI using Bun’s built-in test runner. It supports watch mode, coverage reporting, and workspace testing across multiple packages.
Usage
Basic Examples
Options
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
--pattern | -p | string | string[] | - | Test file patterns |
--watch | -w | boolean | false | Watch for changes |
--coverage | -c | boolean | false | Generate coverage report |
--bail | -b | boolean | false | Stop on first failure |
--timeout | - | number | - | Test timeout in milliseconds |
--all | - | boolean | false | Run tests in all packages (workspace mode) |
Test Patterns
By default, Bunli runs tests matching**/*.test.ts. You can customize patterns:
bunli.config.ts:
Workspace Mode
In monorepo setups, test all packages with--all:
Test Runner Implementation
The test command delegates to Bun’s test runner:Using @bunli/test
The@bunli/test package provides utilities for testing CLI commands:
Installation
Testing Commands
UsetestCommand to test individual commands:
Test Options
ThetestCommand function accepts comprehensive test options:
Mock Helpers
Use helper functions to create test options:Validation Testing
Test validation retry behavior:Matchers
Use built-in matchers to assert test results:Test Command Implementation
ThetestCommand function provides a complete mock environment:
Test Result Interface
Test results include comprehensive information:Example Test Suite
Configuration
Configure testing inbunli.config.ts:
Output Example
Environment Variables
The test command setsNODE_ENV to test:
See Also
- Development Mode - Run tests in watch mode during development
- Building - Run tests before building