Summary
@b9g/libuild/test unifies expect across runtimes, but snapshot matching isn't portable. Under bun, expect is bun:test's (has toMatchSnapshot); under node it's the expect package, which has no snapshot support without a host runner. So expect(x).toMatchSnapshot() passes on -p bun and fails on -p node with:
TypeError: expect(...).toMatchSnapshot is not a function
It also doesn't typecheck: the unified expect type is the union of the two, and the union has no toMatchSnapshot.
Why it matters
Snapshots are the natural way to test large rendered-output blobs (for termdom, multi-line terminal renders). Right now a project has to either drop snapshots or keep them bun-only, which defeats the point of a cross-platform runner.
Proposed
Provide a portable snapshot matcher in the libuild test layer, independent of the underlying runner:
expect(value).toMatchSnapshot() serializes value, stores it in a .snap file next to the test (or a __snapshots__ dir), and compares on subsequent runs.
- An update mode — env var (
LIBUILD_UPDATE_SNAPSHOTS=1) and/or a CLI flag (--update-snapshots / -u).
- Same behavior and same snapshot files across
bun, node, and browser platforms, so a snapshot written on one platform verifies on the others.
- Include
toMatchSnapshot in the exported expect type so consumers typecheck.
This is the same "unify the runtimes at the libuild layer" shape as the externalize (#12) and setup-file (#13) fixes.
Filed from termdom: ~11 tests across ~7 files snapshot rendered terminal output and currently pass on bun, fail on node.
Summary
@b9g/libuild/testunifiesexpectacross runtimes, but snapshot matching isn't portable. Under bun,expectis bun:test's (hastoMatchSnapshot); under node it's theexpectpackage, which has no snapshot support without a host runner. Soexpect(x).toMatchSnapshot()passes on-p bunand fails on-p nodewith:It also doesn't typecheck: the unified
expecttype is the union of the two, and the union has notoMatchSnapshot.Why it matters
Snapshots are the natural way to test large rendered-output blobs (for termdom, multi-line terminal renders). Right now a project has to either drop snapshots or keep them bun-only, which defeats the point of a cross-platform runner.
Proposed
Provide a portable snapshot matcher in the libuild test layer, independent of the underlying runner:
expect(value).toMatchSnapshot()serializesvalue, stores it in a.snapfile next to the test (or a__snapshots__dir), and compares on subsequent runs.LIBUILD_UPDATE_SNAPSHOTS=1) and/or a CLI flag (--update-snapshots/-u).bun,node, and browser platforms, so a snapshot written on one platform verifies on the others.toMatchSnapshotin the exportedexpecttype so consumers typecheck.This is the same "unify the runtimes at the libuild layer" shape as the externalize (#12) and setup-file (#13) fixes.
Filed from termdom: ~11 tests across ~7 files snapshot rendered terminal output and currently pass on bun, fail on node.