Writing & Running Tests in Bun

From the Bun cheat sheet · Test Runner · verified Jul 2026

Writing & Running Tests

Write Jest-compatible tests with describe, test, and expect

typescript
import { test, expect, describe } from "bun:test";

describe("math", () => {
  test("addition", () => {
    expect(2 + 2).toBe(4);
  });

  test("async", async () => {
    const res = await fetch("https://api.example.com");
    expect(res.ok).toBeTrue();
  });
});
💡 bun test is Jest-compatible — import from "bun:test" or keep existing Jest imports
⚡ Bun test runner is 10-40x faster than Jest with zero config for TypeScript
📌 Use test.skip() for tests not ready yet and test.todo() as a placeholder reminder
🟢 Run with bun test --watch to auto-rerun on file changes during development
testjestexpectdescribe

More Bun tasks

Back to the full Bun cheat sheet