Skip to main content
You can configure Bun’s test runner behavior in your bunfig.toml file under the [test] section.

Configuration options

Timeout

Set the default timeout for all tests (in milliseconds):
This can be overridden per-test:

Preload

Specify modules to load before running tests. This is useful for setting up global test utilities or mocking:
Preloaded files run before any test files are loaded.

Concurrency

Run tests concurrently by default:
This is equivalent to running bun test --concurrent or marking individual tests with .concurrent().

Coverage

coverageSkipTestFiles

Exclude test files from coverage reports:
By default, test files are included in coverage reports. Set this to true to exclude them.

coveragePathIgnorePatterns

Specify patterns to exclude from coverage:
Patterns use glob syntax. Files matching any pattern will be excluded from coverage reports.

coverageThreshold

Set minimum coverage thresholds. Tests will fail if coverage is below these values:
All thresholds are percentages (0-100).

coverageReporter

Configure default coverage reporters:
Available reporters:
  • text - Human-readable text output to console
  • lcov - 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

When CI=true is set, Bun makes the following changes:
  • Disables interactive snapshot updates
  • Fails tests if new snapshots are created (unless --update-snapshots is used)
  • Changes error output formatting

Complete example

Here’s a comprehensive bunfig.toml configuration:

Per-directory configuration

You can have multiple bunfig.toml files in different directories. Bun will use the closest configuration file when running tests: