bun-test
Built-in Jest-compatible test runner
TLDR
Run all tests
SYNOPSIS
bun test [options] [files]
DESCRIPTION
bun test is Bun's built-in test runner with a Jest-compatible API. It provides TypeScript and JSX support, snapshot testing, mocks, lifecycle hooks, and watch mode out of the box.
Tests execute with the Bun runtime, providing significantly improved performance over traditional JavaScript test runners.
PARAMETERS
--watch
Re-run tests on file changes--update-snapshots
Update snapshot files--coverage
Enable code coverage reporting--test-name-pattern pattern
Only run tests matching pattern--timeout ms
Test timeout in milliseconds--reporter type
Output format (default, junit, etc.)--reporter-outfile file
Write reporter output to file--bail n
Stop after n test failures--rerun-each n
Run each test n times
TEST FILE PATTERNS
The test runner searches for files matching:
- *.test.{js,jsx,ts,tsx}
- *_test.{js,jsx,ts,tsx}
- *.spec.{js,jsx,ts,tsx}
- *_spec.{js,jsx,ts,tsx}
API
Tests use describe, test/it, expect, beforeAll, beforeEach, afterEach, afterAll, and mock functions from bun:test module.
CAVEATS
While aiming for Jest compatibility, not all Jest features are implemented. GitHub Actions annotations are automatically enabled when running in CI. Some Jest-specific plugins may not work.
