bunfig.toml file under the [test] section.
Configuration options
Timeout
Set the default timeout for all tests (in milliseconds):Preload
Specify modules to load before running tests. This is useful for setting up global test utilities or mocking:Concurrency
Run tests concurrently by default:bun test --concurrent or marking individual tests with .concurrent().
Coverage
coverageSkipTestFiles
Exclude test files from coverage reports:true to exclude them.
coveragePathIgnorePatterns
Specify patterns to exclude from coverage:coverageThreshold
Set minimum coverage thresholds. Tests will fail if coverage is below these values:coverageReporter
Configure default coverage reporters:text- Human-readable text output to consolelcov- LCOV format (can be used with coverage visualization tools)
Root directory
Set the root directory for test discovery:Environment variables
You can also configure tests via environment variables:BUN_TEST_TIMEOUT
Set default test timeout:CI
WhenCI=true is set, Bun makes the following changes:
- Disables interactive snapshot updates
- Fails tests if new snapshots are created (unless
--update-snapshotsis used) - Changes error output formatting
Complete example
Here’s a comprehensivebunfig.toml configuration:
Per-directory configuration
You can have multiplebunfig.toml files in different directories. Bun will use the closest configuration file when running tests: