@zgeoff/bun-test-extended
v0.0.3
Published
jest-extended matchers for bun test, with working failure messages and bun-aware types
Readme
@zgeoff/bun-test-extended
jest-extended matchers for bun test, with working
failure messages and bun-aware types.
Plain expect.extend(matchers) breaks on bun: jest-extended destructures this.utils, bun's native
utils are brand-checked, so every failing assertion crashes with
Expected this to be instanceof ExpectMatcherUtils instead of printing a diff. This package wraps
each matcher in an adapter that supplies the real jest-matcher-utils and keeps this.equals
bound, then registers the lot.
Usage
# bunfig.toml — registers the matchers in every test file
[test]
preload = ["@zgeoff/bun-test-extended"]// tsconfig.json — loads the matcher types
{ "compilerOptions": { "types": ["bun", "@zgeoff/bun-test-extended"] } }test('it works', () => {
expect(['a', 'b']).toIncludeAllMembers(['b']);
expect({ n: 4 }).toEqual({ n: expect.toBeEven() });
});Types
- Augments
bun:testwith only the matchers bun doesn't already declare — no conflicts with builtins, and unknown matcher names fail typecheck (upstream's own types would let typos through). toResolve/toRejectreturnPromise<void>— un-awaited use is visible.- Asymmetric matchers (
expect.toBeOneOf(…)insidetoEqual) fit any value position.
Gaps
expect.pass/expect.fail are unimplemented upstream and excluded here.
