bun-types 1.0.25 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/test.d.ts ADDED
@@ -0,0 +1,1903 @@
1
+ /**
2
+ *
3
+ * To run tests, run `bun test`
4
+ *
5
+ * @example
6
+ *
7
+ * ```bash
8
+ * $ bun test
9
+ * ```
10
+ *
11
+ * @example
12
+ * ```bash
13
+ * $ bun test <filename>
14
+ * ```
15
+ */
16
+ declare module "bun:test" {
17
+ /**
18
+ * -- Mocks --
19
+ */
20
+ export type Mock<T extends (...args: any[]) => any> = JestMock.Mock<T>;
21
+
22
+ export const mock: {
23
+ <T extends (...args: any[]) => any>(Function?: T): Mock<T>;
24
+
25
+ /**
26
+ * Replace the module `id` with the return value of `factory`.
27
+ *
28
+ * This is useful for mocking modules.
29
+ *
30
+ * @param id module ID to mock
31
+ * @param factory a function returning an object that will be used as the exports of the mocked module
32
+ *
33
+ * @example
34
+ * ## Example
35
+ * ```ts
36
+ * import { mock } from "bun:test";
37
+ *
38
+ * mock.module("fs/promises", () => {
39
+ * return {
40
+ * readFile: () => Promise.resolve("hello world"),
41
+ * };
42
+ * });
43
+ *
44
+ * import { readFile } from "fs/promises";
45
+ *
46
+ * console.log(await readFile("hello.txt", "utf8")); // hello world
47
+ * ```
48
+ *
49
+ * ## More notes
50
+ *
51
+ * If the module is already loaded, exports are overwritten with the return
52
+ * value of `factory`. If the export didn't exist before, it will not be
53
+ * added to existing import statements. This is due to how ESM works.
54
+ */
55
+ module(id: string, factory: () => any): void | Promise<void>;
56
+ /**
57
+ * Restore the previous value of mocks.
58
+ */
59
+ restore(): void;
60
+ };
61
+
62
+ /**
63
+ * Control the system time used by:
64
+ * - `Date.now()`
65
+ * - `new Date()`
66
+ * - `Intl.DateTimeFormat().format()`
67
+ *
68
+ * In the future, we may add support for more functions, but we haven't done that yet.
69
+ *
70
+ * @param now The time to set the system time to. If not provided, the system time will be reset.
71
+ * @returns `this`
72
+ * @since v0.6.13
73
+ *
74
+ * ## Set Date to a specific time
75
+ *
76
+ * ```js
77
+ * import { setSystemTime } from 'bun:test';
78
+ *
79
+ * setSystemTime(new Date('2020-01-01T00:00:00.000Z'));
80
+ * console.log(new Date().toISOString()); // 2020-01-01T00:00:00.000Z
81
+ * ```
82
+ * ## Reset Date to the current time
83
+ *
84
+ * ```js
85
+ * import { setSystemTime } from 'bun:test';
86
+ *
87
+ * setSystemTime();
88
+ * ```
89
+ */
90
+ export function setSystemTime(now?: Date | number): ThisType<void>;
91
+
92
+ interface Jest {
93
+ restoreAllMocks(): void;
94
+ fn<T extends (...args: any[]) => any>(func?: T): Mock<T>;
95
+ }
96
+ export const jest: Jest;
97
+ export namespace jest {
98
+ /**
99
+ * Constructs the type of a mock function, e.g. the return type of `jest.fn()`.
100
+ */
101
+ type Mock<T extends (...args: any[]) => any = (...args: any[]) => any> = JestMock.Mock<T>;
102
+ /**
103
+ * Wraps a class, function or object type with Jest mock type definitions.
104
+ */
105
+ // type Mocked<T extends object> = JestMock.Mocked<T>;
106
+ /**
107
+ * Wraps a class type with Jest mock type definitions.
108
+ */
109
+ // type MockedClass<T extends JestMock.ClassLike> = JestMock.MockedClass<T>;
110
+ /**
111
+ * Wraps a function type with Jest mock type definitions.
112
+ */
113
+ // type MockedFunction<T extends (...args: any[]) => any> = JestMock.MockedFunction<T>;
114
+ /**
115
+ * Wraps an object type with Jest mock type definitions.
116
+ */
117
+ // type MockedObject<T extends object> = JestMock.MockedObject<T>;
118
+ /**
119
+ * Constructs the type of a replaced property.
120
+ */
121
+ type Replaced<T> = JestMock.Replaced<T>;
122
+ /**
123
+ * Constructs the type of a spied class or function.
124
+ */
125
+ type Spied<T extends JestMock.ClassLike | ((...args: any[]) => any)> = JestMock.Spied<T>;
126
+ /**
127
+ * Constructs the type of a spied class.
128
+ */
129
+ type SpiedClass<T extends JestMock.ClassLike> = JestMock.SpiedClass<T>;
130
+ /**
131
+ * Constructs the type of a spied function.
132
+ */
133
+ type SpiedFunction<T extends (...args: any[]) => any> = JestMock.SpiedFunction<T>;
134
+ /**
135
+ * Constructs the type of a spied getter.
136
+ */
137
+ type SpiedGetter<T> = JestMock.SpiedGetter<T>;
138
+ /**
139
+ * Constructs the type of a spied setter.
140
+ */
141
+ type SpiedSetter<T> = JestMock.SpiedSetter<T>;
142
+ }
143
+
144
+ export function spyOn<T extends object, K extends keyof T>(
145
+ obj: T,
146
+ methodOrPropertyValue: K,
147
+ ): Mock<T[K] extends (...args: any[]) => any ? T[K] : never>;
148
+
149
+ /**
150
+ * Describes a group of related tests.
151
+ *
152
+ * @example
153
+ * function sum(a, b) {
154
+ * return a + b;
155
+ * }
156
+ * describe("sum()", () => {
157
+ * test("can sum two values", () => {
158
+ * expect(sum(1, 1)).toBe(2);
159
+ * });
160
+ * });
161
+ *
162
+ * @param label the label for the tests
163
+ * @param fn the function that defines the tests
164
+ */
165
+ export interface Describe {
166
+ (label: string, fn: () => void): void;
167
+ /**
168
+ * Skips all other tests, except this group of tests.
169
+ *
170
+ * @param label the label for the tests
171
+ * @param fn the function that defines the tests
172
+ */
173
+ only(label: string, fn: () => void): void;
174
+ /**
175
+ * Skips this group of tests.
176
+ *
177
+ * @param label the label for the tests
178
+ * @param fn the function that defines the tests
179
+ */
180
+ skip(label: string, fn: () => void): void;
181
+ /**
182
+ * Marks this group of tests as to be written or to be fixed.
183
+ *
184
+ * @param label the label for the tests
185
+ * @param fn the function that defines the tests
186
+ */
187
+ todo(label: string, fn?: () => void): void;
188
+ /**
189
+ * Runs this group of tests, only if `condition` is true.
190
+ *
191
+ * This is the opposite of `describe.skipIf()`.
192
+ *
193
+ * @param condition if these tests should run
194
+ */
195
+ if(condition: boolean): (label: string, fn: () => void) => void;
196
+ /**
197
+ * Skips this group of tests, if `condition` is true.
198
+ *
199
+ * @param condition if these tests should be skipped
200
+ */
201
+ skipIf(condition: boolean): (label: string, fn: () => void) => void;
202
+ /**
203
+ * Returns a function that runs for each item in `table`.
204
+ *
205
+ * @param table Array of Arrays with the arguments that are passed into the test fn for each row.
206
+ */
207
+
208
+ each<T extends Readonly<[any, ...any[]]>>(
209
+ table: readonly T[],
210
+ ): (label: string, fn: (...args: [...T]) => void | Promise<unknown>, options?: number | TestOptions) => void;
211
+ each<T extends any[]>(
212
+ table: readonly T[],
213
+ ): (label: string, fn: (...args: Readonly<T>) => void | Promise<unknown>, options?: number | TestOptions) => void;
214
+ each<T>(
215
+ table: T[],
216
+ ): (label: string, fn: (...args: T[]) => void | Promise<unknown>, options?: number | TestOptions) => void;
217
+ }
218
+ /**
219
+ * Describes a group of related tests.
220
+ *
221
+ * @example
222
+ * function sum(a, b) {
223
+ * return a + b;
224
+ * }
225
+ * describe("sum()", () => {
226
+ * test("can sum two values", () => {
227
+ * expect(sum(1, 1)).toBe(2);
228
+ * });
229
+ * });
230
+ *
231
+ * @param label the label for the tests
232
+ * @param fn the function that defines the tests
233
+ */
234
+ export const describe: Describe;
235
+ /**
236
+ * Runs a function, once, before all the tests.
237
+ *
238
+ * This is useful for running set up tasks, like initializing
239
+ * a global variable or connecting to a database.
240
+ *
241
+ * If this function throws, tests will not run in this file.
242
+ *
243
+ * @example
244
+ * let database;
245
+ * beforeAll(async () => {
246
+ * database = await connect("localhost");
247
+ * });
248
+ *
249
+ * @param fn the function to run
250
+ */
251
+ export function beforeAll(fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void)): void;
252
+ /**
253
+ * Runs a function before each test.
254
+ *
255
+ * This is useful for running set up tasks, like initializing
256
+ * a global variable or connecting to a database.
257
+ *
258
+ * If this function throws, the test will not run.
259
+ *
260
+ * @param fn the function to run
261
+ */
262
+ export function beforeEach(fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void)): void;
263
+ /**
264
+ * Runs a function, once, after all the tests.
265
+ *
266
+ * This is useful for running clean up tasks, like closing
267
+ * a socket or deleting temporary files.
268
+ *
269
+ * @example
270
+ * let database;
271
+ * afterAll(async () => {
272
+ * if (database) {
273
+ * await database.close();
274
+ * }
275
+ * });
276
+ *
277
+ * @param fn the function to run
278
+ */
279
+ export function afterAll(fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void)): void;
280
+ /**
281
+ * Runs a function after each test.
282
+ *
283
+ * This is useful for running clean up tasks, like closing
284
+ * a socket or deleting temporary files.
285
+ *
286
+ * @param fn the function to run
287
+ */
288
+ export function afterEach(fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void)): void;
289
+ export interface TestOptions {
290
+ /**
291
+ * Sets the timeout for the test in milliseconds.
292
+ *
293
+ * If the test does not complete within this time, the test will fail with:
294
+ * ```ts
295
+ * 'Timeout: test {name} timed out after 5000ms'
296
+ * ```
297
+ *
298
+ * @default 5000 // 5 seconds
299
+ */
300
+ timeout?: number;
301
+ /**
302
+ * Sets the number of times to retry the test if it fails.
303
+ *
304
+ * @default 0
305
+ */
306
+ retry?: number;
307
+ /**
308
+ * Sets the number of times to repeat the test, regardless of whether it passed or failed.
309
+ *
310
+ * @default 0
311
+ */
312
+ repeats?: number;
313
+ }
314
+ /**
315
+ * Runs a test.
316
+ *
317
+ * @example
318
+ * test("can check if using Bun", () => {
319
+ * expect(Bun).toBeDefined();
320
+ * });
321
+ *
322
+ * test("can make a fetch() request", async () => {
323
+ * const response = await fetch("https://example.com/");
324
+ * expect(response.ok).toBe(true);
325
+ * });
326
+ *
327
+ * test("can set a timeout", async () => {
328
+ * await Bun.sleep(100);
329
+ * }, 50); // or { timeout: 50 }
330
+ *
331
+ * @param label the label for the test
332
+ * @param fn the test function
333
+ * @param options the test timeout or options
334
+ */
335
+ export interface Test {
336
+ (
337
+ label: string,
338
+ fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
339
+ /**
340
+ * - If a `number`, sets the timeout for the test in milliseconds.
341
+ * - If an `object`, sets the options for the test.
342
+ * - `timeout` sets the timeout for the test in milliseconds.
343
+ * - `retry` sets the number of times to retry the test if it fails.
344
+ * - `repeats` sets the number of times to repeat the test, regardless of whether it passed or failed.
345
+ */
346
+ options?: number | TestOptions,
347
+ ): void;
348
+ /**
349
+ * Skips all other tests, except this test when run with the `--only` option.
350
+ *
351
+ * @param label the label for the test
352
+ * @param fn the test function
353
+ * @param options the test timeout or options
354
+ */
355
+ only(
356
+ label: string,
357
+ fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
358
+ options?: number | TestOptions,
359
+ ): void;
360
+ /**
361
+ * Skips this test.
362
+ *
363
+ * @param label the label for the test
364
+ * @param fn the test function
365
+ * @param options the test timeout or options
366
+ */
367
+ skip(
368
+ label: string,
369
+ fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
370
+ options?: number | TestOptions,
371
+ ): void;
372
+ /**
373
+ * Marks this test as to be written or to be fixed.
374
+ *
375
+ * When a test function is passed, it will be marked as `todo` in the test results
376
+ * as long the test does not pass. When the test passes, the test will be marked as
377
+ * `fail` in the results; you will have to remove the `.todo` or check that your test
378
+ * is implemented correctly.
379
+ *
380
+ * @param label the label for the test
381
+ * @param fn the test function
382
+ * @param options the test timeout or options
383
+ */
384
+ todo(
385
+ label: string,
386
+ fn?: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
387
+ options?: number | TestOptions,
388
+ ): void;
389
+ /**
390
+ * Runs this test, if `condition` is true.
391
+ *
392
+ * This is the opposite of `test.skipIf()`.
393
+ *
394
+ * @param condition if the test should run
395
+ */
396
+ if(
397
+ condition: boolean,
398
+ ): (
399
+ label: string,
400
+ fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
401
+ options?: number | TestOptions,
402
+ ) => void;
403
+ /**
404
+ * Skips this test, if `condition` is true.
405
+ *
406
+ * @param condition if the test should be skipped
407
+ */
408
+ skipIf(
409
+ condition: boolean,
410
+ ): (
411
+ label: string,
412
+ fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
413
+ options?: number | TestOptions,
414
+ ) => void;
415
+ /**
416
+ * Returns a function that runs for each item in `table`.
417
+ *
418
+ * @param table Array of Arrays with the arguments that are passed into the test fn for each row.
419
+ */
420
+ each<T extends Readonly<[any, ...any[]]>>(
421
+ table: readonly T[],
422
+ ): (label: string, fn: (...args: [...T]) => void | Promise<unknown>, options?: number | TestOptions) => void;
423
+ each<T extends any[]>(
424
+ table: readonly T[],
425
+ ): (label: string, fn: (...args: Readonly<T>) => void | Promise<unknown>, options?: number | TestOptions) => void;
426
+ each<T>(
427
+ table: T[],
428
+ ): (label: string, fn: (...args: T[]) => void | Promise<unknown>, options?: number | TestOptions) => void;
429
+ }
430
+ /**
431
+ * Runs a test.
432
+ *
433
+ * @example
434
+ * test("can check if using Bun", () => {
435
+ * expect(Bun).toBeDefined();
436
+ * });
437
+ *
438
+ * test("can make a fetch() request", async () => {
439
+ * const response = await fetch("https://example.com/");
440
+ * expect(response.ok).toBe(true);
441
+ * });
442
+ *
443
+ * @param label the label for the test
444
+ * @param fn the test function
445
+ */
446
+ export const test: Test;
447
+ export { test as it };
448
+
449
+ /**
450
+ * Asserts that a value matches some criteria.
451
+ *
452
+ * @link https://jestjs.io/docs/expect#reference
453
+ * @example
454
+ * expect(1 + 1).toBe(2);
455
+ * expect([1,2,3]).toContain(2);
456
+ * expect(null).toBeNull();
457
+ *
458
+ * @param actual The actual (received) value
459
+ */
460
+ export const expect: Expect;
461
+
462
+ type ExpectNot = Omit<AsymmetricMatchers, keyof AsymmetricMatchersBuiltin> & AsymmetricMatchersBuiltinNegated;
463
+
464
+ export interface Expect extends AsymmetricMatchers {
465
+ // the `expect()` callable signature
466
+ <T = unknown>(actual?: T): Matchers<T>;
467
+
468
+ /**
469
+ * Access to negated asymmetric matchers.
470
+ *
471
+ * @example
472
+ * expect("abc").toEqual(expect.stringContaining("abc")); // will pass
473
+ * expect("abc").toEqual(expect.not.stringContaining("abc")); // will fail
474
+ */
475
+ not: ExpectNot;
476
+
477
+ /**
478
+ * Create an asymmetric matcher for a promise resolved value.
479
+ *
480
+ * @example
481
+ * expect(Promise.resolve("value")).toEqual(expect.resolvesTo.stringContaining("value")); // will pass
482
+ * expect(Promise.reject("value")).toEqual(expect.resolvesTo.stringContaining("value")); // will fail
483
+ * expect("value").toEqual(expect.resolvesTo.stringContaining("value")); // will fail
484
+ */
485
+ resolvesTo: AsymmetricMatchers;
486
+
487
+ /**
488
+ * Create an asymmetric matcher for a promise rejected value.
489
+ *
490
+ * @example
491
+ * expect(Promise.reject("error")).toEqual(expect.rejectsTo.stringContaining("error")); // will pass
492
+ * expect(Promise.resolve("error")).toEqual(expect.rejectsTo.stringContaining("error")); // will fail
493
+ * expect("error").toEqual(expect.rejectsTo.stringContaining("error")); // will fail
494
+ */
495
+ rejectsTo: AsymmetricMatchers;
496
+
497
+ /**
498
+ * Register new custom matchers.
499
+ * @param matchers An object containing the matchers to register, where each key is the matcher name, and its value the implementation function.
500
+ * The function must satisfy: `(actualValue, ...matcherInstantiationArguments) => { pass: true|false, message: () => string }`
501
+ *
502
+ * @example
503
+ * expect.extend({
504
+ * toBeWithinRange(actual, min, max) {
505
+ * if (typeof actual !== 'number' || typeof min !== 'number' || typeof max !== 'number')
506
+ * throw new Error('Invalid usage');
507
+ * const pass = actual >= min && actual <= max;
508
+ * return {
509
+ * pass: pass,
510
+ * message: () => `expected ${this.utils.printReceived(actual)} ` +
511
+ * (pass ? `not to be`: `to be`) + ` within range ${this.utils.printExpected(`${min} .. ${max}`)}`,
512
+ * };
513
+ * },
514
+ * });
515
+ *
516
+ * test('some test', () => {
517
+ * expect(50).toBeWithinRange(0, 100); // will pass
518
+ * expect(50).toBeWithinRange(100, 200); // will fail
519
+ * expect(50).toBe(expect.toBeWithinRange(0, 100)); // will pass
520
+ * expect(50).toBe(expect.not.toBeWithinRange(100, 200)); // will pass
521
+ * });
522
+ */
523
+ extend<M>(matchers: ExpectExtendMatchers<M>): void;
524
+
525
+ /**
526
+ * Throw an error if this function is called.
527
+ *
528
+ * @param msg Optional message to display if the test fails
529
+ * @returns never
530
+ *
531
+ * @example
532
+ * ## Example
533
+ *
534
+ * ```ts
535
+ * import { expect, test } from "bun:test";
536
+ *
537
+ * test("!!abc!! is not a module", () => {
538
+ * try {
539
+ * require("!!abc!!");
540
+ * expect.unreachable();
541
+ * } catch(e) {
542
+ * expect(e.name).not.toBe("UnreachableError");
543
+ * }
544
+ * });
545
+ * ```
546
+ */
547
+ unreachable(msg?: string | Error): never;
548
+ }
549
+
550
+ /**
551
+ * You can extend this interface with declaration merging, in order to add type support for custom matchers.
552
+ * @template T Type of the actual value
553
+ *
554
+ * @example
555
+ * // my_modules.d.ts
556
+ * interface MyCustomMatchers {
557
+ * toBeWithinRange(floor: number, ceiling: number): any;
558
+ * }
559
+ * declare module "bun:test" {
560
+ * interface Matchers<T> extends MyCustomMatchers {}
561
+ * interface AsymmetricMatchers extends MyCustomMatchers {}
562
+ * }
563
+ *
564
+ * @example
565
+ * // my_modules.d.ts (alternatively)
566
+ * declare module "bun:test" {
567
+ * interface Matchers<T> {
568
+ * toBeWithinRange(floor: number, ceiling: number): any;
569
+ * }
570
+ * interface AsymmetricMatchers {
571
+ * toBeWithinRange(floor: number, ceiling: number): any;
572
+ * }
573
+ * }
574
+ */
575
+ export interface Matchers<T = unknown> extends MatchersBuiltin<T> {}
576
+
577
+ /**
578
+ * You can extend this interface with declaration merging, in order to add type support for custom asymmetric matchers.
579
+ * @example
580
+ * // my_modules.d.ts
581
+ * interface MyCustomMatchers {
582
+ * toBeWithinRange(floor: number, ceiling: number): any;
583
+ * }
584
+ * declare module "bun:test" {
585
+ * interface Matchers<T> extends MyCustomMatchers {}
586
+ * interface AsymmetricMatchers extends MyCustomMatchers {}
587
+ * }
588
+ *
589
+ * @example
590
+ * // my_modules.d.ts (alternatively)
591
+ * declare module "bun:test" {
592
+ * interface Matchers<T> {
593
+ * toBeWithinRange(floor: number, ceiling: number): any;
594
+ * }
595
+ * interface AsymmetricMatchers {
596
+ * toBeWithinRange(floor: number, ceiling: number): any;
597
+ * }
598
+ * }
599
+ */
600
+ export interface AsymmetricMatchers extends AsymmetricMatchersBuiltin {}
601
+
602
+ export interface AsymmetricMatchersBuiltin {
603
+ /**
604
+ * Matches anything that was created with the given constructor.
605
+ * You can use it inside `toEqual` or `toBeCalledWith` instead of a literal value.
606
+ *
607
+ * @example
608
+ *
609
+ * function randocall(fn) {
610
+ * return fn(Math.floor(Math.random() * 6 + 1));
611
+ * }
612
+ *
613
+ * test('randocall calls its callback with a number', () => {
614
+ * const mock = jest.fn();
615
+ * randocall(mock);
616
+ * expect(mock).toBeCalledWith(expect.any(Number));
617
+ * });
618
+ */
619
+ any(constructor: ((...args: any[]) => any) | { new (...args: any[]): any }): AsymmetricMatcher;
620
+ /**
621
+ * Matches anything but null or undefined. You can use it inside `toEqual` or `toBeCalledWith` instead
622
+ * of a literal value. For example, if you want to check that a mock function is called with a
623
+ * non-null argument:
624
+ *
625
+ * @example
626
+ *
627
+ * test('map calls its argument with a non-null argument', () => {
628
+ * const mock = jest.fn();
629
+ * [1].map(x => mock(x));
630
+ * expect(mock).toBeCalledWith(expect.anything());
631
+ * });
632
+ */
633
+ anything(): AsymmetricMatcher;
634
+ /**
635
+ * Matches any array made up entirely of elements in the provided array.
636
+ * You can use it inside `toEqual` or `toBeCalledWith` instead of a literal value.
637
+ *
638
+ * Optionally, you can provide a type for the elements via a generic.
639
+ */
640
+ arrayContaining<E = any>(arr: readonly E[]): AsymmetricMatcher;
641
+ /**
642
+ * Matches any object that recursively matches the provided keys.
643
+ * This is often handy in conjunction with other asymmetric matchers.
644
+ *
645
+ * Optionally, you can provide a type for the object via a generic.
646
+ * This ensures that the object contains the desired structure.
647
+ */
648
+ objectContaining(obj: object): AsymmetricMatcher;
649
+ /**
650
+ * Matches any received string that contains the exact expected string
651
+ */
652
+ stringContaining(str: string | String): AsymmetricMatcher;
653
+ /**
654
+ * Matches any string that contains the exact provided string
655
+ */
656
+ stringMatching(regex: string | String | RegExp): AsymmetricMatcher;
657
+ /**
658
+ * Useful when comparing floating point numbers in object properties or array item.
659
+ * If you need to compare a number, use `.toBeCloseTo` instead.
660
+ *
661
+ * The optional `numDigits` argument limits the number of digits to check after the decimal point.
662
+ * For the default value 2, the test criterion is `Math.abs(expected - received) < 0.005` (that is, `10 ** -2 / 2`).
663
+ */
664
+ closeTo(num: number, numDigits?: number): AsymmetricMatcher;
665
+ }
666
+
667
+ interface AsymmetricMatchersBuiltinNegated {
668
+ /**
669
+ * Create an asymmetric matcher that will fail on a promise resolved value that matches the chained matcher.
670
+ *
671
+ * @example
672
+ * expect(Promise.resolve("value")).toEqual(expect.not.resolvesTo.stringContaining("value")); // will fail
673
+ * expect(Promise.reject("value")).toEqual(expect.not.resolvesTo.stringContaining("value")); // will pass
674
+ * expect("value").toEqual(expect.not.resolvesTo.stringContaining("value")); // will pass
675
+ */
676
+ resolvesTo: ExpectNot;
677
+
678
+ /**
679
+ * Create an asymmetric matcher that will fail on a promise rejected value that matches the chained matcher.
680
+ *
681
+ * @example
682
+ * expect(Promise.reject("value")).toEqual(expect.not.rejectsTo.stringContaining("value")); // will fail
683
+ * expect(Promise.resolve("value")).toEqual(expect.not.rejectsTo.stringContaining("value")); // will pass
684
+ * expect("value").toEqual(expect.not.rejectsTo.stringContaining("value")); // will pass
685
+ */
686
+ rejectsTo: ExpectNot;
687
+
688
+ /**
689
+ * `expect.not.arrayContaining(array)` matches a received array which
690
+ * does not contain all of the elements in the expected array. That is,
691
+ * the expected array is not a subset of the received array. It is the
692
+ * inverse of `expect.arrayContaining`.
693
+ *
694
+ * Optionally, you can provide a type for the elements via a generic.
695
+ */
696
+ arrayContaining<E = any>(arr: readonly E[]): AsymmetricMatcher;
697
+
698
+ /**
699
+ * `expect.not.objectContaining(object)` matches any received object
700
+ * that does not recursively match the expected properties. That is, the
701
+ * expected object is not a subset of the received object. Therefore,
702
+ * it matches a received object which contains properties that are not
703
+ * in the expected object. It is the inverse of `expect.objectContaining`.
704
+ *
705
+ * Optionally, you can provide a type for the object via a generic.
706
+ * This ensures that the object contains the desired structure.
707
+ */
708
+ objectContaining(obj: object): AsymmetricMatcher;
709
+
710
+ /**
711
+ * `expect.not.stringContaining(string)` matches the received string
712
+ * that does not contain the exact expected string. It is the inverse of
713
+ * `expect.stringContaining`.
714
+ */
715
+ stringContaining(str: string | String): AsymmetricMatcher;
716
+
717
+ /**
718
+ * `expect.not.stringMatching(string | regexp)` matches the received
719
+ * string that does not match the expected regexp. It is the inverse of
720
+ * `expect.stringMatching`.
721
+ */
722
+ stringMatching(str: string | String | RegExp): AsymmetricMatcher;
723
+
724
+ /**
725
+ * `expect.not.closeTo` matches a number not close to the provided value.
726
+ * Useful when comparing floating point numbers in object properties or array item.
727
+ * It is the inverse of `expect.closeTo`.
728
+ */
729
+ closeTo(num: number, numDigits?: number): AsymmetricMatcher;
730
+ }
731
+
732
+ export interface MatchersBuiltin<T = unknown> {
733
+ /**
734
+ * Negates the result of a subsequent assertion.
735
+ * If you know how to test something, `.not` lets you test its opposite.
736
+ *
737
+ * @example
738
+ * expect(1).not.toBe(0);
739
+ * expect(null).not.toBeNull();
740
+ *
741
+ * @example
742
+ * expect(42).toEqual(42); // will pass
743
+ * expect(42).not.toEqual(42); // will fail
744
+ */
745
+ not: Matchers<unknown>;
746
+
747
+ /**
748
+ * Expects the value to be a promise that resolves.
749
+ *
750
+ * @example
751
+ * expect(Promise.resolve(1)).resolves.toBe(1);
752
+ */
753
+ resolves: Matchers<Awaited<T>>;
754
+
755
+ /**
756
+ * Expects the value to be a promise that rejects.
757
+ *
758
+ * @example
759
+ * expect(Promise.reject("error")).rejects.toBe("error");
760
+ */
761
+ rejects: Matchers<unknown>;
762
+
763
+ /**
764
+ * Assertion which passes.
765
+ *
766
+ * @link https://jest-extended.jestcommunity.dev/docs/matchers/pass
767
+ * @example
768
+ * expect().pass();
769
+ * expect().pass("message is optional");
770
+ * expect().not.pass();
771
+ * expect().not.pass("hi");
772
+ *
773
+ * @param message the message to display if the test fails (optional)
774
+ */
775
+ pass: (message?: string) => void;
776
+ /**
777
+ * Assertion which fails.
778
+ *
779
+ * @link https://jest-extended.jestcommunity.dev/docs/matchers/fail
780
+ * @example
781
+ * expect().fail();
782
+ * expect().fail("message is optional");
783
+ * expect().not.fail();
784
+ * expect().not.fail("hi");
785
+ */
786
+ fail: (message?: string) => void;
787
+ /**
788
+ * Asserts that a value equals what is expected.
789
+ *
790
+ * - For non-primitive values, like objects and arrays,
791
+ * use `toEqual()` instead.
792
+ * - For floating-point numbers, use `toBeCloseTo()` instead.
793
+ *
794
+ * @example
795
+ * expect(100 + 23).toBe(123);
796
+ * expect("d" + "og").toBe("dog");
797
+ * expect([123]).toBe([123]); // fail, use toEqual()
798
+ * expect(3 + 0.14).toBe(3.14); // fail, use toBeCloseTo()
799
+ *
800
+ * @param expected the expected value
801
+ */
802
+ toBe(expected: T): void;
803
+ /**
804
+ * Asserts that a number is odd.
805
+ *
806
+ * @link https://jest-extended.jestcommunity.dev/docs/matchers/number/#tobeodd
807
+ * @example
808
+ * expect(1).toBeOdd();
809
+ * expect(2).not.toBeOdd();
810
+ */
811
+ toBeOdd(): void;
812
+ /**
813
+ * Asserts that a number is even.
814
+ *
815
+ * @link https://jest-extended.jestcommunity.dev/docs/matchers/number/#tobeeven
816
+ * @example
817
+ * expect(2).toBeEven();
818
+ * expect(1).not.toBeEven();
819
+ */
820
+ toBeEven(): void;
821
+ /**
822
+ * Asserts that value is close to the expected by floating point precision.
823
+ *
824
+ * For example, the following fails because arithmetic on decimal (base 10)
825
+ * values often have rounding errors in limited precision binary (base 2) representation.
826
+ *
827
+ * @example
828
+ * expect(0.2 + 0.1).toBe(0.3); // fails
829
+ *
830
+ * Use `toBeCloseTo` to compare floating point numbers for approximate equality.
831
+ *
832
+ * @example
833
+ * expect(0.2 + 0.1).toBeCloseTo(0.3, 5); // passes
834
+ *
835
+ * @param expected the expected value
836
+ * @param numDigits the number of digits to check after the decimal point. Default is `2`
837
+ */
838
+ toBeCloseTo(expected: number, numDigits?: number): void;
839
+ /**
840
+ * Asserts that a value is deeply equal to what is expected.
841
+ *
842
+ * @example
843
+ * expect(100 + 23).toBe(123);
844
+ * expect("d" + "og").toBe("dog");
845
+ * expect([456]).toEqual([456]);
846
+ * expect({ value: 1 }).toEqual({ value: 1 });
847
+ *
848
+ * @param expected the expected value
849
+ */
850
+ toEqual(expected: T): void;
851
+ /**
852
+ * Asserts that a value is deeply and strictly equal to
853
+ * what is expected.
854
+ *
855
+ * There are two key differences from `toEqual()`:
856
+ * 1. It checks that the class is the same.
857
+ * 2. It checks that `undefined` values match as well.
858
+ *
859
+ * @example
860
+ * class Dog {
861
+ * type = "dog";
862
+ * }
863
+ * const actual = new Dog();
864
+ * expect(actual).toStrictEqual(new Dog());
865
+ * expect(actual).toStrictEqual({ type: "dog" }); // fail
866
+ *
867
+ * @example
868
+ * const actual = { value: 1, name: undefined };
869
+ * expect(actual).toEqual({ value: 1 });
870
+ * expect(actual).toStrictEqual({ value: 1 }); // fail
871
+ *
872
+ * @param expected the expected value
873
+ */
874
+ toStrictEqual(expected: T): void;
875
+ /**
876
+ * Asserts that a value contains what is expected.
877
+ *
878
+ * The value must be an array or iterable, which
879
+ * includes strings.
880
+ *
881
+ * @example
882
+ * expect([1, 2, 3]).toContain(1);
883
+ * expect(new Set([true])).toContain(true);
884
+ * expect("hello").toContain("o");
885
+ *
886
+ * @param expected the expected value
887
+ */
888
+ toContain(expected: unknown): void;
889
+ /**
890
+ * Asserts that an `object` contains a key.
891
+ *
892
+ * The value must be an object
893
+ *
894
+ * @example
895
+ * expect({ a: 'foo', b: 'bar', c: 'baz' }).toContainKey('a');
896
+ * expect({ a: 'foo', b: 'bar', c: 'baz' }).toContainKey('b');
897
+ * expect({ a: 'foo', b: 'bar', c: 'baz' }).toContainKey('c');
898
+ * expect({ a: 'foo', b: 'bar', c: 'baz' }).not.toContainKey('d');
899
+ *
900
+ * @param expected the expected value
901
+ */
902
+ toContainKey(expected: unknown): void;
903
+ /**
904
+ * Asserts that an `object` contains at least one of the provided keys.
905
+ * Asserts that an `object` contains all the provided keys.
906
+ *
907
+ * The value must be an object
908
+ *
909
+ * @example
910
+ * expect({ a: 'hello', b: 'world' }).toContainAnyKeys(['a']);
911
+ * expect({ a: 'hello', b: 'world' }).toContainAnyKeys(['b']);
912
+ * expect({ a: 'hello', b: 'world' }).toContainAnyKeys(['b', 'c']);
913
+ * expect({ a: 'hello', b: 'world' }).not.toContainAnyKeys(['c']);
914
+ *
915
+ * @param expected the expected value
916
+ */
917
+ toContainAnyKeys(expected: unknown): void;
918
+
919
+ /**
920
+ * Asserts that an `object` contains all the provided keys.
921
+ * expect({ a: 'foo', b: 'bar', c: 'baz' }).toContainKeys(['a', 'b']);
922
+ * expect({ a: 'foo', b: 'bar', c: 'baz' }).toContainKeys(['a', 'b', 'c']);
923
+ * expect({ a: 'foo', b: 'bar', c: 'baz' }).not.toContainKeys(['a', 'b', 'e']);
924
+ *
925
+ * @param expected the expected value
926
+ */
927
+ toContainKeys(expected: unknown): void;
928
+ /**
929
+ * Asserts that a value contains and equals what is expected.
930
+ *
931
+ * This matcher will perform a deep equality check for members
932
+ * of arrays, rather than checking for object identity.
933
+ *
934
+ * @example
935
+ * expect([{ a: 1 }]).toContainEqual({ a: 1 });
936
+ * expect([{ a: 1 }]).not.toContainEqual({ a: 2 });
937
+ *
938
+ * @param expected the expected value
939
+ */
940
+ toContainEqual(expected: unknown): void;
941
+ /**
942
+ * Asserts that a value has a `.length` property
943
+ * that is equal to the expected length.
944
+ *
945
+ * @example
946
+ * expect([]).toHaveLength(0);
947
+ * expect("hello").toHaveLength(4);
948
+ *
949
+ * @param length the expected length
950
+ */
951
+ toHaveLength(length: number): void;
952
+ /**
953
+ * Asserts that a value has a property with the
954
+ * expected name, and value if provided.
955
+ *
956
+ * @example
957
+ * expect(new Set()).toHaveProperty("size");
958
+ * expect(new Uint8Array()).toHaveProperty("byteLength", 0);
959
+ * expect({ kitchen: { area: 20 }}).toHaveProperty("kitchen.area", 20);
960
+ * expect({ kitchen: { area: 20 }}).toHaveProperty(["kitchen", "area"], 20);
961
+ *
962
+ * @param keyPath the expected property name or path, or an index
963
+ * @param value the expected property value, if provided
964
+ */
965
+ toHaveProperty(keyPath: string | number | Array<string | number>, value?: unknown): void;
966
+ /**
967
+ * Asserts that a value is "truthy".
968
+ *
969
+ * To assert that a value equals `true`, use `toBe(true)` instead.
970
+ *
971
+ * @link https://developer.mozilla.org/en-US/docs/Glossary/Truthy
972
+ * @example
973
+ * expect(true).toBeTruthy();
974
+ * expect(1).toBeTruthy();
975
+ * expect({}).toBeTruthy();
976
+ */
977
+ toBeTruthy(): void;
978
+ /**
979
+ * Asserts that a value is "falsy".
980
+ *
981
+ * To assert that a value equals `false`, use `toBe(false)` instead.
982
+ *
983
+ * @link https://developer.mozilla.org/en-US/docs/Glossary/Falsy
984
+ * @example
985
+ * expect(true).toBeTruthy();
986
+ * expect(1).toBeTruthy();
987
+ * expect({}).toBeTruthy();
988
+ */
989
+ toBeFalsy(): void;
990
+ /**
991
+ * Asserts that a value is defined. (e.g. is not `undefined`)
992
+ *
993
+ * @example
994
+ * expect(true).toBeDefined();
995
+ * expect(undefined).toBeDefined(); // fail
996
+ */
997
+ toBeDefined(): void;
998
+ /**
999
+ * Asserts that the expected value is an instance of value
1000
+ *
1001
+ * @example
1002
+ * expect([]).toBeInstanceOf(Array);
1003
+ * expect(null).toBeInstanceOf(Array); // fail
1004
+ */
1005
+ toBeInstanceOf(value: unknown): void;
1006
+ /**
1007
+ * Asserts that the expected value is an instance of value
1008
+ *
1009
+ * @example
1010
+ * expect([]).toBeInstanceOf(Array);
1011
+ * expect(null).toBeInstanceOf(Array); // fail
1012
+ */
1013
+ toBeInstanceOf(value: unknown): void;
1014
+ /**
1015
+ * Asserts that a value is `undefined`.
1016
+ *
1017
+ * @example
1018
+ * expect(undefined).toBeUndefined();
1019
+ * expect(null).toBeUndefined(); // fail
1020
+ */
1021
+ toBeUndefined(): void;
1022
+ /**
1023
+ * Asserts that a value is `null`.
1024
+ *
1025
+ * @example
1026
+ * expect(null).toBeNull();
1027
+ * expect(undefined).toBeNull(); // fail
1028
+ */
1029
+ toBeNull(): void;
1030
+ /**
1031
+ * Asserts that a value is `NaN`.
1032
+ *
1033
+ * Same as using `Number.isNaN()`.
1034
+ *
1035
+ * @example
1036
+ * expect(NaN).toBeNaN();
1037
+ * expect(Infinity).toBeNaN(); // fail
1038
+ * expect("notanumber").toBeNaN(); // fail
1039
+ */
1040
+ toBeNaN(): void;
1041
+ /**
1042
+ * Asserts that a value is a `number` and is greater than the expected value.
1043
+ *
1044
+ * @example
1045
+ * expect(1).toBeGreaterThan(0);
1046
+ * expect(3.14).toBeGreaterThan(3);
1047
+ * expect(9).toBeGreaterThan(9); // fail
1048
+ *
1049
+ * @param expected the expected number
1050
+ */
1051
+ toBeGreaterThan(expected: number | bigint): void;
1052
+ /**
1053
+ * Asserts that a value is a `number` and is greater than or equal to the expected value.
1054
+ *
1055
+ * @example
1056
+ * expect(1).toBeGreaterThanOrEqual(0);
1057
+ * expect(3.14).toBeGreaterThanOrEqual(3);
1058
+ * expect(9).toBeGreaterThanOrEqual(9);
1059
+ *
1060
+ * @param expected the expected number
1061
+ */
1062
+ toBeGreaterThanOrEqual(expected: number | bigint): void;
1063
+ /**
1064
+ * Asserts that a value is a `number` and is less than the expected value.
1065
+ *
1066
+ * @example
1067
+ * expect(-1).toBeLessThan(0);
1068
+ * expect(3).toBeLessThan(3.14);
1069
+ * expect(9).toBeLessThan(9); // fail
1070
+ *
1071
+ * @param expected the expected number
1072
+ */
1073
+ toBeLessThan(expected: number | bigint): void;
1074
+ /**
1075
+ * Asserts that a value is a `number` and is less than or equal to the expected value.
1076
+ *
1077
+ * @example
1078
+ * expect(-1).toBeLessThanOrEqual(0);
1079
+ * expect(3).toBeLessThanOrEqual(3.14);
1080
+ * expect(9).toBeLessThanOrEqual(9);
1081
+ *
1082
+ * @param expected the expected number
1083
+ */
1084
+ toBeLessThanOrEqual(expected: number | bigint): void;
1085
+ /**
1086
+ * Asserts that a function throws an error.
1087
+ *
1088
+ * - If expected is a `string` or `RegExp`, it will check the `message` property.
1089
+ * - If expected is an `Error` object, it will check the `name` and `message` properties.
1090
+ * - If expected is an `Error` constructor, it will check the class of the `Error`.
1091
+ * - If expected is not provided, it will check if anything as thrown.
1092
+ *
1093
+ * @example
1094
+ * function fail() {
1095
+ * throw new Error("Oops!");
1096
+ * }
1097
+ * expect(fail).toThrow("Oops!");
1098
+ * expect(fail).toThrow(/oops/i);
1099
+ * expect(fail).toThrow(Error);
1100
+ * expect(fail).toThrow();
1101
+ *
1102
+ * @param expected the expected error, error message, or error pattern
1103
+ */
1104
+ toThrow(expected?: unknown): void;
1105
+ /**
1106
+ * Asserts that a value matches a regular expression or includes a substring.
1107
+ *
1108
+ * @example
1109
+ * expect("dog").toMatch(/dog/);
1110
+ * expect("dog").toMatch("og");
1111
+ *
1112
+ * @param expected the expected substring or pattern.
1113
+ */
1114
+ toMatch(expected: string | RegExp): void;
1115
+ /**
1116
+ * Asserts that a value matches the most recent snapshot.
1117
+ *
1118
+ * @example
1119
+ * expect([1, 2, 3]).toMatchSnapshot('hint message');
1120
+ * @param hint Hint used to identify the snapshot in the snapshot file.
1121
+ */
1122
+ toMatchSnapshot(hint?: string): void;
1123
+ /**
1124
+ * Asserts that a value matches the most recent snapshot.
1125
+ *
1126
+ * @example
1127
+ * expect([1, 2, 3]).toMatchSnapshot();
1128
+ * expect({ a: 1, b: 2 }).toMatchSnapshot({ a: 1 });
1129
+ * expect({ c: new Date() }).toMatchSnapshot({ c: expect.any(Date) });
1130
+ *
1131
+ * @param propertyMatchers Object containing properties to match against the value.
1132
+ * @param hint Hint used to identify the snapshot in the snapshot file.
1133
+ */
1134
+ toMatchSnapshot(propertyMatchers?: object, hint?: string): void;
1135
+ /**
1136
+ * Asserts that an object matches a subset of properties.
1137
+ *
1138
+ * @example
1139
+ * expect({ a: 1, b: 2 }).toMatchObject({ b: 2 });
1140
+ * expect({ c: new Date(), d: 2 }).toMatchObject({ d: 2 });
1141
+ *
1142
+ * @param subset Subset of properties to match with.
1143
+ */
1144
+ toMatchObject(subset: object): void;
1145
+ /**
1146
+ * Asserts that a value is empty.
1147
+ *
1148
+ * @example
1149
+ * expect("").toBeEmpty();
1150
+ * expect([]).toBeEmpty();
1151
+ * expect({}).toBeEmpty();
1152
+ * expect(new Set()).toBeEmpty();
1153
+ */
1154
+ toBeEmpty(): void;
1155
+ /**
1156
+ * Asserts that a value is an empty `object`.
1157
+ *
1158
+ * @example
1159
+ * expect({}).toBeEmptyObject();
1160
+ * expect({ a: 'hello' }).not.toBeEmptyObject();
1161
+ */
1162
+ toBeEmptyObject(): void;
1163
+ /**
1164
+ * Asserts that a value is `null` or `undefined`.
1165
+ *
1166
+ * @example
1167
+ * expect(null).toBeNil();
1168
+ * expect(undefined).toBeNil();
1169
+ */
1170
+ toBeNil(): void;
1171
+ /**
1172
+ * Asserts that a value is a `array`.
1173
+ *
1174
+ * @link https://jest-extended.jestcommunity.dev/docs/matchers/array/#tobearray
1175
+ * @example
1176
+ * expect([1]).toBeArray();
1177
+ * expect(new Array(1)).toBeArray();
1178
+ * expect({}).not.toBeArray();
1179
+ */
1180
+ toBeArray(): void;
1181
+ /**
1182
+ * Asserts that a value is a `array` of a certain length.
1183
+ *
1184
+ * @link https://jest-extended.jestcommunity.dev/docs/matchers/array/#tobearrayofsize
1185
+ * @example
1186
+ * expect([]).toBeArrayOfSize(0);
1187
+ * expect([1]).toBeArrayOfSize(1);
1188
+ * expect(new Array(1)).toBeArrayOfSize(1);
1189
+ * expect({}).not.toBeArrayOfSize(0);
1190
+ */
1191
+ toBeArrayOfSize(size: number): void;
1192
+ /**
1193
+ * Asserts that a value is a `boolean`.
1194
+ *
1195
+ * @example
1196
+ * expect(true).toBeBoolean();
1197
+ * expect(false).toBeBoolean();
1198
+ * expect(null).not.toBeBoolean();
1199
+ * expect(0).not.toBeBoolean();
1200
+ */
1201
+ toBeBoolean(): void;
1202
+ /**
1203
+ * Asserts that a value is `true`.
1204
+ *
1205
+ * @example
1206
+ * expect(true).toBeTrue();
1207
+ * expect(false).not.toBeTrue();
1208
+ * expect(1).not.toBeTrue();
1209
+ */
1210
+ toBeTrue(): void;
1211
+ /**
1212
+ * Asserts that a value matches a specific type.
1213
+ *
1214
+ * @link https://vitest.dev/api/expect.html#tobetypeof
1215
+ * @example
1216
+ * expect(1).toBeTypeOf("number");
1217
+ * expect("hello").toBeTypeOf("string");
1218
+ * expect([]).not.toBeTypeOf("boolean");
1219
+ */
1220
+ toBeTypeOf(type: "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined"): void;
1221
+ /**
1222
+ * Asserts that a value is `false`.
1223
+ *
1224
+ * @example
1225
+ * expect(false).toBeFalse();
1226
+ * expect(true).not.toBeFalse();
1227
+ * expect(0).not.toBeFalse();
1228
+ */
1229
+ toBeFalse(): void;
1230
+ /**
1231
+ * Asserts that a value is a `number`.
1232
+ *
1233
+ * @example
1234
+ * expect(1).toBeNumber();
1235
+ * expect(3.14).toBeNumber();
1236
+ * expect(NaN).toBeNumber();
1237
+ * expect(BigInt(1)).not.toBeNumber();
1238
+ */
1239
+ toBeNumber(): void;
1240
+ /**
1241
+ * Asserts that a value is a `number`, and is an integer.
1242
+ *
1243
+ * @example
1244
+ * expect(1).toBeInteger();
1245
+ * expect(3.14).not.toBeInteger();
1246
+ * expect(NaN).not.toBeInteger();
1247
+ */
1248
+ toBeInteger(): void;
1249
+ /**
1250
+ * Asserts that a value is an `object`.
1251
+ *
1252
+ * @example
1253
+ * expect({}).toBeObject();
1254
+ * expect("notAnObject").not.toBeObject();
1255
+ * expect(NaN).not.toBeObject();
1256
+ */
1257
+ toBeObject(): void;
1258
+ /**
1259
+ * Asserts that a value is a `number`, and is not `NaN` or `Infinity`.
1260
+ *
1261
+ * @example
1262
+ * expect(1).toBeFinite();
1263
+ * expect(3.14).toBeFinite();
1264
+ * expect(NaN).not.toBeFinite();
1265
+ * expect(Infinity).not.toBeFinite();
1266
+ */
1267
+ toBeFinite(): void;
1268
+ /**
1269
+ * Asserts that a value is a positive `number`.
1270
+ *
1271
+ * @example
1272
+ * expect(1).toBePositive();
1273
+ * expect(-3.14).not.toBePositive();
1274
+ * expect(NaN).not.toBePositive();
1275
+ */
1276
+ toBePositive(): void;
1277
+ /**
1278
+ * Asserts that a value is a negative `number`.
1279
+ *
1280
+ * @example
1281
+ * expect(-3.14).toBeNegative();
1282
+ * expect(1).not.toBeNegative();
1283
+ * expect(NaN).not.toBeNegative();
1284
+ */
1285
+ toBeNegative(): void;
1286
+ /**
1287
+ * Asserts that a value is a number between a start and end value.
1288
+ *
1289
+ * @param start the start number (inclusive)
1290
+ * @param end the end number (exclusive)
1291
+ */
1292
+ toBeWithin(start: number, end: number): void;
1293
+ /**
1294
+ * Asserts that a value is equal to the expected string, ignoring any whitespace.
1295
+ *
1296
+ * @example
1297
+ * expect(" foo ").toEqualIgnoringWhitespace("foo");
1298
+ * expect("bar").toEqualIgnoringWhitespace(" bar ");
1299
+ *
1300
+ * @param expected the expected string
1301
+ */
1302
+ toEqualIgnoringWhitespace(expected: string): void;
1303
+ /**
1304
+ * Asserts that a value is a `symbol`.
1305
+ *
1306
+ * @example
1307
+ * expect(Symbol("foo")).toBeSymbol();
1308
+ * expect("foo").not.toBeSymbol();
1309
+ */
1310
+ toBeSymbol(): void;
1311
+ /**
1312
+ * Asserts that a value is a `function`.
1313
+ *
1314
+ * @example
1315
+ * expect(() => {}).toBeFunction();
1316
+ */
1317
+ toBeFunction(): void;
1318
+ /**
1319
+ * Asserts that a value is a `Date` object.
1320
+ *
1321
+ * To check if a date is valid, use `toBeValidDate()` instead.
1322
+ *
1323
+ * @example
1324
+ * expect(new Date()).toBeDate();
1325
+ * expect(new Date(null)).toBeDate();
1326
+ * expect("2020-03-01").not.toBeDate();
1327
+ */
1328
+ toBeDate(): void;
1329
+ /**
1330
+ * Asserts that a value is a valid `Date` object.
1331
+ *
1332
+ * @example
1333
+ * expect(new Date()).toBeValidDate();
1334
+ * expect(new Date(null)).not.toBeValidDate();
1335
+ * expect("2020-03-01").not.toBeValidDate();
1336
+ */
1337
+ toBeValidDate(): void;
1338
+ /**
1339
+ * Asserts that a value is a `string`.
1340
+ *
1341
+ * @example
1342
+ * expect("foo").toBeString();
1343
+ * expect(new String("bar")).toBeString();
1344
+ * expect(123).not.toBeString();
1345
+ */
1346
+ toBeString(): void;
1347
+ /**
1348
+ * Asserts that a value includes a `string`.
1349
+ *
1350
+ * For non-string values, use `toContain()` instead.
1351
+ *
1352
+ * @param expected the expected substring
1353
+ */
1354
+ toInclude(expected: string): void;
1355
+ /**
1356
+ * Asserts that a value includes a `string` {times} times.
1357
+ * @param expected the expected substring
1358
+ * @param times the number of times the substring should occur
1359
+ */
1360
+ toIncludeRepeated(expected: string, times: number): void;
1361
+ /**
1362
+ * Checks whether a value satisfies a custom condition.
1363
+ * @param {Function} predicate - The custom condition to be satisfied. It should be a function that takes a value as an argument (in this case the value from expect) and returns a boolean.
1364
+ * @example
1365
+ * expect(1).toSatisfy((val) => val > 0);
1366
+ * expect("foo").toSatisfy((val) => val === "foo");
1367
+ * expect("bar").not.toSatisfy((val) => val === "bun");
1368
+ * @link https://vitest.dev/api/expect.html#tosatisfy
1369
+ * @link https://jest-extended.jestcommunity.dev/docs/matchers/toSatisfy
1370
+ */
1371
+ toSatisfy(predicate: (value: T) => boolean): void;
1372
+ /**
1373
+ * Asserts that a value starts with a `string`.
1374
+ *
1375
+ * @param expected the string to start with
1376
+ */
1377
+ toStartWith(expected: string): void;
1378
+ /**
1379
+ * Asserts that a value ends with a `string`.
1380
+ *
1381
+ * @param expected the string to end with
1382
+ */
1383
+ toEndWith(expected: string): void;
1384
+ /**
1385
+ * Ensures that a mock function is called.
1386
+ */
1387
+ toHaveBeenCalled(): void;
1388
+ /**
1389
+ * Ensures that a mock function is called an exact number of times.
1390
+ */
1391
+ toHaveBeenCalledTimes(expected: number): void;
1392
+ /**
1393
+ * Ensure that a mock function is called with specific arguments.
1394
+ */
1395
+ toHaveBeenCalledWith(...expected: unknown[]): void;
1396
+ /**
1397
+ * Ensure that a mock function is called with specific arguments for the last call.
1398
+ */
1399
+ toHaveBeenLastCalledWith(...expected: unknown[]): void;
1400
+ /**
1401
+ * Ensure that a mock function is called with specific arguments for the nth call.
1402
+ */
1403
+ toHaveBeenNthCalledWith(n: number, ...expected: unknown[]): void;
1404
+ }
1405
+
1406
+ /**
1407
+ * Object representing an asymmetric matcher obtained by an static call to expect like `expect.anything()`, `expect.stringContaining("...")`, etc.
1408
+ */
1409
+ // Defined as an alias of `any` so that it does not trigger any type mismatch
1410
+ export type AsymmetricMatcher = any;
1411
+
1412
+ export interface MatcherResult {
1413
+ pass: boolean;
1414
+ message?: string | (() => string);
1415
+ }
1416
+
1417
+ export type CustomMatcher<E, P extends any[]> = (
1418
+ this: MatcherContext,
1419
+ expected: E,
1420
+ ...matcherArguments: P
1421
+ ) => MatcherResult | Promise<MatcherResult>;
1422
+
1423
+ /** All non-builtin matchers and asymmetric matchers that have been type-registered through declaration merging */
1424
+ export type CustomMatchersDetected = Omit<Matchers<unknown>, keyof MatchersBuiltin<unknown>> &
1425
+ Omit<AsymmetricMatchers, keyof AsymmetricMatchersBuiltin>;
1426
+
1427
+ /**
1428
+ * If the types has been defined through declaration merging, enforce it.
1429
+ * Otherwise enforce the generic custom matcher signature.
1430
+ */
1431
+ export type ExpectExtendMatchers<M> = {
1432
+ [k in keyof M]: k extends keyof CustomMatchersDetected
1433
+ ? CustomMatcher<unknown, Parameters<CustomMatchersDetected[k]>>
1434
+ : CustomMatcher<unknown, any[]>;
1435
+ };
1436
+
1437
+ /** Custom equality tester */
1438
+ export type Tester = (this: TesterContext, a: any, b: any, customTesters: Tester[]) => boolean | undefined;
1439
+
1440
+ export type EqualsFunction = (
1441
+ a: unknown,
1442
+ b: unknown,
1443
+ //customTesters?: Array<Tester>,
1444
+ //strictCheck?: boolean,
1445
+ ) => boolean;
1446
+
1447
+ export interface TesterContext {
1448
+ equals: EqualsFunction;
1449
+ }
1450
+
1451
+ interface MatcherState {
1452
+ //assertionCalls: number;
1453
+ //currentConcurrentTestName?: () => string | undefined;
1454
+ //currentTestName?: string;
1455
+ //error?: Error;
1456
+ //expand: boolean;
1457
+ //expectedAssertionsNumber: number | null;
1458
+ //expectedAssertionsNumberError?: Error;
1459
+ //isExpectingAssertions: boolean;
1460
+ //isExpectingAssertionsError?: Error;
1461
+ isNot: boolean;
1462
+ //numPassingAsserts: number;
1463
+ promise: string;
1464
+ //suppressedErrors: Array<Error>;
1465
+ //testPath?: string;
1466
+ }
1467
+
1468
+ type MatcherHintColor = (arg: string) => string; // subset of Chalk type
1469
+
1470
+ interface MatcherUtils {
1471
+ //customTesters: Array<Tester>;
1472
+ //dontThrow(): void; // (internally used by jest snapshot)
1473
+ equals: EqualsFunction;
1474
+ utils: Readonly<{
1475
+ stringify(value: unknown): string;
1476
+ printReceived(value: unknown): string;
1477
+ printExpected(value: unknown): string;
1478
+ matcherHint(
1479
+ matcherName: string,
1480
+ received?: unknown,
1481
+ expected?: unknown,
1482
+ options?: {
1483
+ isNot?: boolean;
1484
+ promise?: string;
1485
+ isDirectExpectCall?: boolean; // (internal)
1486
+ comment?: string;
1487
+ expectedColor?: MatcherHintColor;
1488
+ receivedColor?: MatcherHintColor;
1489
+ secondArgument?: string;
1490
+ secondArgumentColor?: MatcherHintColor;
1491
+ },
1492
+ ): string;
1493
+ //iterableEquality: Tester;
1494
+ //subsetEquality: Tester;
1495
+ // ...
1496
+ }>;
1497
+ }
1498
+
1499
+ type MatcherContext = MatcherUtils & MatcherState;
1500
+ }
1501
+
1502
+ declare module "test" {
1503
+ export type * from "bun:test";
1504
+ }
1505
+
1506
+ declare namespace JestMock {
1507
+ /**
1508
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1509
+ *
1510
+ * This source code is licensed under the MIT license found in the
1511
+ * LICENSE file in the root directory of this source tree.
1512
+ */
1513
+ export interface ClassLike {
1514
+ new (...args: any): any;
1515
+ }
1516
+
1517
+ export type ConstructorLikeKeys<T> = keyof {
1518
+ [K in keyof T as Required<T>[K] extends ClassLike ? K : never]: T[K];
1519
+ };
1520
+
1521
+ // export const fn: <T extends FunctionLike = UnknownFunction>(
1522
+ // implementation?: T | undefined,
1523
+ // ) => Mock<T>;
1524
+
1525
+ export type FunctionLike = (...args: any) => any;
1526
+
1527
+ export type MethodLikeKeys<T> = keyof {
1528
+ [K in keyof T as Required<T>[K] extends FunctionLike ? K : never]: T[K];
1529
+ };
1530
+
1531
+ export interface Mock<T extends (...args: any[]) => any> extends MockInstance<T> {
1532
+ (...args: Parameters<T>): ReturnType<T>;
1533
+ }
1534
+
1535
+ /**
1536
+ * All what the internal typings need is to be sure that we have any-function.
1537
+ * `FunctionLike` type ensures that and helps to constrain the type as well.
1538
+ * The default of `UnknownFunction` makes sure that `any`s do not leak to the
1539
+ * user side. For instance, calling `fn()` without implementation will return
1540
+ * a mock of `(...args: Array<unknown>) => unknown` type. If implementation
1541
+ * is provided, its typings are inferred correctly.
1542
+ */
1543
+ // export interface Mock<T extends FunctionLike = UnknownFunction>
1544
+ // extends Function,
1545
+ // MockInstance<T> {
1546
+ // new (...args: Parameters<T>): ReturnType<T>;
1547
+ // (...args: Parameters<T>): ReturnType<T>;
1548
+ // }
1549
+
1550
+ // export type Mocked<T> = T extends ClassLike
1551
+ // ? MockedClass<T>
1552
+ // : T extends FunctionLike
1553
+ // ? MockedFunction<T>
1554
+ // : T extends object
1555
+ // ? MockedObject<T>
1556
+ // : T;
1557
+
1558
+ // export const mocked: {
1559
+ // <T extends object>(
1560
+ // source: T,
1561
+ // options?: {
1562
+ // shallow: false;
1563
+ // },
1564
+ // ): Mocked<T>;
1565
+ // <T_1 extends object>(
1566
+ // source: T_1,
1567
+ // options: {
1568
+ // shallow: true;
1569
+ // },
1570
+ // ): MockedShallow<T_1>;
1571
+ // };
1572
+
1573
+ // export type MockedClass<T extends ClassLike> = MockInstance<
1574
+ // (...args: ConstructorParameters<T>) => Mocked<InstanceType<T>>
1575
+ // > &
1576
+ // MockedObject<T>;
1577
+
1578
+ // export type MockedFunction<T extends FunctionLike> = MockInstance<T> &
1579
+ // MockedObject<T>;
1580
+
1581
+ // type MockedFunctionShallow<T extends FunctionLike> = MockInstance<T> & T;
1582
+
1583
+ // export type MockedObject<T extends object> = {
1584
+ // [K in keyof T]: T[K] extends ClassLike
1585
+ // ? MockedClass<T[K]>
1586
+ // : T[K] extends FunctionLike
1587
+ // ? MockedFunction<T[K]>
1588
+ // : T[K] extends object
1589
+ // ? MockedObject<T[K]>
1590
+ // : T[K];
1591
+ // } & T;
1592
+
1593
+ // type MockedObjectShallow<T extends object> = {
1594
+ // [K in keyof T]: T[K] extends ClassLike
1595
+ // ? MockedClass<T[K]>
1596
+ // : T[K] extends FunctionLike
1597
+ // ? MockedFunctionShallow<T[K]>
1598
+ // : T[K];
1599
+ // } & T;
1600
+
1601
+ // export type MockedShallow<T> = T extends ClassLike
1602
+ // ? MockedClass<T>
1603
+ // : T extends FunctionLike
1604
+ // ? MockedFunctionShallow<T>
1605
+ // : T extends object
1606
+ // ? MockedObjectShallow<T>
1607
+ // : T;
1608
+
1609
+ // export type MockFunctionMetadata<
1610
+ // T = unknown,
1611
+ // MetadataType = MockMetadataType,
1612
+ // > = MockMetadata<T, MetadataType>;
1613
+
1614
+ // export type MockFunctionMetadataType = MockMetadataType;
1615
+
1616
+ type MockFunctionResult<T extends FunctionLike = UnknownFunction> =
1617
+ | MockFunctionResultIncomplete
1618
+ | MockFunctionResultReturn<T>
1619
+ | MockFunctionResultThrow;
1620
+
1621
+ interface MockFunctionResultIncomplete {
1622
+ type: "incomplete";
1623
+ /**
1624
+ * Result of a single call to a mock function that has not yet completed.
1625
+ * This occurs if you test the result from within the mock function itself,
1626
+ * or from within a function that was called by the mock.
1627
+ */
1628
+ value: undefined;
1629
+ }
1630
+
1631
+ interface MockFunctionResultReturn<T extends FunctionLike = UnknownFunction> {
1632
+ type: "return";
1633
+ /**
1634
+ * Result of a single call to a mock function that returned.
1635
+ */
1636
+ value: ReturnType<T>;
1637
+ }
1638
+
1639
+ interface MockFunctionResultThrow {
1640
+ type: "throw";
1641
+ /**
1642
+ * Result of a single call to a mock function that threw.
1643
+ */
1644
+ value: unknown;
1645
+ }
1646
+
1647
+ interface MockFunctionState<T extends FunctionLike = FunctionLike> {
1648
+ /**
1649
+ * List of the call arguments of all calls that have been made to the mock.
1650
+ */
1651
+ calls: Array<Parameters<T>>;
1652
+ /**
1653
+ * List of all the object instances that have been instantiated from the mock.
1654
+ */
1655
+ instances: Array<ReturnType<T>>;
1656
+ /**
1657
+ * List of all the function contexts that have been applied to calls to the mock.
1658
+ */
1659
+ contexts: Array<ThisParameterType<T>>;
1660
+ /**
1661
+ * List of the call order indexes of the mock. Jest is indexing the order of
1662
+ * invocations of all mocks in a test file. The index is starting with `1`.
1663
+ */
1664
+ invocationCallOrder: number[];
1665
+ /**
1666
+ * List of the call arguments of the last call that was made to the mock.
1667
+ * If the function was not called, it will return `undefined`.
1668
+ */
1669
+ lastCall?: Parameters<T>;
1670
+ /**
1671
+ * List of the results of all calls that have been made to the mock.
1672
+ */
1673
+ results: Array<MockFunctionResult<T>>;
1674
+ }
1675
+
1676
+ export interface MockInstance<T extends FunctionLike = UnknownFunction> {
1677
+ _isMockFunction: true;
1678
+ _protoImpl: Function;
1679
+ getMockImplementation(): T | undefined;
1680
+ getMockName(): string;
1681
+ mock: MockFunctionState<T>;
1682
+ mockClear(): this;
1683
+ mockReset(): this;
1684
+ mockRestore(): void;
1685
+ mockImplementation(fn: T): this;
1686
+ mockImplementationOnce(fn: T): this;
1687
+ withImplementation(fn: T, callback: () => Promise<unknown>): Promise<void>;
1688
+ withImplementation(fn: T, callback: () => void): void;
1689
+ mockName(name: string): this;
1690
+ mockReturnThis(): this;
1691
+ mockReturnValue(value: ReturnType<T>): this;
1692
+ mockReturnValueOnce(value: ReturnType<T>): this;
1693
+ mockResolvedValue(value: ResolveType<T>): this;
1694
+ mockResolvedValueOnce(value: ResolveType<T>): this;
1695
+ mockRejectedValue(value: RejectType<T>): this;
1696
+ mockRejectedValueOnce(value: RejectType<T>): this;
1697
+ }
1698
+
1699
+ // export type MockMetadata<T, MetadataType = MockMetadataType> = {
1700
+ // ref?: number;
1701
+ // members?: Record<string, MockMetadata<T>>;
1702
+ // mockImpl?: T;
1703
+ // name?: string;
1704
+ // refID?: number;
1705
+ // type?: MetadataType;
1706
+ // value?: T;
1707
+ // length?: number;
1708
+ // };
1709
+
1710
+ // export type MockMetadataType =
1711
+ // | "object"
1712
+ // | "array"
1713
+ // | "regexp"
1714
+ // | "function"
1715
+ // | "constant"
1716
+ // | "collection"
1717
+ // | "null"
1718
+ // | "undefined";
1719
+
1720
+ // export class ModuleMocker {
1721
+ // private readonly _environmentGlobal;
1722
+ // private _mockState;
1723
+ // private _mockConfigRegistry;
1724
+ // private _spyState;
1725
+ // private _invocationCallCounter;
1726
+ // /**
1727
+ // * @see README.md
1728
+ // * @param global Global object of the test environment, used to create
1729
+ // * mocks
1730
+ // */
1731
+ // constructor(global: typeof globalThis);
1732
+ // private _getSlots;
1733
+ // private _ensureMockConfig;
1734
+ // private _ensureMockState;
1735
+ // private _defaultMockConfig;
1736
+ // private _defaultMockState;
1737
+ // private _makeComponent;
1738
+ // private _createMockFunction;
1739
+ // private _generateMock;
1740
+ // /**
1741
+ // * Check whether the given property of an object has been already replaced.
1742
+ // */
1743
+ // private _findReplacedProperty;
1744
+ // /**
1745
+ // * @see README.md
1746
+ // * @param metadata Metadata for the mock in the schema returned by the
1747
+ // * getMetadata method of this module.
1748
+ // */
1749
+ // generateFromMetadata<T>(metadata: MockMetadata<T>): Mocked<T>;
1750
+ // /**
1751
+ // * @see README.md
1752
+ // * @param component The component for which to retrieve metadata.
1753
+ // */
1754
+ // getMetadata<T = unknown>(
1755
+ // component: T,
1756
+ // _refs?: Map<T, number>,
1757
+ // ): MockMetadata<T> | null;
1758
+ // isMockFunction<T extends FunctionLike = UnknownFunction>(
1759
+ // fn: MockInstance<T>,
1760
+ // ): fn is MockInstance<T>;
1761
+ // isMockFunction<P extends Array<unknown>, R>(
1762
+ // fn: (...args: P) => R,
1763
+ // ): fn is Mock<(...args: P) => R>;
1764
+ // isMockFunction(fn: unknown): fn is Mock<UnknownFunction>;
1765
+ // fn<T extends FunctionLike = UnknownFunction>(implementation?: T): Mock<T>;
1766
+ // private _attachMockImplementation;
1767
+ // spyOn<
1768
+ // T extends object,
1769
+ // K extends PropertyLikeKeys<T>,
1770
+ // A extends "get" | "set",
1771
+ // >(
1772
+ // object: T,
1773
+ // methodKey: K,
1774
+ // accessType: A,
1775
+ // ): A extends "get"
1776
+ // ? SpiedGetter<T[K]>
1777
+ // : A extends "set"
1778
+ // ? SpiedSetter<T[K]>
1779
+ // : never;
1780
+ // spyOn<
1781
+ // T extends object,
1782
+ // K extends ConstructorLikeKeys<T> | MethodLikeKeys<T>,
1783
+ // V extends Required<T>[K],
1784
+ // >(
1785
+ // object: T,
1786
+ // methodKey: K,
1787
+ // ): V extends ClassLike | FunctionLike ? Spied<V> : never;
1788
+ // private _spyOnProperty;
1789
+ // replaceProperty<
1790
+ // T extends object,
1791
+ // K extends PropertyLikeKeys<T>,
1792
+ // V extends T[K],
1793
+ // >(object: T, propertyKey: K, value: V): Replaced<T[K]>;
1794
+ // clearAllMocks(): void;
1795
+ // resetAllMocks(): void;
1796
+ // restoreAllMocks(): void;
1797
+ // private _typeOf;
1798
+ // mocked<T extends object>(
1799
+ // source: T,
1800
+ // options?: {
1801
+ // shallow: false;
1802
+ // },
1803
+ // ): Mocked<T>;
1804
+ // mocked<T extends object>(
1805
+ // source: T,
1806
+ // options: {
1807
+ // shallow: true;
1808
+ // },
1809
+ // ): MockedShallow<T>;
1810
+ // }
1811
+
1812
+ export type PropertyLikeKeys<T> = Exclude<keyof T, ConstructorLikeKeys<T> | MethodLikeKeys<T>>;
1813
+
1814
+ export type RejectType<T extends FunctionLike> = ReturnType<T> extends PromiseLike<any> ? unknown : never;
1815
+
1816
+ export interface Replaced<T = unknown> {
1817
+ /**
1818
+ * Restore property to its original value known at the time of mocking.
1819
+ */
1820
+ restore(): void;
1821
+ /**
1822
+ * Change the value of the property.
1823
+ */
1824
+ replaceValue(value: T): this;
1825
+ }
1826
+
1827
+ export function replaceProperty<
1828
+ T extends object,
1829
+ K_2 extends Exclude<
1830
+ keyof T,
1831
+ | keyof {
1832
+ [K in keyof T as Required<T>[K] extends ClassLike ? K : never]: T[K];
1833
+ }
1834
+ | keyof {
1835
+ [K_1 in keyof T as Required<T>[K_1] extends FunctionLike ? K_1 : never]: T[K_1];
1836
+ }
1837
+ >,
1838
+ V extends T[K_2],
1839
+ >(object: T, propertyKey: K_2, value: V): Replaced<T[K_2]>;
1840
+
1841
+ export type ResolveType<T extends FunctionLike> = ReturnType<T> extends PromiseLike<infer U> ? U : never;
1842
+
1843
+ export type Spied<T extends ClassLike | FunctionLike> = T extends ClassLike
1844
+ ? SpiedClass<T>
1845
+ : T extends FunctionLike
1846
+ ? SpiedFunction<T>
1847
+ : never;
1848
+
1849
+ export type SpiedClass<T extends ClassLike = UnknownClass> = MockInstance<
1850
+ (...args: ConstructorParameters<T>) => InstanceType<T>
1851
+ >;
1852
+
1853
+ export type SpiedFunction<T extends FunctionLike = UnknownFunction> = MockInstance<
1854
+ (...args: Parameters<T>) => ReturnType<T>
1855
+ >;
1856
+
1857
+ export type SpiedGetter<T> = MockInstance<() => T>;
1858
+
1859
+ export type SpiedSetter<T> = MockInstance<(arg: T) => void>;
1860
+
1861
+ export interface SpyInstance<T extends FunctionLike = UnknownFunction> extends MockInstance<T> {}
1862
+
1863
+ export const spyOn: {
1864
+ <
1865
+ T extends object,
1866
+ K_2 extends Exclude<
1867
+ keyof T,
1868
+ | keyof {
1869
+ [K in keyof T as Required<T>[K] extends ClassLike ? K : never]: T[K];
1870
+ }
1871
+ | keyof {
1872
+ [K_1 in keyof T as Required<T>[K_1] extends FunctionLike ? K_1 : never]: T[K_1];
1873
+ }
1874
+ >,
1875
+ V extends Required<T>[K_2],
1876
+ A extends "set" | "get",
1877
+ >(
1878
+ object: T,
1879
+ methodKey: K_2,
1880
+ accessType: A,
1881
+ ): A extends "get" ? SpiedGetter<V> : A extends "set" ? SpiedSetter<V> : never;
1882
+ <
1883
+ T_1 extends object,
1884
+ K_5 extends
1885
+ | keyof {
1886
+ [K_3 in keyof T_1 as Required<T_1>[K_3] extends ClassLike ? K_3 : never]: T_1[K_3];
1887
+ }
1888
+ | keyof {
1889
+ [K_4 in keyof T_1 as Required<T_1>[K_4] extends FunctionLike ? K_4 : never]: T_1[K_4];
1890
+ },
1891
+ V_1 extends Required<T_1>[K_5],
1892
+ >(
1893
+ object: T_1,
1894
+ methodKey: K_5,
1895
+ ): V_1 extends ClassLike | FunctionLike ? Spied<V_1> : never;
1896
+ };
1897
+
1898
+ export interface UnknownClass {
1899
+ new (...args: unknown[]): unknown;
1900
+ }
1901
+
1902
+ export type UnknownFunction = (...args: unknown[]) => unknown;
1903
+ }