CheckOps home

Tools directory

B

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.

Visit website

Latest public signals

Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.

Visit Website

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

  1. Jest-compatible API: test, expect, describe, hooks and mocks from bun:test.
  2. TypeScript and JSX: No separate transpilation step.
  3. Snapshots and DOM testing: Snapshot assertions and UI testing support.
  4. CI-friendly: Automatic GitHub Actions annotations, coverage and reporters.

Pros

  1. Free: Included with Bun at no cost.
  2. Fast startup: Built into the runtime with no extra tooling.

Cons

  1. Requires Bun: Tests run in the Bun runtime, which may differ from Node.js in production.
  2. Partial Jest compatibility: Some Jest APIs are not yet implemented; check the tracking issue.
// 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).

  1. Projects already using Bun as runtime or package manager.
  2. 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.