v0.2.12 — portable toMatchSnapshot across bun and node; one test entrypoint
Everything since 0.2.11 (the last published release). Interim 0.2.12 and 0.2.13 were committed during development but never published, so their changes ship here under a single version rather than leaving npm with a gap.
Added
- Portable
toMatchSnapshotacross bun and node.@b9g/libuild/testnow installs one snapshot matcher that overrides each runtime's native/absent support, soexpect(value).toMatchSnapshot()writes and verifies the same.snapfiles on both platforms — previously it passed on bun (its native matcher) and threw on node (toMatchSnapshot is not a function). Snapshots live in__snapshots__/<file>.snapnext to the source test, in a jest-compatible format written and parsed withouteval. Strings are stored verbatim (the rendered-output case); other values serialize viapretty-format. Keys are the jest-style<describe > test> <n>, tracked by wrappingdescribe/test/it. Update stale snapshots withlibuild test -u(--update-snapshots). The exportedexpecttype now includestoMatchSnapshot, so it typechecks. Browsers have no filesystem, so theirtoMatchSnapshotthrows a clear "not supported on the browser platform" error (bun/node parity covers the use case). Adds apretty-formatdependency.
Changed (BREAKING)
- One public test entrypoint:
@b9g/libuild/test. The platform shims@b9g/libuild/test-bun,/test-node, and/test-browser(and their.jsaliases) are removed.test-bun/test-nodewere trivial wrappers overbun:testandnode:test+expect; they're collapsed into the single dispatcher, and the browser runner is now an internal chunk (_test-browser).@b9g/libuild/testdetects the runtime (typeof Bun/typeof process— a real browser has noprocess, which distinguishes it from node+jsdom) and loads the right backend directly, so bun/node use their own builtins rather than a libuild module. Consumers import from@b9g/libuild/testexactly as before — only the internal sub-paths are gone. - The test runner is now internal —
@b9g/libuild/test-runneris no longer a public export. It exposed the runner machinery plus a pile of helpers only meant for libuild's own unit tests (bundleTests,collectTests,parseTapOutput, etc.) and a deaddetectPlatforms(). Every public export is a liability; the runner was never a deliberate consumer contract. The public test surface remains@b9g/libuild/test(thedescribe/test/expectAPI).detectPlatforms()is removed.
Fixed
- Setup file now recognized for the
.spec.convention, not just.test.. Test discovery accepts both*.test.*and*.spec.*, but setup recognition only matchedtest-setup.test.*— so a.spec.-convention project'stest-setup.spec.tswas silently run as an ordinary (test-less) shard and set up nothing for the other files. Bothtest-setup.test.*andtest-setup.spec.*are now recognized. - Browser test bundles now build. The browser target was
es2020, which can't emit the top-levelawaitthe@b9g/libuild/testdispatcher now uses to select its backend — so-p chromium/firefox/webkitfailed to bundle. Bumped toes2022, which every Playwright-driven browser supports.
Removed
libuild test --watch— the flag was wired up but never did anything (a no-op). Removed rather than left advertising behavior it doesn't have.
Notes
--timeoutis per file (each file runs in its own process as of 0.2.10), not a whole-suite budget. Browser, which still runs a combined bundle, applies it per run.