-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Expand file tree
/
Copy pathbun-test.d.ts
More file actions
57 lines (50 loc) · 2.01 KB
/
bun-test.d.ts
File metadata and controls
57 lines (50 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
declare module "bun:test" {
type AnyFunction = (...args: any[]) => any
interface MockMetadata<TArgs extends unknown[]> {
calls: TArgs[]
}
interface MockFunction<TFunction extends AnyFunction = AnyFunction> {
(...args: Parameters<TFunction>): ReturnType<TFunction>
mock: MockMetadata<Parameters<TFunction>>
mockClear(): void
mockReset(): void
mockRestore(): void
mockReturnValue(value: ReturnType<TFunction>): void
mockResolvedValue(value: Awaited<ReturnType<TFunction>>): void
mockImplementation(fn: TFunction): MockFunction<TFunction>
}
export function describe(name: string, fn: () => void): void
export function test(name: string, fn: () => void | Promise<void>): void
export function it(name: string, fn: () => void | Promise<void>): void
export function beforeEach(fn: () => void | Promise<void>): void
export function afterEach(fn: () => void | Promise<void>): void
export function beforeAll(fn: () => void | Promise<void>): void
export function afterAll(fn: () => void | Promise<void>): void
export function mock<TFunction extends AnyFunction>(fn: TFunction): MockFunction<TFunction>
export function spyOn<TObject extends object>(
object: TObject,
key: keyof TObject,
): MockFunction<AnyFunction>
export namespace mock {
function module(modulePath: string, factory: () => Record<string, unknown>): void
function restore(): void
}
interface Matchers {
toBe(expected: unknown): void
toBeDefined(): void
toBeUndefined(): void
toBeNull(): void
toEqual(expected: unknown): void
toContain(expected: unknown): void
toMatch(expected: RegExp | string): void
toHaveLength(expected: number): void
toHaveBeenCalled(): void
toHaveBeenCalledTimes(expected: number): void
toHaveBeenCalledWith(...expected: unknown[]): void
toBeGreaterThan(expected: number): void
toThrow(expected?: RegExp | string): void
toStartWith(expected: string): void
not: Matchers
}
export function expect(received: unknown): Matchers
}