Replies: 1 comment
-
Unfortunately this is not possible - please see #18199 A workaround I personally suggest is the following import {expect} from 'bun:test';
export function toBeTruthy(value: unknown): asserts value {
expect(value).toBeTruthy();
} TypeScript only allows the assertion to exist on the function accepting the argument that is being asserted directly, rather than on a returned value (e.g. the Matchers interface which has |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When writing tests I frequently find myself repeating myself in order to get the
bun:test
expect
call and the TypeScript compiler on the same page...Example:
This makes the
expect
call rather redundant... It would be nice to be able to omit theif (!data) throw
here in place of the expect call, as one might do in a plain JS test. I guess when writing Bun tests in TypeScript I should just throw and not bother with theexpect
call?Beta Was this translation helpful? Give feedback.
All reactions