(testOrName: string | (() => boolean), test?: () => boolean)
| 46 | export function expect(test: () => boolean): void; |
| 47 | export function expect(name: string, test: () => boolean): void; |
| 48 | export function expect(testOrName: string | (() => boolean), test?: () => boolean) { |
| 49 | // biome-ignore lint/style/noNonNullAssertion: test related, will remove soon with Vitest |
| 50 | const testFunc = typeof testOrName === 'function' ? (testOrName as () => boolean) : test!; |
| 51 | |
| 52 | const name = typeof testOrName === 'string' ? (testOrName as string) : null; |
| 53 | |
| 54 | if (testFunc()) { |
| 55 | successfulTests += 1; |
| 56 | return; // Success |
| 57 | } |
| 58 | |
| 59 | // Failed! |
| 60 | throw new Error(` |
| 61 | Test failed ${name ? `: ${name}` : ''} |
| 62 | ${testFunc.toString()} |
| 63 | |
| 64 | `); |
| 65 | } |
searching dependent graphs…