Skip to content

Capability index

Stable

The fixture engine is the core; everything else on this page is a capability built on the same runner and the same explicit composition. Each row names the tier that governs it — read Stability, compatibility, and support for what a tier promises.

Capabilities

CapabilityUse it forTierPrerequisitesGuide
FixturesTyped values with a lifetime: databases, containers, users, clientsStableNoneThe fixture model
Standard fixturesIsolated tmpdir, env, stdio, clock, seed, and an armed networkGuardStableNoneDeterministic tests
Snapshot testingCompare a value, a file, or a callback result against a stored baselineStableNoneSnapshot testing
Property-based testingState an invariant and let fast-check generate inputs, then shrink failuresStablefast-checkProperty-based testing
Parameterized testsRun one body over a fixed matrix of named values through test.propStablefast-checkParameterized tests
HTTP mocking and test serversServe an ephemeral Bun.serve instance and intercept fetch with MSW-style handlersStableNoneHTTP mocking and test servers
Recording HTTP cassettesRecord real HTTP traffic and callback results, then replay them deterministicallyStableNoneRecording HTTP cassettes
DOM testingRender and query markup in-process with happy-domStablehappy-domDOM and browser testing
Browser testingDrive a real headless Chromium page through PlaywrightExperimentalplaywright + an installed Chromium buildDOM and browser testing
BDD scenariosWrite one test as fluent given / when / then steps that share typed stateExperimental@aboviq/bun-test-cucumberBDD scenarios

Everything above shares one rule: the capability is available where the runner you import has it, and a peer package is loaded only when a requested fixture actually needs it. A unit test that never mentions webPage never loads happy-dom, and a suite that never mentions browserPage never loads Playwright.

Built-in fixtures overview

The root test contributes these nineteen names. Request one by destructuring it; override one with an extension of the same name. Per-fixture members, scopes, and behaviours are in the Built-in fixture API.

AreaFixturesWhat they give a test
Standardtmpdir, env, stdio, clock, seed, networkGuardA temporary directory, a scoped environment, captured output streams, frozen time, a seeded Math.random, and a fetch guard — each restored at teardown.
DOMwindow, document, pageThe happy-dom window and document, plus a small helper for mounting, querying, and clicking.
Either backendwebPageOne page-shaped API that is happy-dom by default and Playwright when BUN_TEST_UTILS_WEB_ENV=browser.
Browser (experimental)browser, browserContext, browserPage, browserHttpMockA session-scoped Chromium, a per-test context and page, and httpMock handlers installed on that context.
Server and HTTPtestServer, serverUrl, httpMockAn ephemeral Bun.serve instance on a random port, its URL as a dependency, and MSW-style fetch handlers.
CassettescassetteCallback record/replay plus HTTP record/replay, with serializers.
SnapshotssnapshotValue, file, and callable snapshot assertions with serializers and modes.

Where to go next

Docs for bun-test-utils v0.1.0 Release notes Report a docs issue