# CLI Usage

```bash
bun test <patterns>
```

### Execution Control

<ParamField path="--timeout" type="number" default="5000">
  Set the per-test timeout in milliseconds (default 5000)
</ParamField>

<ParamField path="--rerun-each" type="number">
  Re-run each test file <code>NUMBER</code> times to help catch certain bugs
</ParamField>

<ParamField path="--retry" type="number">
  Retry failed tests up to <code>NUMBER</code> times. Overridden by per-test <code>{`{ retry: N }`}</code>
</ParamField>

<ParamField path="--concurrent" type="boolean">
  Treat all tests as <code>test.concurrent()</code> tests
</ParamField>

<ParamField path="--randomize" type="boolean">
  Run tests in random order
</ParamField>

<ParamField path="--seed" type="number">
  Set the random seed for test randomization
</ParamField>

<ParamField path="--bail" type="number" default="1">
  Exit the test suite after <code>NUMBER</code> failures. If you do not specify a number, it defaults to 1.
</ParamField>

<ParamField path="--max-concurrency" type="number" default="20">
  Maximum number of concurrent tests to execute at once (default 20)
</ParamField>

### Test Filtering

<ParamField path="--todo" type="boolean">
  Include tests that are marked with <code>test.todo()</code>
</ParamField>

<ParamField path="--test-name-pattern" type="string">
  Run only tests with a name that matches the given regex. Alias: <code>-t</code>
</ParamField>

### Reporting

<ParamField path="--reporter" type="string">
  Test output reporter format. Available: <code>junit</code> (requires --reporter-outfile), <code>dots</code>. Default:
  console output.
</ParamField>

<ParamField path="--reporter-outfile" type="string">
  Output file path for the reporter format (required with --reporter)
</ParamField>

<ParamField path="--dots" type="boolean">
  Enable dots reporter. Shorthand for --reporter=dots
</ParamField>

### Coverage

<ParamField path="--coverage" type="boolean">
  Generate a coverage profile
</ParamField>

<ParamField path="--coverage-reporter" type="string" default="text">
  Report coverage in <code>text</code> and/or <code>lcov</code>. Defaults to <code>text</code>
</ParamField>

<ParamField path="--coverage-dir" type="string" default="coverage">
  Directory for coverage files. Defaults to <code>coverage</code>
</ParamField>

### Snapshots

<ParamField path="--update-snapshots" type="boolean">
  Update snapshot files. Alias: <code>-u</code>
</ParamField>

## Examples

Run all test files:

```bash terminal icon="terminal"
bun test
```

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

```bash terminal icon="terminal"
bun test foo bar
```

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

```bash terminal icon="terminal"
bun test --test-name-pattern baz
```
