Skip to content

Troubleshooting

StableSince v0.1.0

Organised by what you observe. Fixture-specific errors have their own page: Debugging fixture failures.

Setup: nothing runs at all

SymptomCauseFix
Cannot find package "@archont561/bun-test-utils"The package is not installed in the project that runs the test, or the command ran in a different directorybun add -d @archont561/bun-test-utils beside the package.json that owns the test
Tests pass, but session-scoped fixtures never tear downThe preload from test-utils init is missing from bunfig.toml, so the run has no teardown hooksbunx test-utils init --yes, then check [test].preload
A fixture “does not exist” that you can see in another fileThe test imports bun:test or the package instead of the composed runnerImport the runner module: import { test } from "./test"
The same fixture name behaves differently in two filesOne file imports an extended runner, the other the parentSibling modules do not share fixtures; import the runner that has the fixture you need
test-utils: command not foundThe CLI is run from the repo root without bunx, or the package is not installedbunx test-utils <command> from the project directory
Fixtures are not discovered from the file tree, as expectedBy design: composition is explicitImport the test.extend() chain — see Composition and overrides

Setup: a capability refuses to start

Each message names the exact install command.

ErrorCapabilityFix
'happy-dom' is required for DOM fixtures. Install via 'bun add -d happy-dom'.DOM fixtures, default webPage backendbun add -d happy-dom
'playwright' is required for browser fixtures. Install via 'bun add -d playwright'.Browser fixturesbun add -d playwright
test.prop() requires 'fast-check'. Install via 'bun add -d fast-check'.Property testsbun add -d fast-check
test.scenario() requires '@aboviq/bun-test-cucumber'. Install via 'bun add -d @aboviq/bun-test-cucumber'.BDD scenariosbun add -d @aboviq/bun-test-cucumber
FIXTURE_SETUP_FAILED: “No browser is available — both the headless shell and the full chromium build failed to launch.”Browser fixturesbunx playwright install chromium (the message names this repository’s alias, not a consumer command)
The same error on Linux with a launch failure unrelated to a missing fileBrowser fixtures, missing system librariesbunx playwright install --with-deps chromium, or use Playwright’s container

All four peer errors carry the code MISSING_OPTIONAL_DEPENDENCY; the browser launch failure carries FIXTURE_SETUP_FAILED with the original error as cause.

Runtime: network and time

SymptomCauseFix
networkGuard blocked unexpected fetch: GET https://…The test requested networkGuard and fetched a URL it never allowedAllow it deterministically, or mock it — see matchers
A mock never matchesA bare origin string such as "https://api.example.com" is compared as a whole URLUse "/api/user", a RegExp, or the full URL
A mocked URL still throws a guard errorhttpMock is listed before networkGuard, so the guard wraps the mockList httpMock after networkGuard
A test reaches the network in CI and failsNothing intercepts it: no mock and no guardMock it with httpMock, or record it as a cassette
Time is real again in the middle of a testThe clock fixture was not requested by that testDestructure clock; the fixture is test-scoped, not global
A test passes alone and fails in a fileState is leaking through a file- or session-scoped fixtureMove the mutated state to test scope, or reset it in the shared fixture’s teardown

Runtime: cassettes and snapshots

SymptomCauseFix
CASSETTE_NOT_FOUNDReplay mode with no cassette for the testRecord it: run without VCR_MODE=replay, or clear and re-record
CASSETTE_MISMATCHThe request is not in the existing cassette: method or full URL changedClear the test’s recording, run again to record, review the diff
A testServer cassette never replaysThe URL contains the random port, which changes every runRecord against a stable URL, or use httpMock for local endpoints
CASSETTE_NOT_FOUND only in CICI makes auto refuse to recordRecord locally, commit __cassettes__/, then push — see CI-safe cassettes
A snapshot is never writtenCI is set, or SNAPSHOT_MODE=ciUnset CI or use SNAPSHOT_MODE=update for the recording run
A snapshot mismatch after an intended changeThe baseline is staleRead the diff, then clear one test’s snapshot and re-record it
CALLBACK_NOT_RECORDEDThe callback body changed, so its source text no longer matchesRe-record the callback, and review the sidecar diff
CALLBACK_AMBIGUOUSOne source text was recorded from two different closuresReplay the closure you recorded, or give each one its own function
CALLBACK_NOT_SERIALIZABLEThe callback returned something that is not plain dataConvert the value inside the callback, or register a serializer
CALLBACK_SERIALIZER_NOT_FOUNDA recording needs a serializer name and version that is not registeredRegister the exact serializer, or clear and re-record
CALLBACK_STORE_INVALIDThe .callbacks.json sidecar is corruptDelete the sidecar; the next recording run rewrites it

CI

SymptomCauseFix
Browser tests fail only on CIThe Chromium build or its shared libraries are missing on the runnerbunx playwright install --with-deps chromium before the test step, and cache ~/.cache/ms-playwright — see Browser tests in CI
Cassettes fail with a missing recordingThe cassette was never committed, or was cleared locallyCommit __cassettes__/; git checkout -- <path> restores one deleted by mistake
A snapshot test fails with “missing snapshot”The baseline is not committedCommit __snapshots__/ with the change that produced it
Tests pass locally and fail on CI with different timingsReal time or real randomness in the testRequest clock and seed — see Deterministic tests
Windows runners failWindows is not supported in 0.1.xRun the suite on Linux or macOS; Windows support is planned

Platform and version

SymptomCauseFix
An unexpected Bun API errorBun older than 1.1.0Upgrade Bun; the supported range is in the package’s engines field
Import errors from a subpath such as /snapThe subpath is helper-only and exports no runnerImport fixtures from the package root; the subpaths export typed definitions and serializer contracts — see Imports
A capability behaves differently after an upgradeIt is experimental (browser or BDD)Read Release notes and Stability, compatibility, and support

Still blocked?

  1. Reproduce with BUN_TEST_UTILS_DEBUG=1 bun test <file> to see engine diagnostics.
  2. Check the error’s code in the error-code list.
  3. Reduce the file to one test and one fixture. If the failure survives that, it is a bug worth reporting.
  4. Open a bug report with bun --version, the OS, the code, and the full output. The page footer has a pre-filled link for documentation problems.

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