CheckOps
Bun Test Runner
bun test is Bun's fast, built-in, Jest-compatible test runner with TypeScript and JSX support, lifecycle hooks, mocks, snapshots, DOM testing, coverage, watch mode and GitHub Actions annotations.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
Bun, the JavaScript runtime, ships with a fast, built-in, Jest-compatible test runner. Tests run in the Bun runtime and use a Jest-like API imported from bun:test. According to the documentation, it supports TypeScript and JSX, lifecycle hooks, snapshot testing, UI and DOM testing, watch mode with --watch and script preloading with --preload. Bun aims for Jest compatibility but notes that not everything is implemented and keeps a tracking issue for gaps.
bun test recursively finds files matching patterns such as *.test.ts, *_test.ts, *.spec.ts and *_spec.ts. You can filter by path or by test name with -t/--test-name-pattern. By default all tests run in a single process with a shared global, and --parallel spreads files across CPU cores. Inside GitHub Actions it automatically emits annotations with no configuration. The docs also cover mocks, dates and times, code coverage and reporters, and Bun itself is MIT-licensed.
Coverage is reported with bun test --coverage.
Features
- Jest-compatible API:
test,expect,describe, hooks and mocks frombun:test. - TypeScript and JSX: No separate transpilation step.
- Snapshots and DOM testing: Snapshot assertions and UI testing support.
- CI-friendly: Automatic GitHub Actions annotations, coverage and reporters.
Pros
- Free: Included with Bun at no cost.
- Fast startup: Built into the runtime with no extra tooling.
Cons
- Requires Bun: Tests run in the Bun runtime, which may differ from Node.js in production.
- Partial Jest compatibility: Some Jest APIs are not yet implemented; check the tracking issue.
Usage and Links (Example)
// math.test.ts
import { expect, test, mock } from "bun:test";
import { add } from "./math";
test("2 + 2", () => {
expect(add(2, 2)).toBe(4);
});
test("mock function", () => {
const fn = mock(() => 1);
fn();
expect(fn).toHaveBeenCalledTimes(1);
});
bun test
bun test --watch
bun test --coverage
Resources:
Pricing
Free and open source as part of Bun (MIT licence).
Recommended for?
- Projects already using Bun as runtime or package manager.
- Teams wanting very fast TypeScript tests with a familiar Jest API.
Conclusion
bun test brings a fast, zero-config, Jest-style runner to Bun projects, though teams deploying on Node.js should consider runtime differences.
Alternatives
Other tools on CheckOps that cover similar ground. Open a page, or compare one with Bun Test Runner side by side.
JJestJest is a free, open-source JavaScript test runner with zero-config defaults, mocks, and snapshot testing.Compare with Bun Test Runner
VVitestVitest is a free, open-source unit test runner that reuses a Vite project's config, transforms, and plugins.Compare with Bun Test Runner
NNode.js Test Runner (node:test)The Node.js test runner is the built-in `node:test` module, stable since Node.js 20, providing describe/it tests, mocking, snapshots, coverage and reporters with no extra dependencies.Compare with Bun Test Runner
DDeno Testdeno test is Deno's built-in test runner, with Deno.test, test steps, hooks, filtering, sanitizers, mocking and snapshots via the standard library, coverage, documentation tests and affected-test selection.Compare with Bun Test Runner
MMochaMocha is a long-running, MIT-licensed JavaScript test framework for Node.js and browsers, with BDD and TDD interfaces, async support, hooks, parallel mode and a large reporter ecosystem.Compare with Bun Test Runner
AAVAAVA is an MIT-licensed Node.js test runner that runs test files concurrently in separate worker processes, with a minimal API, clean output, built-in assertions and snapshot support.Compare with Bun Test Runner