Get comfortable with Bun's built-in, Jest-compatible test runner.
0 / 5 completed
1 / 5
At standup, a dev wants to run unit tests without installing Jest or Vitest. Which Bun feature fits?
bun test is Bun's built-in test runner, compatible with much of the Jest API, requiring no separate test framework install. It discovers and runs *.test.ts files natively. This reduces toolchain setup for Bun projects.
2 / 5
During a design review, the team wants to replace a module's real implementation in a test. Which API do they use?
Bun's test runner provides mock() and spyOn() to replace functions or observe calls during a test, mirroring Jest's mocking API. This lets tests isolate units from real dependencies. Familiar Jest-style mocking eases migration to Bun's runner.
3 / 5
In a code review, a dev wants matching assertions like toBe and toEqual. Which function provides them?
Bun's expect() API supports the familiar Jest-style matcher chain, including toBe, toEqual, and toThrow. This compatibility lets existing Jest-style test suites often run with minimal changes. It is central to the runner's ergonomics.
4 / 5
An incident report shows CI test runs are far faster after migrating from another runner to Bun. What mainly explains this?
Bun's test runner benefits from Bun's fast native startup and execution model, often significantly cutting total run time versus JIT-heavy Node-based runners. This speed is one of the main draws for adopting bun test. It particularly helps large suites with many small test files.
5 / 5
During a PR review, a teammate wants coverage reporting from the test run. Which flag enables it?
Passing --coverage to bun test generates code coverage reporting for the run. This helps teams track how much of the codebase is exercised by tests. It is a built-in flag, not a separate dependency.