Skip to content

bun test CLI Usage

bash
bun test <patterns>

Execution Control

--timeoutnumber default: 5000
Set the per-test timeout in milliseconds (default 5000)
--rerun-eachnumber
Re-run each test file NUMBER times, helps catch certain bugs
--concurrentboolean
Treat all tests as test.concurrent() tests
--randomizeboolean
Run tests in random order
--seednumber
Set the random seed for test randomization
--bailnumber default: 1
Exit the test suite after NUMBER failures. If you do not specify a number, it defaults to 1.
--max-concurrencynumber default: 20
Maximum number of concurrent tests to execute at once (default 20)

Test Filtering

--todoboolean
Include tests that are marked with test.todo()
--test-name-patternstring
Run only tests with a name that matches the given regex. Alias: -t

Reporting

--reporterstring
Test output reporter format. Available: junit (requires --reporter-outfile), dots. Default: console output.
--reporter-outfilestring
Output file path for the reporter format (required with --reporter)
--dotsboolean
Enable dots reporter. Shorthand for --reporter=dots

Coverage

--coverageboolean
Generate a coverage profile
--coverage-reporterstring default: text
Report coverage in text and/or lcov. Defaults to text
--coverage-dirstring default: coverage
Directory for coverage files. Defaults to coverage

Snapshots

--update-snapshotsboolean
Update snapshot files. Alias: -u

Examples

Run all test files:

bash
bun test

Run all test files with "foo" or "bar" in the file name:

bash
bun test foo bar

Run all test files, only including tests whose names includes "baz":

bash
bun test --test-name-pattern baz