1. Import the runner
test, expect, and describe come from the built-in bun:test module — nothing to install.
import { test, expect, describe } from "bun:test";Typorithm · easy
Step 1 of 8 · intro card
bun:test
bun:test is Bun's built-in, zero-config runner. Import test, expect, and describe from "bun:test", write Jest-style assertions, and run them with bun test. Matchers like toBe, toEqual, and toThrow behave just like Jest's.
bun:test is Bun's built-in test runner: import test, expect, and describe from "bun:test", then run the suite with bun test — no Jest or Vitest install and no config file.
The expect API is Jest-compatible, so matchers like toBe (strict equality), toEqual (deep equality), and toThrow (asserts a function throws) all work exactly as you would expect.
Because the runner ships inside Bun and transpiles TypeScript directly, tests are fast to start and need zero setup before the first bun test.
Import test, expect, describe from "bun:test".
Run tests with bun test — zero config.
Jest matchers toBe, toEqual, toThrow all work.
import { test, expect, describe } from "bun:test";
describe("math", () => {
test("adds numbers", () => {
expect(2 + 2).toBe(4);
expect({ a: 1 }).toEqual({ a: 1 });
expect(() => { throw new Error("boom"); }).toThrow("boom");
});
});Connect each part of the code to the concept before you type.
test, expect, and describe come from the built-in bun:test module — nothing to install.
import { test, expect, describe } from "bun:test";describe groups related tests under a shared label for readable output.
describe("math", () => {toBe checks strict (===) equality, ideal for primitives like numbers.
expect(2 + 2).toBe(4);toEqual compares objects and arrays deeply by value, not by reference.
expect({ a: 1 }).toEqual({ a: 1 });toThrow asserts the wrapped function throws, optionally matching the message.
}).toThrow("boom");Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.