@storybook/test 0.0.0-pr-24225-sha-d42b137f → 0.0.0-pr-23888-sha-39ed28da

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -1,10 +1,496 @@
1
- import { AsymmetricMatchersContaining, MatchersObject, MatcherState, JestAssertion, ExpectStatic } from '@vitest/expect';
2
1
  import { TestingLibraryMatchers } from '@testing-library/jest-dom/types/matchers';
3
- export * from '@vitest/spy';
4
2
  import * as _testing_library_user_event_dist_types_setup_directApi from '@testing-library/user-event/dist/types/setup/directApi';
5
3
  import * as _testing_library_user_event_dist_types_setup_setup from '@testing-library/user-event/dist/types/setup/setup';
6
4
  import * as domTestingLibrary from '@testing-library/dom';
7
5
 
6
+ interface Constructable$1 {
7
+ new (...args: any[]): any;
8
+ }
9
+
10
+ declare const Modifier: unique symbol;
11
+ declare const Hint: unique symbol;
12
+ declare const Kind: unique symbol;
13
+ type Evaluate<T> = T extends infer O ? {
14
+ [K in keyof O]: O[K];
15
+ } : never;
16
+ type TReadonly<T extends TSchema> = T & {
17
+ [Modifier]: 'Readonly';
18
+ };
19
+ type TOptional<T extends TSchema> = T & {
20
+ [Modifier]: 'Optional';
21
+ };
22
+ type TReadonlyOptional<T extends TSchema> = T & {
23
+ [Modifier]: 'ReadonlyOptional';
24
+ };
25
+ interface SchemaOptions {
26
+ $schema?: string;
27
+ /** Id for this schema */
28
+ $id?: string;
29
+ /** Title of this schema */
30
+ title?: string;
31
+ /** Description of this schema */
32
+ description?: string;
33
+ /** Default value for this schema */
34
+ default?: any;
35
+ /** Example values matching this schema */
36
+ examples?: any;
37
+ [prop: string]: any;
38
+ }
39
+ interface TKind {
40
+ [Kind]: string;
41
+ }
42
+ interface TSchema extends SchemaOptions, TKind {
43
+ [Modifier]?: string;
44
+ [Hint]?: string;
45
+ params: unknown[];
46
+ static: unknown;
47
+ }
48
+ interface NumericOptions<N extends number | bigint> extends SchemaOptions {
49
+ exclusiveMaximum?: N;
50
+ exclusiveMinimum?: N;
51
+ maximum?: N;
52
+ minimum?: N;
53
+ multipleOf?: N;
54
+ }
55
+ interface TBoolean extends TSchema {
56
+ [Kind]: 'Boolean';
57
+ static: boolean;
58
+ type: 'boolean';
59
+ }
60
+ interface TNull extends TSchema {
61
+ [Kind]: 'Null';
62
+ static: null;
63
+ type: 'null';
64
+ }
65
+ interface TNumber extends TSchema, NumericOptions<number> {
66
+ [Kind]: 'Number';
67
+ static: number;
68
+ type: 'number';
69
+ }
70
+ type ReadonlyOptionalPropertyKeys<T extends TProperties> = {
71
+ [K in keyof T]: T[K] extends TReadonlyOptional<TSchema> ? K : never;
72
+ }[keyof T];
73
+ type ReadonlyPropertyKeys<T extends TProperties> = {
74
+ [K in keyof T]: T[K] extends TReadonly<TSchema> ? K : never;
75
+ }[keyof T];
76
+ type OptionalPropertyKeys<T extends TProperties> = {
77
+ [K in keyof T]: T[K] extends TOptional<TSchema> ? K : never;
78
+ }[keyof T];
79
+ type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
80
+ type PropertiesReducer<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<(Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>)>;
81
+ type PropertiesReduce<T extends TProperties, P extends unknown[]> = PropertiesReducer<T, {
82
+ [K in keyof T]: Static<T[K], P>;
83
+ }>;
84
+ type TProperties = Record<keyof any, TSchema>;
85
+ type TAdditionalProperties = undefined | TSchema | boolean;
86
+ interface ObjectOptions extends SchemaOptions {
87
+ additionalProperties?: TAdditionalProperties;
88
+ minProperties?: number;
89
+ maxProperties?: number;
90
+ }
91
+ interface TObject<T extends TProperties = TProperties> extends TSchema, ObjectOptions {
92
+ [Kind]: 'Object';
93
+ static: PropertiesReduce<T, this['params']>;
94
+ additionalProperties?: TAdditionalProperties;
95
+ type: 'object';
96
+ properties: T;
97
+ required?: string[];
98
+ }
99
+ interface StringOptions<Format extends string> extends SchemaOptions {
100
+ minLength?: number;
101
+ maxLength?: number;
102
+ pattern?: string;
103
+ format?: Format;
104
+ contentEncoding?: '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64';
105
+ contentMediaType?: string;
106
+ }
107
+ interface TString<Format extends string = string> extends TSchema, StringOptions<Format> {
108
+ [Kind]: 'String';
109
+ static: string;
110
+ type: 'string';
111
+ }
112
+ /** Creates a TypeScript static type from a TypeBox type */
113
+ type Static<T extends TSchema, P extends unknown[] = []> = (T & {
114
+ params: P;
115
+ })['static'];
116
+
117
+ /**
118
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
119
+ *
120
+ * This source code is licensed under the MIT license found in the
121
+ * LICENSE file in the root directory of this source tree.
122
+ */
123
+
124
+
125
+ declare const RawSnapshotFormat: TObject<{
126
+ callToJSON: TReadonlyOptional<TBoolean>;
127
+ compareKeys: TReadonlyOptional<TNull>;
128
+ escapeRegex: TReadonlyOptional<TBoolean>;
129
+ escapeString: TReadonlyOptional<TBoolean>;
130
+ highlight: TReadonlyOptional<TBoolean>;
131
+ indent: TReadonlyOptional<TNumber>;
132
+ maxDepth: TReadonlyOptional<TNumber>;
133
+ maxWidth: TReadonlyOptional<TNumber>;
134
+ min: TReadonlyOptional<TBoolean>;
135
+ printBasicPrototype: TReadonlyOptional<TBoolean>;
136
+ printFunctionName: TReadonlyOptional<TBoolean>;
137
+ theme: TReadonlyOptional<
138
+ TObject<{
139
+ comment: TReadonlyOptional<TString<string>>;
140
+ content: TReadonlyOptional<TString<string>>;
141
+ prop: TReadonlyOptional<TString<string>>;
142
+ tag: TReadonlyOptional<TString<string>>;
143
+ value: TReadonlyOptional<TString<string>>;
144
+ }>
145
+ >;
146
+ }>;
147
+
148
+ declare const SnapshotFormat: TObject<{
149
+ callToJSON: TReadonlyOptional<TBoolean>;
150
+ compareKeys: TReadonlyOptional<TNull>;
151
+ escapeRegex: TReadonlyOptional<TBoolean>;
152
+ escapeString: TReadonlyOptional<TBoolean>;
153
+ highlight: TReadonlyOptional<TBoolean>;
154
+ indent: TReadonlyOptional<TNumber>;
155
+ maxDepth: TReadonlyOptional<TNumber>;
156
+ maxWidth: TReadonlyOptional<TNumber>;
157
+ min: TReadonlyOptional<TBoolean>;
158
+ printBasicPrototype: TReadonlyOptional<TBoolean>;
159
+ printFunctionName: TReadonlyOptional<TBoolean>;
160
+ theme: TReadonlyOptional<
161
+ TObject<{
162
+ comment: TReadonlyOptional<TString<string>>;
163
+ content: TReadonlyOptional<TString<string>>;
164
+ prop: TReadonlyOptional<TString<string>>;
165
+ tag: TReadonlyOptional<TString<string>>;
166
+ value: TReadonlyOptional<TString<string>>;
167
+ }>
168
+ >;
169
+ }>;
170
+
171
+ declare type SnapshotFormat = Static<typeof RawSnapshotFormat>;
172
+
173
+ /**
174
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
175
+ *
176
+ * This source code is licensed under the MIT license found in the
177
+ * LICENSE file in the root directory of this source tree.
178
+ */
179
+
180
+
181
+ declare type Colors = {
182
+ comment: {
183
+ close: string;
184
+ open: string;
185
+ };
186
+ content: {
187
+ close: string;
188
+ open: string;
189
+ };
190
+ prop: {
191
+ close: string;
192
+ open: string;
193
+ };
194
+ tag: {
195
+ close: string;
196
+ open: string;
197
+ };
198
+ value: {
199
+ close: string;
200
+ open: string;
201
+ };
202
+ };
203
+
204
+ declare type CompareKeys =
205
+ | ((a: string, b: string) => number)
206
+ | null
207
+ | undefined;
208
+
209
+ declare type Config = {
210
+ callToJSON: boolean;
211
+ compareKeys: CompareKeys;
212
+ colors: Colors;
213
+ escapeRegex: boolean;
214
+ escapeString: boolean;
215
+ indent: string;
216
+ maxDepth: number;
217
+ maxWidth: number;
218
+ min: boolean;
219
+ plugins: Plugins;
220
+ printBasicPrototype: boolean;
221
+ printFunctionName: boolean;
222
+ spacingInner: string;
223
+ spacingOuter: string;
224
+ };
225
+
226
+ declare type Indent = (arg0: string) => string;
227
+
228
+ declare type NewPlugin = {
229
+ serialize: (
230
+ val: any,
231
+ config: Config,
232
+ indentation: string,
233
+ depth: number,
234
+ refs: Refs,
235
+ printer: Printer,
236
+ ) => string;
237
+ test: Test;
238
+ };
239
+
240
+ declare type OldPlugin = {
241
+ print: (
242
+ val: unknown,
243
+ print: Print,
244
+ indent: Indent,
245
+ options: PluginOptions,
246
+ colors: Colors,
247
+ ) => string;
248
+ test: Test;
249
+ };
250
+
251
+ declare type Plugin_2 = NewPlugin | OldPlugin;
252
+
253
+
254
+ declare type PluginOptions = {
255
+ edgeSpacing: string;
256
+ min: boolean;
257
+ spacing: string;
258
+ };
259
+
260
+ declare type Plugins = Array<Plugin_2>;
261
+
262
+ declare interface PrettyFormatOptions
263
+ extends Omit<SnapshotFormat, 'compareKeys'> {
264
+ compareKeys?: CompareKeys;
265
+ plugins?: Plugins;
266
+ }
267
+
268
+ declare type Print = (arg0: unknown) => string;
269
+
270
+ declare type Printer = (
271
+ val: unknown,
272
+ config: Config,
273
+ indentation: string,
274
+ depth: number,
275
+ refs: Refs,
276
+ hasCalledToJSON?: boolean,
277
+ ) => string;
278
+
279
+ declare type Refs = Array<unknown>;
280
+
281
+ declare type Test = (arg0: any) => boolean;
282
+
283
+ declare function stringify(object: unknown, maxDepth?: number, { maxLength, ...options }?: PrettyFormatOptions & {
284
+ maxLength?: number;
285
+ }): string;
286
+
287
+ /**
288
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
289
+ *
290
+ * This source code is licensed under the MIT license found in the
291
+ * LICENSE file in the root directory of this source tree.
292
+ */
293
+
294
+ type DiffOptionsColor = (arg: string) => string;
295
+ interface DiffOptions {
296
+ aAnnotation?: string;
297
+ aColor?: DiffOptionsColor;
298
+ aIndicator?: string;
299
+ bAnnotation?: string;
300
+ bColor?: DiffOptionsColor;
301
+ bIndicator?: string;
302
+ changeColor?: DiffOptionsColor;
303
+ changeLineTrailingSpaceColor?: DiffOptionsColor;
304
+ commonColor?: DiffOptionsColor;
305
+ commonIndicator?: string;
306
+ commonLineTrailingSpaceColor?: DiffOptionsColor;
307
+ contextLines?: number;
308
+ emptyFirstOrLastLinePlaceholder?: string;
309
+ expand?: boolean;
310
+ includeChangeCounts?: boolean;
311
+ omitAnnotationLines?: boolean;
312
+ patchColor?: DiffOptionsColor;
313
+ compareKeys?: CompareKeys;
314
+ }
315
+
316
+ /**
317
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
318
+ *
319
+ * This source code is licensed under the MIT license found in the
320
+ * LICENSE file in the root directory of this source tree.
321
+ */
322
+
323
+ /**
324
+ * @param a Expected value
325
+ * @param b Received value
326
+ * @param options Diff options
327
+ * @returns
328
+ */
329
+ declare function diff(a: any, b: any, options?: DiffOptions): string | null;
330
+
331
+ type Formatter = (input: string | number | null | undefined) => string;
332
+
333
+ declare function getMatcherUtils(): {
334
+ EXPECTED_COLOR: {
335
+ (input: unknown): string;
336
+ open: string;
337
+ close: string;
338
+ };
339
+ RECEIVED_COLOR: {
340
+ (input: unknown): string;
341
+ open: string;
342
+ close: string;
343
+ };
344
+ INVERTED_COLOR: {
345
+ (input: unknown): string;
346
+ open: string;
347
+ close: string;
348
+ };
349
+ BOLD_WEIGHT: {
350
+ (input: unknown): string;
351
+ open: string;
352
+ close: string;
353
+ };
354
+ DIM_COLOR: {
355
+ (input: unknown): string;
356
+ open: string;
357
+ close: string;
358
+ };
359
+ matcherHint: (matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions) => string;
360
+ printReceived: (object: unknown) => string;
361
+ printExpected: (value: unknown) => string;
362
+ };
363
+ type Tester = (a: any, b: any) => boolean | undefined;
364
+
365
+ interface MatcherHintOptions {
366
+ comment?: string;
367
+ expectedColor?: Formatter;
368
+ isDirectExpectCall?: boolean;
369
+ isNot?: boolean;
370
+ promise?: string;
371
+ receivedColor?: Formatter;
372
+ secondArgument?: string;
373
+ secondArgumentColor?: Formatter;
374
+ }
375
+ interface MatcherState {
376
+ assertionCalls: number;
377
+ currentTestName?: string;
378
+ dontThrow?: () => void;
379
+ error?: Error;
380
+ equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
381
+ expand?: boolean;
382
+ expectedAssertionsNumber?: number | null;
383
+ expectedAssertionsNumberErrorGen?: (() => Error) | null;
384
+ isExpectingAssertions?: boolean;
385
+ isExpectingAssertionsError?: Error | null;
386
+ isNot: boolean;
387
+ promise: string;
388
+ suppressedErrors: Array<Error>;
389
+ testPath?: string;
390
+ utils: ReturnType<typeof getMatcherUtils> & {
391
+ diff: typeof diff;
392
+ stringify: typeof stringify;
393
+ iterableEquality: Tester;
394
+ subsetEquality: Tester;
395
+ };
396
+ soft?: boolean;
397
+ }
398
+ interface SyncExpectationResult {
399
+ pass: boolean;
400
+ message: () => string;
401
+ actual?: any;
402
+ expected?: any;
403
+ }
404
+ type AsyncExpectationResult = Promise<SyncExpectationResult>;
405
+ type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
406
+ interface RawMatcherFn<T extends MatcherState = MatcherState> {
407
+ (this: T, received: any, expected: any, options?: any): ExpectationResult;
408
+ }
409
+ type MatchersObject<T extends MatcherState = MatcherState> = Record<string, RawMatcherFn<T>>;
410
+ interface ExpectStatic extends Chai.ExpectStatic, AsymmetricMatchersContaining {
411
+ <T>(actual: T, message?: string): Assertion$1<T>;
412
+ unreachable(message?: string): never;
413
+ soft<T>(actual: T, message?: string): Assertion$1<T>;
414
+ extend(expects: MatchersObject): void;
415
+ assertions(expected: number): void;
416
+ hasAssertions(): void;
417
+ anything(): any;
418
+ any(constructor: unknown): any;
419
+ getState(): MatcherState;
420
+ setState(state: Partial<MatcherState>): void;
421
+ not: AsymmetricMatchersContaining;
422
+ }
423
+ interface AsymmetricMatchersContaining {
424
+ stringContaining(expected: string): any;
425
+ objectContaining<T = any>(expected: T): any;
426
+ arrayContaining<T = unknown>(expected: Array<T>): any;
427
+ stringMatching(expected: string | RegExp): any;
428
+ }
429
+ interface JestAssertion<T = any> extends jest.Matchers<void, T> {
430
+ toEqual<E>(expected: E): void;
431
+ toStrictEqual<E>(expected: E): void;
432
+ toBe<E>(expected: E): void;
433
+ toMatch(expected: string | RegExp): void;
434
+ toMatchObject<E extends {} | any[]>(expected: E): void;
435
+ toContain<E>(item: E): void;
436
+ toContainEqual<E>(item: E): void;
437
+ toBeTruthy(): void;
438
+ toBeFalsy(): void;
439
+ toBeGreaterThan(num: number | bigint): void;
440
+ toBeGreaterThanOrEqual(num: number | bigint): void;
441
+ toBeLessThan(num: number | bigint): void;
442
+ toBeLessThanOrEqual(num: number | bigint): void;
443
+ toBeNaN(): void;
444
+ toBeUndefined(): void;
445
+ toBeNull(): void;
446
+ toBeDefined(): void;
447
+ toBeInstanceOf<E>(expected: E): void;
448
+ toBeCalledTimes(times: number): void;
449
+ toHaveLength(length: number): void;
450
+ toHaveProperty<E>(property: string | (string | number)[], value?: E): void;
451
+ toBeCloseTo(number: number, numDigits?: number): void;
452
+ toHaveBeenCalledTimes(times: number): void;
453
+ toHaveBeenCalled(): void;
454
+ toBeCalled(): void;
455
+ toHaveBeenCalledWith<E extends any[]>(...args: E): void;
456
+ toBeCalledWith<E extends any[]>(...args: E): void;
457
+ toHaveBeenNthCalledWith<E extends any[]>(n: number, ...args: E): void;
458
+ nthCalledWith<E extends any[]>(nthCall: number, ...args: E): void;
459
+ toHaveBeenLastCalledWith<E extends any[]>(...args: E): void;
460
+ lastCalledWith<E extends any[]>(...args: E): void;
461
+ toThrow(expected?: string | Constructable$1 | RegExp | Error): void;
462
+ toThrowError(expected?: string | Constructable$1 | RegExp | Error): void;
463
+ toReturn(): void;
464
+ toHaveReturned(): void;
465
+ toReturnTimes(times: number): void;
466
+ toHaveReturnedTimes(times: number): void;
467
+ toReturnWith<E>(value: E): void;
468
+ toHaveReturnedWith<E>(value: E): void;
469
+ toHaveLastReturnedWith<E>(value: E): void;
470
+ lastReturnedWith<E>(value: E): void;
471
+ toHaveNthReturnedWith<E>(nthCall: number, value: E): void;
472
+ nthReturnedWith<E>(nthCall: number, value: E): void;
473
+ }
474
+ type VitestAssertion<A, T> = {
475
+ [K in keyof A]: A[K] extends Chai.Assertion ? Assertion$1<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T>;
476
+ } & ((type: string, message?: string) => Assertion$1);
477
+ type Promisify$1<O> = {
478
+ [K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify$1<O[K]> : (...args: A) => Promise<R> : O[K];
479
+ };
480
+ interface Assertion$1<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAssertion<T> {
481
+ toBeTypeOf(expected: 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined'): void;
482
+ toHaveBeenCalledOnce(): void;
483
+ toSatisfy<E>(matcher: (value: E) => boolean, message?: string): void;
484
+ resolves: Promisify$1<Assertion$1<T>>;
485
+ rejects: Promisify$1<Assertion$1<T>>;
486
+ }
487
+ declare global {
488
+ namespace jest {
489
+ interface Matchers<R, T = {}> {
490
+ }
491
+ }
492
+ }
493
+
8
494
  type Promisify<Fn> = Fn extends (...args: infer A) => infer R ? (...args: A) => R extends Promise<any> ? R : Promise<R> : Fn;
9
495
  type PromisifyObject<O> = {
10
496
  [K in keyof O]: Promisify<O[K]>;
@@ -31,6 +517,136 @@ interface Expect extends AsymmetricMatchersContaining {
31
517
  not: AsymmetricMatchersContaining;
32
518
  }
33
519
 
520
+ declare const S: unique symbol;
521
+ declare type ReturnError = ['error', any];
522
+ declare type ReturnOk<R> = ['ok', R];
523
+ declare type ResultFn<R> = ReturnError | ReturnOk<R>;
524
+ interface SpyInternal<A extends any[] = any[], R = any> {
525
+ (this: any, ...args: A): R;
526
+ [S]: SpyInternalState<A, R>;
527
+ }
528
+ interface SpyInternalImpl<A extends any[] = any[], R = any> extends SpyInternal<A, R> {
529
+ [S]: SpyInternalImplState<A, R>;
530
+ }
531
+ interface SpyInternalState<A extends any[] = any[], R = any> {
532
+ called: boolean;
533
+ callCount: number;
534
+ calls: A[];
535
+ results: ResultFn<R>[];
536
+ reset(): void;
537
+ impl: ((...args: A) => R) | undefined;
538
+ next: ResultFn<R> | null;
539
+ }
540
+ interface SpyInternalImplState<A extends any[] = any[], R = any> extends SpyInternalState<A, R> {
541
+ getOriginal(): (...args: A) => R;
542
+ willCall(cb: (...args: A) => R): this;
543
+ restore(): void;
544
+ }
545
+
546
+ interface MockResultReturn<T> {
547
+ type: 'return';
548
+ value: T;
549
+ }
550
+ interface MockResultIncomplete {
551
+ type: 'incomplete';
552
+ value: undefined;
553
+ }
554
+ interface MockResultThrow {
555
+ type: 'throw';
556
+ value: any;
557
+ }
558
+ type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
559
+ interface MockContext<TArgs, TReturns> {
560
+ calls: TArgs[];
561
+ instances: TReturns[];
562
+ invocationCallOrder: number[];
563
+ results: MockResult<TReturns>[];
564
+ lastCall: TArgs | undefined;
565
+ }
566
+ type Procedure = (...args: any[]) => any;
567
+ type Methods<T> = {
568
+ [K in keyof T]: T[K] extends Procedure ? K : never;
569
+ }[keyof T] & (string | symbol);
570
+ type Properties<T> = {
571
+ [K in keyof T]: T[K] extends Procedure ? never : K;
572
+ }[keyof T] & (string | symbol);
573
+ type Classes<T> = {
574
+ [K in keyof T]: T[K] extends new (...args: any[]) => any ? K : never;
575
+ }[keyof T] & (string | symbol);
576
+ interface SpyInstance<TArgs extends any[] = any[], TReturns = any> {
577
+ getMockName(): string;
578
+ mockName(n: string): this;
579
+ mock: MockContext<TArgs, TReturns>;
580
+ mockClear(): this;
581
+ mockReset(): this;
582
+ mockRestore(): void;
583
+ getMockImplementation(): ((...args: TArgs) => TReturns) | undefined;
584
+ mockImplementation(fn: ((...args: TArgs) => TReturns) | (() => Promise<TReturns>)): this;
585
+ mockImplementationOnce(fn: ((...args: TArgs) => TReturns) | (() => Promise<TReturns>)): this;
586
+ withImplementation<T>(fn: ((...args: TArgs) => TReturns), cb: () => T): T extends Promise<unknown> ? Promise<this> : this;
587
+ mockReturnThis(): this;
588
+ mockReturnValue(obj: TReturns): this;
589
+ mockReturnValueOnce(obj: TReturns): this;
590
+ mockResolvedValue(obj: Awaited<TReturns>): this;
591
+ mockResolvedValueOnce(obj: Awaited<TReturns>): this;
592
+ mockRejectedValue(obj: any): this;
593
+ mockRejectedValueOnce(obj: any): this;
594
+ }
595
+ interface MockInstance<A extends any[] = any[], R = any> extends SpyInstance<A, R> {
596
+ }
597
+ interface Mock<TArgs extends any[] = any, TReturns = any> extends SpyInstance<TArgs, TReturns> {
598
+ new (...args: TArgs): TReturns;
599
+ (...args: TArgs): TReturns;
600
+ }
601
+ interface PartialMock<TArgs extends any[] = any, TReturns = any> extends SpyInstance<TArgs, TReturns extends Promise<Awaited<TReturns>> ? Promise<Partial<Awaited<TReturns>>> : Partial<TReturns>> {
602
+ new (...args: TArgs): TReturns;
603
+ (...args: TArgs): TReturns;
604
+ }
605
+ type MaybeMockedConstructor<T> = T extends new (...args: Array<any>) => infer R ? Mock<ConstructorParameters<T>, R> : T;
606
+ type MockedFunction<T extends Procedure> = Mock<Parameters<T>, ReturnType<T>> & {
607
+ [K in keyof T]: T[K];
608
+ };
609
+ type PartiallyMockedFunction<T extends Procedure> = PartialMock<Parameters<T>, ReturnType<T>> & {
610
+ [K in keyof T]: T[K];
611
+ };
612
+ type MockedFunctionDeep<T extends Procedure> = Mock<Parameters<T>, ReturnType<T>> & MockedObjectDeep<T>;
613
+ type PartiallyMockedFunctionDeep<T extends Procedure> = PartialMock<Parameters<T>, ReturnType<T>> & MockedObjectDeep<T>;
614
+ type MockedObject<T> = MaybeMockedConstructor<T> & {
615
+ [K in Methods<T>]: T[K] extends Procedure ? MockedFunction<T[K]> : T[K];
616
+ } & {
617
+ [K in Properties<T>]: T[K];
618
+ };
619
+ type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
620
+ [K in Methods<T>]: T[K] extends Procedure ? MockedFunctionDeep<T[K]> : T[K];
621
+ } & {
622
+ [K in Properties<T>]: MaybeMockedDeep<T[K]>;
623
+ };
624
+ type MaybeMockedDeep<T> = T extends Procedure ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
625
+ type MaybePartiallyMockedDeep<T> = T extends Procedure ? PartiallyMockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
626
+ type MaybeMocked<T> = T extends Procedure ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
627
+ type MaybePartiallyMocked<T> = T extends Procedure ? PartiallyMockedFunction<T> : T extends object ? MockedObject<T> : T;
628
+ interface Constructable {
629
+ new (...args: any[]): any;
630
+ }
631
+ type MockedClass<T extends Constructable> = MockInstance<T extends new (...args: infer P) => any ? P : never, InstanceType<T>> & {
632
+ prototype: T extends {
633
+ prototype: any;
634
+ } ? Mocked<T['prototype']> : never;
635
+ } & T;
636
+ type Mocked<T> = {
637
+ [P in keyof T]: T[P] extends (...args: infer Args) => infer Returns ? MockInstance<Args, Returns> : T[P] extends Constructable ? MockedClass<T[P]> : T[P];
638
+ } & T;
639
+ type EnhancedSpy<TArgs extends any[] = any[], TReturns = any> = SpyInstance<TArgs, TReturns> & SpyInternalImpl<TArgs, TReturns>;
640
+ declare const spies: Set<SpyInstance<any[], any>>;
641
+ declare function isMockFunction(fn: any): fn is EnhancedSpy;
642
+ declare function spyOn<T, S extends Properties<Required<T>>>(obj: T, methodName: S, accessType: 'get'): SpyInstance<[], T[S]>;
643
+ declare function spyOn<T, G extends Properties<Required<T>>>(obj: T, methodName: G, accessType: 'set'): SpyInstance<[T[G]], void>;
644
+ declare function spyOn<T, M extends (Classes<Required<T>> | Methods<Required<T>>)>(obj: T, methodName: M): Required<T>[M] extends ({
645
+ new (...args: infer A): infer R;
646
+ }) | ((...args: infer A) => infer R) ? SpyInstance<A, R> : never;
647
+ declare function fn<TArgs extends any[] = any, R = any>(): Mock<TArgs, R>;
648
+ declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): Mock<TArgs, R>;
649
+
34
650
  declare const buildQueries: typeof domTestingLibrary.buildQueries;
35
651
  declare const configure: typeof domTestingLibrary.configure;
36
652
  declare const createEvent: domTestingLibrary.CreateObject & domTestingLibrary.CreateFunction;
@@ -125,4 +741,4 @@ declare const userEvent: {
125
741
 
126
742
  declare const expect: Expect;
127
743
 
128
- export { buildQueries, configure, createEvent, expect, findAllByAltText, findAllByDisplayValue, findAllByLabelText, findAllByPlaceholderText, findAllByRole, findAllByTestId, findAllByText, findAllByTitle, findByAltText, findByDisplayValue, findByLabelText, findByPlaceholderText, findByRole, findByTestId, findByText, findByTitle, fireEvent, getAllByAltText, getAllByDisplayValue, getAllByLabelText, getAllByPlaceholderText, getAllByRole, getAllByTestId, getAllByText, getAllByTitle, getByAltText, getByDisplayValue, getByLabelText, getByPlaceholderText, getByRole, getByTestId, getByText, getByTitle, getConfig, getDefaultNormalizer, getElementError, getNodeText, getQueriesForElement, getRoles, getSuggestedQuery, isInaccessible, logDOM, logRoles, prettyDOM, prettyFormat, queries, queryAllByAltText, queryAllByAttribute, queryAllByDisplayValue, queryAllByLabelText, queryAllByPlaceholderText, queryAllByRole, queryAllByTestId, queryAllByText, queryAllByTitle, queryByAltText, queryByAttribute, queryByDisplayValue, queryByLabelText, queryByPlaceholderText, queryByRole, queryByTestId, queryByText, queryByTitle, queryHelpers, screen, userEvent, waitFor, waitForElementToBeRemoved, within };
744
+ export { EnhancedSpy, MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MaybePartiallyMocked, MaybePartiallyMockedDeep, Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, PartialMock, PartiallyMockedFunction, PartiallyMockedFunctionDeep, SpyInstance, buildQueries, configure, createEvent, expect, findAllByAltText, findAllByDisplayValue, findAllByLabelText, findAllByPlaceholderText, findAllByRole, findAllByTestId, findAllByText, findAllByTitle, findByAltText, findByDisplayValue, findByLabelText, findByPlaceholderText, findByRole, findByTestId, findByText, findByTitle, fireEvent, fn, getAllByAltText, getAllByDisplayValue, getAllByLabelText, getAllByPlaceholderText, getAllByRole, getAllByTestId, getAllByText, getAllByTitle, getByAltText, getByDisplayValue, getByLabelText, getByPlaceholderText, getByRole, getByTestId, getByText, getByTitle, getConfig, getDefaultNormalizer, getElementError, getNodeText, getQueriesForElement, getRoles, getSuggestedQuery, isInaccessible, isMockFunction, logDOM, logRoles, prettyDOM, prettyFormat, queries, queryAllByAltText, queryAllByAttribute, queryAllByDisplayValue, queryAllByLabelText, queryAllByPlaceholderText, queryAllByRole, queryAllByTestId, queryAllByText, queryAllByTitle, queryByAltText, queryByAttribute, queryByDisplayValue, queryByLabelText, queryByPlaceholderText, queryByRole, queryByTestId, queryByText, queryByTitle, queryHelpers, screen, spies, spyOn, userEvent, waitFor, waitForElementToBeRemoved, within };