@rstest/core 0.7.7 → 0.7.9

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.
Files changed (57) hide show
  1. package/LICENSE.md +294 -0
  2. package/dist/0~130.js +2 -2
  3. package/dist/0~1472.js +48 -0
  4. package/dist/0~1981.js +3 -0
  5. package/dist/0~2173.js +25 -10
  6. package/dist/0~2255.js +2 -2
  7. package/dist/0~3062.js +0 -5
  8. package/dist/0~3919.js +1 -1
  9. package/dist/0~4403.js +6 -5
  10. package/dist/0~4809.js +4 -4
  11. package/dist/0~5835.js +2 -2
  12. package/dist/0~62.js +3 -3
  13. package/dist/0~6588.js +3 -3
  14. package/dist/0~6923.js +2 -2
  15. package/dist/0~7583.js +9 -8
  16. package/dist/0~7882.js +1144 -0
  17. package/dist/0~8426.js +1 -2
  18. package/dist/0~89.js +33 -24
  19. package/dist/0~9348.js +953 -0
  20. package/dist/0~9634.js +58 -10
  21. package/dist/1157.js +13 -118
  22. package/dist/{7913.js → 1294.js} +51 -1745
  23. package/dist/2672.js +647 -0
  24. package/dist/3278.js +3 -450
  25. package/dist/4484.js +38 -0
  26. package/dist/487.js +1739 -0
  27. package/dist/4899.js +11 -0
  28. package/dist/5734.js +1 -1
  29. package/dist/{0~6151.js → 6151.js} +169 -21
  30. package/dist/{0~6973.js → 6973.js} +5 -5
  31. package/dist/721.js +9 -0
  32. package/dist/9131.js +559 -502
  33. package/dist/browser-runtime/2~907.js +1211 -0
  34. package/dist/browser-runtime/2~907.js.map +1 -0
  35. package/dist/browser-runtime/389.js +22071 -0
  36. package/dist/browser-runtime/389.js.LICENSE.txt +329 -0
  37. package/dist/browser-runtime/389.js.map +1 -0
  38. package/dist/browser-runtime/index.d.ts +2806 -0
  39. package/dist/browser-runtime/index.js +1 -0
  40. package/dist/browser-runtime/rslib-runtime.js +50 -0
  41. package/dist/browser-runtime/rslib-runtime.js.map +1 -0
  42. package/dist/browser.d.ts +3329 -0
  43. package/dist/browser.js +14 -0
  44. package/dist/cssFilterLoader.mjs +1 -1
  45. package/dist/globalSetupWorker.js +3 -2
  46. package/dist/index.d.ts +67 -2
  47. package/dist/index.js +2 -1
  48. package/dist/rslib-runtime.js +27 -0
  49. package/dist/rstestSuppressWarnings.cjs +9 -0
  50. package/dist/worker.d.ts +66 -2
  51. package/dist/worker.js +415 -1
  52. package/package.json +29 -14
  53. package/dist/0~8957.js +0 -149
  54. package/dist/554.js +0 -417
  55. package/dist/5693.js +0 -91
  56. /package/dist/{7913.js.LICENSE.txt → 1294.js.LICENSE.txt} +0 -0
  57. /package/dist/{0~6151.js.LICENSE.txt → 6151.js.LICENSE.txt} +0 -0
@@ -0,0 +1,3329 @@
1
+ import type { assert as assert_2 } from 'chai';
2
+ import color from 'picocolors';
3
+ import type { config } from 'chai';
4
+ import { Logger } from 'rslog';
5
+ import * as rsbuild from '@rsbuild/core';
6
+ import type { RsbuildConfig } from '@rsbuild/core';
7
+ import type { Writable } from 'node:stream';
8
+
9
+ /**
10
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
11
+ *
12
+ * This source code is licensed under the MIT license found in the
13
+ * LICENSE file in the root directory of this source tree.
14
+ */
15
+
16
+ declare function addSerializer(plugin: Plugin_2): void;
17
+
18
+ export declare const afterAll: Rstest_2['afterAll'];
19
+
20
+ declare type AfterAllListener = (ctx: SuiteContext) => MaybePromise<void>;
21
+
22
+ export declare const afterEach: Rstest_2['afterEach'];
23
+
24
+ declare type AfterEachListener = (ctx: TestContext) => MaybePromise<void>;
25
+
26
+ export declare const assert: Rstest_2['assert'];
27
+
28
+ export declare interface Assertion<T = any> extends Assertion_2<T> {
29
+ matchSnapshot: SnapshotMatcher<T>;
30
+ toMatchSnapshot: SnapshotMatcher<T>;
31
+ toMatchInlineSnapshot: InlineSnapshotMatcher<T>;
32
+ /**
33
+ * Checks that an error thrown by a function matches a previously recorded snapshot.
34
+ *
35
+ * @param message - Optional custom error message.
36
+ *
37
+ * @example
38
+ * expect(functionWithError).toThrowErrorMatchingSnapshot();
39
+ */
40
+ toThrowErrorMatchingSnapshot: (message?: string) => void;
41
+ /**
42
+ * Checks that an error thrown by a function matches an inline snapshot within the test file.
43
+ * Useful for keeping snapshots close to the test code.
44
+ *
45
+ * @param snapshot - Optional inline snapshot string to match.
46
+ * @param message - Optional custom error message.
47
+ *
48
+ * @example
49
+ * const throwError = () => { throw new Error('Error occurred') };
50
+ * expect(throwError).toThrowErrorMatchingInlineSnapshot(`"Error occurred"`);
51
+ */
52
+ toThrowErrorMatchingInlineSnapshot: (snapshot?: string, message?: string) => void;
53
+ /**
54
+ * Compares the received value to a snapshot saved in a specified file.
55
+ * Useful for cases where snapshot content is large or needs to be shared across tests.
56
+ *
57
+ * @param filepath - Path to the snapshot file.
58
+ * @param message - Optional custom error message.
59
+ *
60
+ * @example
61
+ * await expect(largeData).toMatchFileSnapshot('path/to/snapshot.json');
62
+ */
63
+ toMatchFileSnapshot: (filepath: string, message?: string) => Promise<void>;
64
+ /**
65
+ * Verifies that a promise resolves.
66
+ *
67
+ * @example
68
+ * await expect(someAsyncFunc).resolves.toBe(42);
69
+ */
70
+ resolves: PromisifyAssertion_2<T>;
71
+ /**
72
+ * Verifies that a promise rejects.
73
+ *
74
+ * @example
75
+ * await expect(someAsyncFunc).rejects.toThrow('error');
76
+ */
77
+ rejects: PromisifyAssertion_2<T>;
78
+ }
79
+
80
+ declare interface Assertion_2<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAssertion<T>, Matchers<T> {
81
+ /**
82
+ * Ensures a value is of a specific type.
83
+ *
84
+ * @example
85
+ * expect(value).toBeTypeOf('string');
86
+ * expect(number).toBeTypeOf('number');
87
+ */
88
+ toBeTypeOf: (expected: "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined") => void;
89
+ /**
90
+ * Asserts that a mock function was called exactly once.
91
+ *
92
+ * @example
93
+ * expect(mockFunc).toHaveBeenCalledOnce();
94
+ */
95
+ toHaveBeenCalledOnce: () => void;
96
+ /**
97
+ * Ensure that a mock function is called with specific arguments and called
98
+ * exactly once.
99
+ *
100
+ * @example
101
+ * expect(mockFunc).toHaveBeenCalledExactlyOnceWith('arg1', 42);
102
+ */
103
+ toHaveBeenCalledExactlyOnceWith: <E extends any[]>(...args: E) => void;
104
+ /**
105
+ * This assertion checks if a `Mock` was called before another `Mock`.
106
+ * @param mock - A mock function created by `vi.spyOn` or `vi.fn`
107
+ * @param failIfNoFirstInvocation - Fail if the first mock was never called
108
+ * @example
109
+ * const mock1 = vi.fn()
110
+ * const mock2 = vi.fn()
111
+ *
112
+ * mock1()
113
+ * mock2()
114
+ * mock1()
115
+ *
116
+ * expect(mock1).toHaveBeenCalledBefore(mock2)
117
+ */
118
+ toHaveBeenCalledBefore: (mock: MockInstance, failIfNoFirstInvocation?: boolean) => void;
119
+ /**
120
+ * This assertion checks if a `Mock` was called after another `Mock`.
121
+ * @param mock - A mock function created by `vi.spyOn` or `vi.fn`
122
+ * @param failIfNoFirstInvocation - Fail if the first mock was never called
123
+ * @example
124
+ * const mock1 = vi.fn()
125
+ * const mock2 = vi.fn()
126
+ *
127
+ * mock2()
128
+ * mock1()
129
+ * mock2()
130
+ *
131
+ * expect(mock1).toHaveBeenCalledAfter(mock2)
132
+ */
133
+ toHaveBeenCalledAfter: (mock: MockInstance, failIfNoFirstInvocation?: boolean) => void;
134
+ /**
135
+ * Checks that a promise resolves successfully at least once.
136
+ *
137
+ * @example
138
+ * await expect(promise).toHaveResolved();
139
+ */
140
+ toHaveResolved: () => void;
141
+ /**
142
+ * Checks that a promise resolves to a specific value.
143
+ *
144
+ * @example
145
+ * await expect(promise).toHaveResolvedWith('success');
146
+ */
147
+ toHaveResolvedWith: <E>(value: E) => void;
148
+ /**
149
+ * Ensures a promise resolves a specific number of times.
150
+ *
151
+ * @example
152
+ * expect(mockAsyncFunc).toHaveResolvedTimes(3);
153
+ */
154
+ toHaveResolvedTimes: (times: number) => void;
155
+ /**
156
+ * Asserts that the last resolved value of a promise matches an expected value.
157
+ *
158
+ * @example
159
+ * await expect(mockAsyncFunc).toHaveLastResolvedWith('finalResult');
160
+ */
161
+ toHaveLastResolvedWith: <E>(value: E) => void;
162
+ /**
163
+ * Ensures a specific value was returned by a promise on the nth resolution.
164
+ *
165
+ * @example
166
+ * await expect(mockAsyncFunc).toHaveNthResolvedWith(2, 'secondResult');
167
+ */
168
+ toHaveNthResolvedWith: <E>(nthCall: number, value: E) => void;
169
+ /**
170
+ * Verifies that a promise resolves.
171
+ *
172
+ * @example
173
+ * await expect(someAsyncFunc).resolves.toBe(42);
174
+ */
175
+ resolves: PromisifyAssertion<T>;
176
+ /**
177
+ * Verifies that a promise rejects.
178
+ *
179
+ * @example
180
+ * await expect(someAsyncFunc).rejects.toThrow('error');
181
+ */
182
+ rejects: PromisifyAssertion<T>;
183
+ }
184
+
185
+ declare interface AssertOptions {
186
+ received: unknown;
187
+ filepath: string;
188
+ name: string;
189
+ /**
190
+ * Not required but needed for `SnapshotClient.clearTest` to implement test-retry behavior.
191
+ * @default name
192
+ */
193
+ testId?: string;
194
+ message?: string;
195
+ isInline?: boolean;
196
+ properties?: object;
197
+ inlineSnapshot?: string;
198
+ error?: Error;
199
+ errorMessage?: string;
200
+ rawSnapshot?: RawSnapshotInfo;
201
+ }
202
+
203
+ declare abstract class AsymmetricMatcher<
204
+ T,
205
+ State extends MatcherState = MatcherState
206
+ > implements AsymmetricMatcherInterface {
207
+ protected sample: T;
208
+ protected inverse: boolean;
209
+ // should have "jest" to be compatible with its ecosystem
210
+ $$typeof: symbol;
211
+ constructor(sample: T, inverse?: boolean);
212
+ protected getMatcherContext(expect?: Chai.ExpectStatic): State;
213
+ abstract asymmetricMatch(other: unknown): boolean;
214
+ abstract toString(): string;
215
+ getExpectedType?(): string;
216
+ toAsymmetricMatcher?(): string;
217
+ }
218
+
219
+ declare interface AsymmetricMatcherInterface {
220
+ asymmetricMatch: (other: unknown) => boolean;
221
+ toString: () => string;
222
+ getExpectedType?: () => string;
223
+ toAsymmetricMatcher?: () => string;
224
+ }
225
+
226
+ declare interface AsymmetricMatchersContaining extends CustomMatcher {
227
+ /**
228
+ * Matches if the received string contains the expected substring.
229
+ *
230
+ * @example
231
+ * expect('I have an apple').toEqual(expect.stringContaining('apple'));
232
+ * expect({ a: 'test string' }).toEqual({ a: expect.stringContaining('test') });
233
+ */
234
+ stringContaining: (expected: string) => any;
235
+ /**
236
+ * Matches if the received object contains all properties of the expected object.
237
+ *
238
+ * @example
239
+ * expect({ a: '1', b: 2 }).toEqual(expect.objectContaining({ a: '1' }))
240
+ */
241
+ objectContaining: <T = any>(expected: DeeplyAllowMatchers<T>) => any;
242
+ /**
243
+ * Matches if the received array contains all elements in the expected array.
244
+ *
245
+ * @example
246
+ * expect(['a', 'b', 'c']).toEqual(expect.arrayContaining(['b', 'a']));
247
+ */
248
+ arrayContaining: <T = unknown>(expected: Array<DeeplyAllowMatchers<T>>) => any;
249
+ /**
250
+ * Matches if the received string or regex matches the expected pattern.
251
+ *
252
+ * @example
253
+ * expect('hello world').toEqual(expect.stringMatching(/^hello/));
254
+ * expect('hello world').toEqual(expect.stringMatching('hello'));
255
+ */
256
+ stringMatching: (expected: string | RegExp) => any;
257
+ /**
258
+ * Matches if the received number is within a certain precision of the expected number.
259
+ *
260
+ * @param precision - Optional decimal precision for comparison. Default is 2.
261
+ *
262
+ * @example
263
+ * expect(10.45).toEqual(expect.closeTo(10.5, 1));
264
+ * expect(5.11).toEqual(expect.closeTo(5.12)); // with default precision
265
+ */
266
+ closeTo: (expected: number, precision?: number) => any;
267
+ }
268
+
269
+ declare type AsyncExpectationResult = Promise<SyncExpectationResult>;
270
+
271
+ export declare const beforeAll: Rstest_2['beforeAll'];
272
+
273
+ declare type BeforeAllListener = (ctx: SuiteContext) => MaybePromise<void | AfterAllListener>;
274
+
275
+ export declare const beforeEach: Rstest_2['beforeEach'];
276
+
277
+ declare type BeforeEachListener = (ctx: TestContext) => MaybePromise<void | AfterEachListener>;
278
+
279
+ declare interface BranchMapping {
280
+ loc: Range_2;
281
+ type: string;
282
+ locations: Range_2[];
283
+ line: number;
284
+ }
285
+
286
+ declare type BrowserModeConfig = {
287
+ /**
288
+ * Enable browser mode when running tests.
289
+ *
290
+ * @default false
291
+ */
292
+ enabled?: boolean;
293
+ /**
294
+ * Browser provider to use for running tests.
295
+ *
296
+ * Currently only 'playwright' is supported.
297
+ *
298
+ * @default 'playwright'
299
+ */
300
+ provider?: 'playwright';
301
+ /**
302
+ * Which browser to use for testing.
303
+ *
304
+ * - `chromium` - Google Chrome, Microsoft Edge
305
+ * - `firefox` - Mozilla Firefox
306
+ * - `webkit` - Safari
307
+ *
308
+ * @default 'chromium'
309
+ */
310
+ browser?: 'chromium' | 'firefox' | 'webkit';
311
+ /**
312
+ * Run browser in headless mode.
313
+ *
314
+ * @default Inferred from CI environment. `true` in CI, `false` otherwise.
315
+ */
316
+ headless?: boolean;
317
+ /**
318
+ * Port for the browser mode dev server.
319
+ *
320
+ * If not specified, a random available port will be used.
321
+ */
322
+ port?: number;
323
+ };
324
+
325
+ declare type BuiltInReporterNames = keyof typeof reportersMap;
326
+
327
+ declare type BuiltinReporterOptions = {
328
+ default: DefaultReporterOptions;
329
+ };
330
+
331
+ declare type ChaiConfig = Partial<Omit<typeof config, 'useProxy' | 'proxyExcludedKeys' | 'deepEqual'>>;
332
+
333
+ declare interface CloverOptions extends FileOptions, ProjectOptions {}
334
+
335
+ declare interface CoberturaOptions extends FileOptions, ProjectOptions {}
336
+
337
+ export { color }
338
+
339
+ /**
340
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
341
+ *
342
+ * This source code is licensed under the MIT license found in the
343
+ * LICENSE file in the root directory of this source tree.
344
+ */
345
+ declare interface Colors {
346
+ comment: {
347
+ close: string
348
+ open: string
349
+ };
350
+ content: {
351
+ close: string
352
+ open: string
353
+ };
354
+ prop: {
355
+ close: string
356
+ open: string
357
+ };
358
+ tag: {
359
+ close: string
360
+ open: string
361
+ };
362
+ value: {
363
+ close: string
364
+ open: string
365
+ };
366
+ }
367
+
368
+ declare type CompareKeys = ((a: string, b: string) => number) | null | undefined;
369
+
370
+ declare interface Config {
371
+ callToJSON: boolean;
372
+ compareKeys: CompareKeys;
373
+ colors: Colors;
374
+ escapeRegex: boolean;
375
+ escapeString: boolean;
376
+ indent: string;
377
+ maxDepth: number;
378
+ maxWidth: number;
379
+ min: boolean;
380
+ plugins: Plugins;
381
+ printBasicPrototype: boolean;
382
+ printFunctionName: boolean;
383
+ spacingInner: string;
384
+ spacingOuter: string;
385
+ }
386
+
387
+ declare interface Constructable {
388
+ new (...args: any[]): any;
389
+ }
390
+
391
+ /**
392
+ * Base class for writing content
393
+ */
394
+ declare class ContentWriter {
395
+ /**
396
+ * returns the colorized version of a string. Typically,
397
+ * content writers that write to files will return the
398
+ * same string and ones writing to a tty will wrap it in
399
+ * appropriate escape sequences.
400
+ */
401
+ colorize(str: string, clazz?: string): string;
402
+ /**
403
+ * writes a string appended with a newline to the destination
404
+ */
405
+ println(str: string): void;
406
+ /**
407
+ * closes this content writer. Should be called after all writes are complete.
408
+ */
409
+ close(): void;
410
+ }
411
+
412
+ declare interface Context {
413
+ data: any;
414
+ dir: string;
415
+ sourceFinder(filepath: string): string;
416
+ watermarks: Watermarks;
417
+ writer: FileWriter;
418
+ /**
419
+ * returns the coverage class given a coverage
420
+ * types and a percentage value.
421
+ */
422
+ classForPercent(type: keyof Watermarks, value: number): string;
423
+ /**
424
+ * returns the source code for the specified file path or throws if
425
+ * the source could not be found.
426
+ */
427
+ getSource(filepath: string): string;
428
+ getTree(summarizer?: Summarizers): Tree;
429
+ /**
430
+ * returns a full visitor given a partial one.
431
+ */
432
+ getVisitor<N extends Node_2 = Node_2>(visitor: Partial<Visitor<N>>): Visitor<N>;
433
+ /**
434
+ * returns a FileWriter implementation for reporting use. Also available
435
+ * as the `writer` property on the context.
436
+ */
437
+ getWriter(): FileWriter;
438
+ /**
439
+ * returns an XML writer for the supplied content writer
440
+ */
441
+ getXmlWriter(contentWriter: ContentWriter): XmlWriter;
442
+ }
443
+
444
+ declare class CounterMap<K> extends DefaultMap<K, number> {
445
+ constructor();
446
+ // compat for jest-image-snapshot https://github.com/vitest-dev/vitest/issues/7322
447
+ // `valueOf` and `Snapshot.added` setter allows
448
+ // snapshotState.added = snapshotState.added + 1
449
+ // to function as
450
+ // snapshotState.added.total_ = snapshotState.added.total() + 1
451
+ _total: number | undefined;
452
+ valueOf(): number;
453
+ increment(key: K): void;
454
+ total(): number;
455
+ }
456
+
457
+ declare interface Coverage {
458
+ covered: number;
459
+ total: number;
460
+ coverage: number;
461
+ }
462
+
463
+ declare interface CoverageMapData {
464
+ [key: string]: FileCoverage | FileCoverageData;
465
+ }
466
+
467
+ declare type CoverageOptions = {
468
+ /**
469
+ * Enable coverage collection.
470
+ * @default false
471
+ */
472
+ enabled?: boolean;
473
+ /**
474
+ * A list of glob patterns that should be included for coverage collection.
475
+ * Only collect coverage for tested files by default.
476
+ *
477
+ * @default undefined
478
+ */
479
+ include?: string[];
480
+ /**
481
+ * A list of glob patterns that should be excluded from coverage collection.
482
+ *
483
+ * This option accepts an array of wax(https://crates.io/crates/wax)-compatible glob patterns
484
+ *
485
+ * @default ['**\/node_modules/**',
486
+ * '**\/dist/**',
487
+ * '**\/test/**',
488
+ * '**\/__tests__/**',
489
+ * '**\/*.{test,spec}.?(c|m)[jt]s?(x)',
490
+ * '**\/__mocks__/**'
491
+ * ]
492
+ */
493
+ exclude?: string[];
494
+ /**
495
+ * The provider to use for coverage collection.
496
+ * @default 'istanbul'
497
+ */
498
+ provider?: 'istanbul';
499
+ /**
500
+ * The reporters to use for coverage collection.
501
+ * Supports built-in istanbul reporters and custom reporters (e.g., '@canyonjs/report-html').
502
+ * @default ['text', 'html', 'clover', 'json']
503
+ * @example
504
+ * // Built-in reporters
505
+ * reporters: ['text', 'html', ['json', { file: 'coverage.json' }]]
506
+ *
507
+ * // Custom reporters
508
+ * reporters: ['@canyonjs/report-html', ['custom-reporter', { outputDir: './reports' }]]
509
+ *
510
+ * // Mixed usage
511
+ * reporters: ['text', '@canyonjs/report-html', ['html', { subdir: 'html-report' }]]
512
+ */
513
+ reporters?: SupportedReporter[];
514
+ /**
515
+ * The directory to store coverage reports.
516
+ * @default './coverage'
517
+ */
518
+ reportsDirectory?: string;
519
+ /**
520
+ * Whether to clean the coverage directory before running tests.
521
+ * @default true
522
+ */
523
+ clean?: boolean;
524
+ /**
525
+ * Coverage thresholds
526
+ *
527
+ * @default undefined
528
+ */
529
+ thresholds?: CoverageThresholds;
530
+ /**
531
+ * Whether to report coverage when tests fail.
532
+ * @default false
533
+ */
534
+ reportOnFailure?: boolean;
535
+ };
536
+
537
+ declare class CoverageSummary {
538
+ constructor(data: CoverageSummary | CoverageSummaryData);
539
+ merge(obj: CoverageSummary): CoverageSummary;
540
+ toJSON(): CoverageSummaryData;
541
+ isEmpty(): boolean;
542
+ data: CoverageSummaryData;
543
+ lines: Totals;
544
+ statements: Totals;
545
+ branches: Totals;
546
+ functions: Totals;
547
+ }
548
+
549
+ declare interface CoverageSummaryData {
550
+ lines: Totals;
551
+ statements: Totals;
552
+ branches: Totals;
553
+ functions: Totals;
554
+ }
555
+
556
+ declare type CoverageThreshold = {
557
+ /** Threshold for statements */
558
+ statements?: number;
559
+ /** Threshold for functions */
560
+ functions?: number;
561
+ /** Threshold for branches */
562
+ branches?: number;
563
+ /** Threshold for lines */
564
+ lines?: number;
565
+ };
566
+
567
+ declare type CoverageThresholds = CoverageThreshold | (CoverageThreshold & ThresholdGlobRecord);
568
+
569
+ export declare const createRstestRuntime: (workerState: WorkerState) => Promise<{
570
+ runner: {
571
+ runTests: (testPath: string, hooks: RunnerHooks, api: Rstest_2) => Promise<TestFileResult>;
572
+ collectTests: () => Promise<Test[]>;
573
+ getCurrentTest: () => TestCase | undefined;
574
+ };
575
+ api: Rstest_2;
576
+ }>;
577
+
578
+ declare interface CustomMatcher {
579
+ /**
580
+ * Checks that a value satisfies a custom matcher function.
581
+ *
582
+ * @param matcher - A function returning a boolean based on the custom condition
583
+ * @param message - Optional custom error message on failure
584
+ *
585
+ * @example
586
+ * expect(age).toSatisfy(val => val >= 18, 'Age must be at least 18');
587
+ * expect(age).toEqual(expect.toSatisfy(val => val >= 18, 'Age must be at least 18'));
588
+ */
589
+ toSatisfy: (matcher: (value: any) => boolean, message?: string) => any;
590
+ /**
591
+ * Matches if the received value is one of the values in the expected array.
592
+ *
593
+ * @example
594
+ * expect(1).toBeOneOf([1, 2, 3])
595
+ * expect('foo').toBeOneOf([expect.any(String)])
596
+ * expect({ a: 1 }).toEqual({ a: expect.toBeOneOf(['1', '2', '3']) })
597
+ */
598
+ toBeOneOf: <T>(sample: Array<T>) => any;
599
+ }
600
+
601
+ /** Custom reporter configuration for non-istanbul reporters */
602
+ declare type CustomReporter = string | [string, Record<string, unknown>];
603
+
604
+ declare interface DecodedSourceMap extends SourceMapV3 {
605
+ mappings: SourceMapSegment[][];
606
+ }
607
+
608
+ declare type DecodedSourceMapXInput = DecodedSourceMap & XInput;
609
+
610
+ declare type DeeplyAllowMatchers<T> = T extends Array<infer Element> ? WithAsymmetricMatcher<T> | DeeplyAllowMatchers<Element>[] : T extends object ? WithAsymmetricMatcher<T> | { [K in keyof T] : DeeplyAllowMatchers<T[K]> } : WithAsymmetricMatcher<T>;
611
+
612
+ /**
613
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
614
+ *
615
+ * This source code is licensed under the MIT license found in the
616
+ * LICENSE file in the root directory of this source tree.
617
+ */
618
+
619
+ declare class DefaultMap<
620
+ K,
621
+ V
622
+ > extends Map<K, V> {
623
+ private defaultFn;
624
+ constructor(defaultFn: (key: K) => V, entries?: Iterable<readonly [K, V]>);
625
+ get(key: K): V;
626
+ }
627
+
628
+ declare class DefaultReporter implements Reporter {
629
+ protected rootPath: string;
630
+ protected config: NormalizedConfig;
631
+ private options;
632
+ protected statusRenderer: StatusRenderer | undefined;
633
+ private testState;
634
+ constructor({ rootPath, options, config, testState, }: {
635
+ rootPath: string;
636
+ config: NormalizedConfig;
637
+ options: DefaultReporterOptions;
638
+ testState: RstestTestState;
639
+ });
640
+ onTestFileStart(): void;
641
+ onTestFileResult(test: TestFileResult): void;
642
+ onTestCaseResult(): void;
643
+ onUserConsoleLog(log: UserConsoleLog): void;
644
+ onExit(): Promise<void>;
645
+ onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, unhandledErrors, }: {
646
+ results: TestFileResult[];
647
+ testResults: TestResult[];
648
+ duration: Duration;
649
+ snapshotSummary: SnapshotSummary;
650
+ getSourcemap: GetSourcemap;
651
+ unhandledErrors?: Error[];
652
+ filterRerunTestPaths?: string[];
653
+ }): Promise<void>;
654
+ }
655
+
656
+ declare type DefaultReporterOptions = {
657
+ /**
658
+ * prints out summary of all tests
659
+ * @default true
660
+ */
661
+ summary?: boolean;
662
+ /**
663
+ * logger which write messages to
664
+ * @default process.stdout/process.stderr
665
+ */
666
+ logger?: Options['logger'];
667
+ };
668
+
669
+ export declare const describe: Rstest_2['describe'];
670
+
671
+ declare type DescribeAPI = DescribeFn & {
672
+ each: DescribeEachFn;
673
+ for: DescribeForFn;
674
+ only: DescribeAPI;
675
+ skip: DescribeAPI;
676
+ runIf: (condition: boolean) => DescribeAPI;
677
+ skipIf: (condition: boolean) => DescribeAPI;
678
+ todo: DescribeAPI;
679
+ concurrent: DescribeAPI;
680
+ sequential: DescribeAPI;
681
+ };
682
+
683
+ declare interface DescribeEachFn {
684
+ <T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
685
+ <T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>) => void;
686
+ <T>(cases: readonly T[]): (description: string, fn: (param: T) => MaybePromise<void>) => void;
687
+ }
688
+
689
+ declare type DescribeFn = (description: string, fn?: () => void) => void;
690
+
691
+ declare type DescribeForFn = <T>(cases: readonly T[]) => (description: string, fn?: (param: T) => MaybePromise<void>) => void;
692
+
693
+ /**
694
+ * @param a Expected value
695
+ * @param b Received value
696
+ * @param options Diff options
697
+ * @returns {string | null} a string diff
698
+ */
699
+ declare function diff(a: any, b: any, options?: DiffOptions): string | undefined;
700
+
701
+ declare interface DiffOptions {
702
+ aAnnotation?: string;
703
+ aColor?: DiffOptionsColor;
704
+ aIndicator?: string;
705
+ bAnnotation?: string;
706
+ bColor?: DiffOptionsColor;
707
+ bIndicator?: string;
708
+ changeColor?: DiffOptionsColor;
709
+ changeLineTrailingSpaceColor?: DiffOptionsColor;
710
+ commonColor?: DiffOptionsColor;
711
+ commonIndicator?: string;
712
+ commonLineTrailingSpaceColor?: DiffOptionsColor;
713
+ contextLines?: number;
714
+ emptyFirstOrLastLinePlaceholder?: string;
715
+ expand?: boolean;
716
+ includeChangeCounts?: boolean;
717
+ omitAnnotationLines?: boolean;
718
+ patchColor?: DiffOptionsColor;
719
+ printBasicPrototype?: boolean;
720
+ maxDepth?: number;
721
+ compareKeys?: CompareKeys;
722
+ truncateThreshold?: number;
723
+ truncateAnnotation?: string;
724
+ truncateAnnotationColor?: DiffOptionsColor;
725
+ }
726
+
727
+ /**
728
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
729
+ *
730
+ * This source code is licensed under the MIT license found in the
731
+ * LICENSE file in the root directory of this source tree.
732
+ */
733
+
734
+ declare type DiffOptionsColor = (arg: string) => string;
735
+
736
+ /** The test file output path */
737
+ declare type DistPath = string;
738
+
739
+ declare type Duration = {
740
+ totalTime: number;
741
+ buildTime: number;
742
+ testTime: number;
743
+ };
744
+
745
+ declare interface EncodedSourceMap extends SourceMapV3 {
746
+ mappings: string;
747
+ }
748
+
749
+ declare type EncodedSourceMapXInput = EncodedSourceMap & XInput;
750
+
751
+ declare type EnvironmentName = 'node' | 'jsdom' | 'happy-dom';
752
+
753
+ declare type EnvironmentWithOptions = {
754
+ name: EnvironmentName;
755
+ options?: Record<string, any>;
756
+ };
757
+
758
+ export declare const expect: Rstest_2['expect'];
759
+
760
+ declare type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
761
+
762
+ declare interface ExpectPollOptions {
763
+ /**
764
+ * @default 50
765
+ */
766
+ interval?: number;
767
+ /**
768
+ * @default 1000
769
+ */
770
+ timeout?: number;
771
+ message?: string;
772
+ }
773
+
774
+ declare interface ExpectStatic extends ExpectStatic_2 {
775
+ <T>(actual: T, message?: string): Assertion<T>;
776
+ unreachable: (message?: string) => never;
777
+ soft: <T>(actual: T, message?: string) => Assertion<T>;
778
+ poll: <T>(actual: () => T, options?: ExpectPollOptions) => Omit<PromisifyAssertion_2<Awaited<T>>, 'rejects' | 'resolves' | 'toThrow' | 'toThrowError' | 'throw' | 'throws' | 'matchSnapshot' | 'toMatchSnapshot' | 'toMatchInlineSnapshot' | 'toThrowErrorMatchingSnapshot' | 'toThrowErrorMatchingInlineSnapshot'>;
779
+ addEqualityTesters: (testers: Tester[]) => void;
780
+ assertions: (expected: number) => void;
781
+ hasAssertions: () => void;
782
+ addSnapshotSerializer: typeof addSerializer;
783
+ getState: () => MatcherState_2;
784
+ setState: (state: Partial<MatcherState_2>) => void;
785
+ }
786
+
787
+ declare interface ExpectStatic_2 extends Chai.ExpectStatic, Matchers, AsymmetricMatchersContaining {
788
+ <T>(actual: T, message?: string): Assertion_2<T>;
789
+ extend: (expects: MatchersObject) => void;
790
+ anything: () => any;
791
+ any: (constructor: unknown) => any;
792
+ getState: () => MatcherState;
793
+ setState: (state: Partial<MatcherState>) => void;
794
+ not: AsymmetricMatchersContaining;
795
+ }
796
+
797
+ declare type ExtendConfig = Omit<RstestConfig, 'projects'>;
798
+
799
+ declare type ExtendConfigFn = (userConfig: Readonly<RstestConfig>) => MaybePromise<ExtendConfig>;
800
+
801
+ /**
802
+ * Names of clock methods that may be faked by install.
803
+ */
804
+ declare type FakeMethod =
805
+ | "setTimeout"
806
+ | "clearTimeout"
807
+ | "setImmediate"
808
+ | "clearImmediate"
809
+ | "setInterval"
810
+ | "clearInterval"
811
+ | "Date"
812
+ | "nextTick"
813
+ | "hrtime"
814
+ | "requestAnimationFrame"
815
+ | "cancelAnimationFrame"
816
+ | "requestIdleCallback"
817
+ | "cancelIdleCallback"
818
+ | "performance"
819
+ | "queueMicrotask";
820
+
821
+ declare interface FakeTimerInstallOpts {
822
+ /**
823
+ * Installs fake timers with the specified unix epoch (default: 0)
824
+ */
825
+ now?: number | Date | undefined;
826
+
827
+ /**
828
+ * An array with names of global methods and APIs to fake. By default, `@sinonjs/fake-timers` does not replace `nextTick()` and `queueMicrotask()`.
829
+ * For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()`
830
+ */
831
+ toFake?: FakeMethod[] | undefined;
832
+
833
+ /**
834
+ * The maximum number of timers that will be run when calling runAll() (default: 1000)
835
+ */
836
+ loopLimit?: number | undefined;
837
+
838
+ /**
839
+ * Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
840
+ * 20ms for every 20ms change in the real system time) (default: false)
841
+ */
842
+ shouldAdvanceTime?: boolean | undefined;
843
+
844
+ /**
845
+ * Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
846
+ * in the real system time (default: 20)
847
+ */
848
+ advanceTimeDelta?: number | undefined;
849
+
850
+ /**
851
+ * Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by
852
+ * default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. (default: false)
853
+ */
854
+ shouldClearNativeTimers?: boolean | undefined;
855
+ }
856
+
857
+ declare class FileCoverage implements FileCoverageData {
858
+ constructor(data: string | FileCoverage | FileCoverageData);
859
+ merge(other: FileCoverageData): void;
860
+ getBranchCoverageByLine(): { [line: number]: Coverage };
861
+ getLineCoverage(): { [line: number]: number };
862
+ getUncoveredLines(): number[];
863
+ resetHits(): void;
864
+ computeBranchTotals(): Totals;
865
+ computeSimpleTotals(): Totals;
866
+ toSummary(): CoverageSummary;
867
+ toJSON(): object;
868
+
869
+ data: FileCoverageData;
870
+ path: string;
871
+ statementMap: { [key: string]: Range_2 };
872
+ fnMap: { [key: string]: FunctionMapping };
873
+ branchMap: { [key: string]: BranchMapping };
874
+ s: { [key: string]: number };
875
+ f: { [key: string]: number };
876
+ b: { [key: string]: number[] };
877
+ }
878
+
879
+ declare interface FileCoverageData {
880
+ path: string;
881
+ statementMap: { [key: string]: Range_2 };
882
+ fnMap: { [key: string]: FunctionMapping };
883
+ branchMap: { [key: string]: BranchMapping };
884
+ s: { [key: string]: number };
885
+ f: { [key: string]: number };
886
+ b: { [key: string]: number[] };
887
+ }
888
+
889
+ declare interface FileOptions {
890
+ file: string;
891
+ }
892
+
893
+ /**
894
+ * utility for writing files under a specific directory
895
+ */
896
+ declare class FileWriter {
897
+ constructor(baseDir: string);
898
+ static startCapture(): void;
899
+ static stopCapture(): void;
900
+ static getOutput(): string;
901
+ static resetOutput(): void;
902
+ /**
903
+ * returns a FileWriter that is rooted at the supplied subdirectory
904
+ */
905
+ writeForDir(subdir: string): FileWriter;
906
+ /**
907
+ * copies a file from a source directory to a destination name
908
+ */
909
+ copyFile(source: string, dest: string, header?: string): void;
910
+ /**
911
+ * returns a content writer for writing content to the supplied file.
912
+ */
913
+ writeFile(file: string | null): ContentWriter;
914
+ }
915
+
916
+ declare type Fixture<T, K extends keyof T, ExtraContext = object> = ((...args: any) => any) extends T[K] ? T[K] extends any ? FixtureFn<T, K, Omit<ExtraContext, Exclude<keyof T, K>>> : never : T[K] | (T[K] extends any ? FixtureFn<T, K, Omit<ExtraContext, Exclude<keyof T, K>>> : never);
917
+
918
+ declare type FixtureFn<T, K extends keyof T, ExtraContext> = (context: Omit<T, K> & ExtraContext, use: Use<T[K]>) => Promise<void>;
919
+
920
+ declare interface FixtureOptions {
921
+ /**
922
+ * Whether to automatically set up current fixture, even though it's not being used in tests.
923
+ */
924
+ auto?: boolean;
925
+ }
926
+
927
+ declare type Fixtures<T extends Record<string, any> = object, ExtraContext = object> = {
928
+ [K in keyof T]: Fixture<T, K, ExtraContext & TestContext> | [Fixture<T, K, ExtraContext & TestContext>, FixtureOptions?];
929
+ };
930
+
931
+ export declare type FormattedError = {
932
+ fullStack?: boolean;
933
+ message: string;
934
+ name?: string;
935
+ stack?: string;
936
+ diff?: string;
937
+ expected?: string;
938
+ actual?: string;
939
+ };
940
+
941
+ declare interface Formatter {
942
+ (input?: unknown): string;
943
+ open: string;
944
+ close: string;
945
+ }
946
+
947
+ declare type FunctionLike = (...args: any) => any;
948
+
949
+ declare interface FunctionMapping {
950
+ name: string;
951
+ decl: Range_2;
952
+ loc: Range_2;
953
+ line: number;
954
+ }
955
+
956
+ declare type GeneratedColumn = number;
957
+
958
+ declare function getMatcherUtils(): {
959
+ EXPECTED_COLOR: Formatter
960
+ RECEIVED_COLOR: Formatter
961
+ INVERTED_COLOR: Formatter
962
+ BOLD_WEIGHT: Formatter
963
+ DIM_COLOR: Formatter
964
+ diff: typeof diff
965
+ matcherHint: typeof matcherHint
966
+ printReceived: typeof printReceived
967
+ printExpected: typeof printExpected
968
+ printDiffOrStringify: typeof printDiffOrStringify
969
+ printWithType: typeof printWithType
970
+ };
971
+
972
+ export declare const getSetupFiles: (setups: string[], rootPath: string) => Record<string, string>;
973
+
974
+ declare type GetSourcemap = (sourcePath: string) => Promise<SourceMapInput | null>;
975
+
976
+ export declare const getTestEntries: ({ include, exclude, rootPath, projectRoot, fileFilters, includeSource, }: {
977
+ rootPath: string;
978
+ include: string[];
979
+ exclude: string[];
980
+ includeSource: string[];
981
+ fileFilters: string[];
982
+ projectRoot: string;
983
+ }) => Promise<Record<string, string>>;
984
+
985
+ declare class GithubActionsReporter {
986
+ private onWritePath;
987
+ private rootPath;
988
+ constructor({ options, rootPath, }: {
989
+ rootPath: string;
990
+ options: {
991
+ onWritePath: (path: string) => string;
992
+ };
993
+ });
994
+ private log;
995
+ onTestRunEnd({ results, testResults, getSourcemap, }: {
996
+ results: TestFileResult[];
997
+ testResults: TestResult[];
998
+ duration: Duration;
999
+ snapshotSummary: SnapshotSummary;
1000
+ getSourcemap: GetSourcemap;
1001
+ filterRerunTestPaths?: string[];
1002
+ }): Promise<void>;
1003
+ }
1004
+
1005
+ export declare const globalApis: (keyof Rstest_2)[];
1006
+
1007
+ declare interface HtmlOptions {
1008
+ verbose: boolean;
1009
+ skipEmpty: boolean;
1010
+ subdir: string;
1011
+ linkMapper: LinkMapper;
1012
+ }
1013
+
1014
+ declare interface HtmlSpaOptions extends HtmlOptions {
1015
+ metricsToShow: Array<"lines" | "branches" | "functions" | "statements">;
1016
+ }
1017
+
1018
+ declare type Indent = (arg0: string) => string;
1019
+
1020
+ /**
1021
+ * A list of glob patterns or files that match your test projects.
1022
+ *
1023
+ * eg. ['packages/*', 'examples/node/rstest.config.ts']
1024
+ */
1025
+ /**
1026
+ * Inline project config must include a name.
1027
+ */
1028
+ declare type InlineProjectConfig = ProjectConfig & {
1029
+ name: string;
1030
+ };
1031
+
1032
+ declare interface InlineSnapshotMatcher<T> {
1033
+ <U extends {
1034
+ [P in keyof T]: any;
1035
+ }>(properties: Partial<U>, snapshot?: string, message?: string): void;
1036
+ (message?: string): void;
1037
+ }
1038
+
1039
+ export declare const isDebug: () => boolean;
1040
+
1041
+ export declare const it: Rstest_2['it'];
1042
+
1043
+ declare interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMatcher {
1044
+ /**
1045
+ * Used when you want to check that two objects have the same value.
1046
+ * This matcher recursively checks the equality of all fields, rather than checking for object identity.
1047
+ *
1048
+ * @example
1049
+ * expect(user).toEqual({ name: 'Alice', age: 30 });
1050
+ */
1051
+ toEqual: <E>(expected: E) => void;
1052
+ /**
1053
+ * Use to test that objects have the same types as well as structure.
1054
+ *
1055
+ * @example
1056
+ * expect(user).toStrictEqual({ name: 'Alice', age: 30 });
1057
+ */
1058
+ toStrictEqual: <E>(expected: E) => void;
1059
+ /**
1060
+ * Checks that a value is what you expect. It calls `Object.is` to compare values.
1061
+ * Don't use `toBe` with floating-point numbers.
1062
+ *
1063
+ * @example
1064
+ * expect(result).toBe(42);
1065
+ * expect(status).toBe(true);
1066
+ */
1067
+ toBe: <E>(expected: E) => void;
1068
+ /**
1069
+ * Check that a string matches a regular expression.
1070
+ *
1071
+ * @example
1072
+ * expect(message).toMatch(/hello/);
1073
+ * expect(greeting).toMatch('world');
1074
+ */
1075
+ toMatch: (expected: string | RegExp) => void;
1076
+ /**
1077
+ * Used to check that a JavaScript object matches a subset of the properties of an object
1078
+ *
1079
+ * @example
1080
+ * expect(user).toMatchObject({
1081
+ * name: 'Alice',
1082
+ * address: { city: 'Wonderland' }
1083
+ * });
1084
+ */
1085
+ toMatchObject: <E extends object | any[]>(expected: E) => void;
1086
+ /**
1087
+ * Used when you want to check that an item is in a list.
1088
+ * For testing the items in the list, this uses `===`, a strict equality check.
1089
+ *
1090
+ * @example
1091
+ * expect(items).toContain('apple');
1092
+ * expect(numbers).toContain(5);
1093
+ */
1094
+ toContain: <E>(item: E) => void;
1095
+ /**
1096
+ * Used when you want to check that an item is in a list.
1097
+ * For testing the items in the list, this matcher recursively checks the
1098
+ * equality of all fields, rather than checking for object identity.
1099
+ *
1100
+ * @example
1101
+ * expect(items).toContainEqual({ name: 'apple', quantity: 1 });
1102
+ */
1103
+ toContainEqual: <E>(item: E) => void;
1104
+ /**
1105
+ * Use when you don't care what a value is, you just want to ensure a value
1106
+ * is true in a boolean context. In JavaScript, there are six falsy values:
1107
+ * `false`, `0`, `''`, `null`, `undefined`, and `NaN`. Everything else is truthy.
1108
+ *
1109
+ * @example
1110
+ * expect(user.isActive).toBeTruthy();
1111
+ */
1112
+ toBeTruthy: () => void;
1113
+ /**
1114
+ * When you don't care what a value is, you just want to
1115
+ * ensure a value is false in a boolean context.
1116
+ *
1117
+ * @example
1118
+ * expect(user.isActive).toBeFalsy();
1119
+ */
1120
+ toBeFalsy: () => void;
1121
+ /**
1122
+ * For comparing floating point numbers.
1123
+ *
1124
+ * @example
1125
+ * expect(score).toBeGreaterThan(10);
1126
+ */
1127
+ toBeGreaterThan: (num: number | bigint) => void;
1128
+ /**
1129
+ * For comparing floating point numbers.
1130
+ *
1131
+ * @example
1132
+ * expect(score).toBeGreaterThanOrEqual(10);
1133
+ */
1134
+ toBeGreaterThanOrEqual: (num: number | bigint) => void;
1135
+ /**
1136
+ * For comparing floating point numbers.
1137
+ *
1138
+ * @example
1139
+ * expect(score).toBeLessThan(10);
1140
+ */
1141
+ toBeLessThan: (num: number | bigint) => void;
1142
+ /**
1143
+ * For comparing floating point numbers.
1144
+ *
1145
+ * @example
1146
+ * expect(score).toBeLessThanOrEqual(10);
1147
+ */
1148
+ toBeLessThanOrEqual: (num: number | bigint) => void;
1149
+ /**
1150
+ * Used to check that a variable is NaN.
1151
+ *
1152
+ * @example
1153
+ * expect(value).toBeNaN();
1154
+ */
1155
+ toBeNaN: () => void;
1156
+ /**
1157
+ * Used to check that a variable is undefined.
1158
+ *
1159
+ * @example
1160
+ * expect(value).toBeUndefined();
1161
+ */
1162
+ toBeUndefined: () => void;
1163
+ /**
1164
+ * This is the same as `.toBe(null)` but the error messages are a bit nicer.
1165
+ * So use `.toBeNull()` when you want to check that something is null.
1166
+ *
1167
+ * @example
1168
+ * expect(value).toBeNull();
1169
+ */
1170
+ toBeNull: () => void;
1171
+ /**
1172
+ * Ensure that a variable is not undefined.
1173
+ *
1174
+ * @example
1175
+ * expect(value).toBeDefined();
1176
+ */
1177
+ toBeDefined: () => void;
1178
+ /**
1179
+ * Ensure that an object is an instance of a class.
1180
+ * This matcher uses `instanceof` underneath.
1181
+ *
1182
+ * @example
1183
+ * expect(new Date()).toBeInstanceOf(Date);
1184
+ */
1185
+ toBeInstanceOf: <E>(expected: E) => void;
1186
+ /**
1187
+ * Used to check that an object has a `.length` property
1188
+ * and it is set to a certain numeric value.
1189
+ *
1190
+ * @example
1191
+ * expect([1, 2, 3]).toHaveLength(3);
1192
+ * expect('hello').toHaveLength(5);
1193
+ */
1194
+ toHaveLength: (length: number) => void;
1195
+ /**
1196
+ * Use to check if a property at the specified path exists on an object.
1197
+ * For checking deeply nested properties, you may use dot notation or an array containing
1198
+ * the path segments for deep references.
1199
+ *
1200
+ * Optionally, you can provide a value to check if it matches the value present at the path
1201
+ * on the target object. This matcher uses 'deep equality' (like `toEqual()`) and recursively checks
1202
+ * the equality of all fields.
1203
+ *
1204
+ * @example
1205
+ * expect(user).toHaveProperty('address.city', 'New York');
1206
+ * expect(config).toHaveProperty(['settings', 'theme'], 'dark');
1207
+ */
1208
+ toHaveProperty: <E>(property: string | (string | number)[], value?: E) => void;
1209
+ /**
1210
+ * Using exact equality with floating point numbers is a bad idea.
1211
+ * Rounding means that intuitive things fail.
1212
+ * The default for `precision` is 2.
1213
+ *
1214
+ * @example
1215
+ * expect(price).toBeCloseTo(9.99, 2);
1216
+ */
1217
+ toBeCloseTo: (number: number, numDigits?: number) => void;
1218
+ /**
1219
+ * Ensures that a mock function is called an exact number of times.
1220
+ *
1221
+ * Also under the alias `expect.toBeCalledTimes`.
1222
+ *
1223
+ * @example
1224
+ * expect(mockFunc).toHaveBeenCalledTimes(2);
1225
+ */
1226
+ toHaveBeenCalledTimes: (times: number) => void;
1227
+ /**
1228
+ * Ensures that a mock function is called an exact number of times.
1229
+ *
1230
+ * Alias for `expect.toHaveBeenCalledTimes`.
1231
+ *
1232
+ * @example
1233
+ * expect(mockFunc).toBeCalledTimes(2);
1234
+ */
1235
+ toBeCalledTimes: (times: number) => void;
1236
+ /**
1237
+ * Ensures that a mock function is called.
1238
+ *
1239
+ * Also under the alias `expect.toBeCalled`.
1240
+ *
1241
+ * @example
1242
+ * expect(mockFunc).toHaveBeenCalled();
1243
+ */
1244
+ toHaveBeenCalled: () => void;
1245
+ /**
1246
+ * Ensures that a mock function is called.
1247
+ *
1248
+ * Alias for `expect.toHaveBeenCalled`.
1249
+ *
1250
+ * @example
1251
+ * expect(mockFunc).toBeCalled();
1252
+ */
1253
+ toBeCalled: () => void;
1254
+ /**
1255
+ * Ensure that a mock function is called with specific arguments.
1256
+ *
1257
+ * Also under the alias `expect.toBeCalledWith`.
1258
+ *
1259
+ * @example
1260
+ * expect(mockFunc).toHaveBeenCalledWith('arg1', 42);
1261
+ */
1262
+ toHaveBeenCalledWith: <E extends any[]>(...args: E) => void;
1263
+ /**
1264
+ * Ensure that a mock function is called with specific arguments.
1265
+ *
1266
+ * Alias for `expect.toHaveBeenCalledWith`.
1267
+ *
1268
+ * @example
1269
+ * expect(mockFunc).toBeCalledWith('arg1', 42);
1270
+ */
1271
+ toBeCalledWith: <E extends any[]>(...args: E) => void;
1272
+ /**
1273
+ * Ensure that a mock function is called with specific arguments on an Nth call.
1274
+ *
1275
+ * Also under the alias `expect.nthCalledWith`.
1276
+ *
1277
+ * @example
1278
+ * expect(mockFunc).toHaveBeenNthCalledWith(2, 'secondArg');
1279
+ */
1280
+ toHaveBeenNthCalledWith: <E extends any[]>(n: number, ...args: E) => void;
1281
+ /**
1282
+ * Ensure that a mock function is called with specific arguments on an Nth call.
1283
+ *
1284
+ * Alias for `expect.toHaveBeenNthCalledWith`.
1285
+ *
1286
+ * @example
1287
+ * expect(mockFunc).nthCalledWith(2, 'secondArg');
1288
+ */
1289
+ nthCalledWith: <E extends any[]>(nthCall: number, ...args: E) => void;
1290
+ /**
1291
+ * If you have a mock function, you can use `.toHaveBeenLastCalledWith`
1292
+ * to test what arguments it was last called with.
1293
+ *
1294
+ * Also under the alias `expect.lastCalledWith`.
1295
+ *
1296
+ * @example
1297
+ * expect(mockFunc).toHaveBeenLastCalledWith('lastArg');
1298
+ */
1299
+ toHaveBeenLastCalledWith: <E extends any[]>(...args: E) => void;
1300
+ /**
1301
+ * If you have a mock function, you can use `.lastCalledWith`
1302
+ * to test what arguments it was last called with.
1303
+ *
1304
+ * Alias for `expect.toHaveBeenLastCalledWith`.
1305
+ *
1306
+ * @example
1307
+ * expect(mockFunc).lastCalledWith('lastArg');
1308
+ */
1309
+ lastCalledWith: <E extends any[]>(...args: E) => void;
1310
+ /**
1311
+ * Used to test that a function throws when it is called.
1312
+ *
1313
+ * Also under the alias `expect.toThrowError`.
1314
+ *
1315
+ * @example
1316
+ * expect(() => functionWithError()).toThrow('Error message');
1317
+ * expect(() => parseJSON('invalid')).toThrow(SyntaxError);
1318
+ */
1319
+ toThrow: (expected?: string | Constructable | RegExp | Error) => void;
1320
+ /**
1321
+ * Used to test that a function throws when it is called.
1322
+ *
1323
+ * Alias for `expect.toThrow`.
1324
+ *
1325
+ * @example
1326
+ * expect(() => functionWithError()).toThrowError('Error message');
1327
+ * expect(() => parseJSON('invalid')).toThrowError(SyntaxError);
1328
+ */
1329
+ toThrowError: (expected?: string | Constructable | RegExp | Error) => void;
1330
+ /**
1331
+ * Use to test that the mock function successfully returned (i.e., did not throw an error) at least one time
1332
+ *
1333
+ * Alias for `expect.toHaveReturned`.
1334
+ *
1335
+ * @example
1336
+ * expect(mockFunc).toReturn();
1337
+ */
1338
+ toReturn: () => void;
1339
+ /**
1340
+ * Use to test that the mock function successfully returned (i.e., did not throw an error) at least one time
1341
+ *
1342
+ * Also under the alias `expect.toReturn`.
1343
+ *
1344
+ * @example
1345
+ * expect(mockFunc).toHaveReturned();
1346
+ */
1347
+ toHaveReturned: () => void;
1348
+ /**
1349
+ * Use to ensure that a mock function returned successfully (i.e., did not throw an error) an exact number of times.
1350
+ * Any calls to the mock function that throw an error are not counted toward the number of times the function returned.
1351
+ *
1352
+ * Alias for `expect.toHaveReturnedTimes`.
1353
+ *
1354
+ * @example
1355
+ * expect(mockFunc).toReturnTimes(3);
1356
+ */
1357
+ toReturnTimes: (times: number) => void;
1358
+ /**
1359
+ * Use to ensure that a mock function returned successfully (i.e., did not throw an error) an exact number of times.
1360
+ * Any calls to the mock function that throw an error are not counted toward the number of times the function returned.
1361
+ *
1362
+ * Also under the alias `expect.toReturnTimes`.
1363
+ *
1364
+ * @example
1365
+ * expect(mockFunc).toHaveReturnedTimes(3);
1366
+ */
1367
+ toHaveReturnedTimes: (times: number) => void;
1368
+ /**
1369
+ * Use to ensure that a mock function returned a specific value.
1370
+ *
1371
+ * Alias for `expect.toHaveReturnedWith`.
1372
+ *
1373
+ * @example
1374
+ * expect(mockFunc).toReturnWith('returnValue');
1375
+ */
1376
+ toReturnWith: <E>(value: E) => void;
1377
+ /**
1378
+ * Use to ensure that a mock function returned a specific value.
1379
+ *
1380
+ * Also under the alias `expect.toReturnWith`.
1381
+ *
1382
+ * @example
1383
+ * expect(mockFunc).toHaveReturnedWith('returnValue');
1384
+ */
1385
+ toHaveReturnedWith: <E>(value: E) => void;
1386
+ /**
1387
+ * Use to test the specific value that a mock function last returned.
1388
+ * If the last call to the mock function threw an error, then this matcher will fail
1389
+ * no matter what value you provided as the expected return value.
1390
+ *
1391
+ * Also under the alias `expect.lastReturnedWith`.
1392
+ *
1393
+ * @example
1394
+ * expect(mockFunc).toHaveLastReturnedWith('lastValue');
1395
+ */
1396
+ toHaveLastReturnedWith: <E>(value: E) => void;
1397
+ /**
1398
+ * Use to test the specific value that a mock function last returned.
1399
+ * If the last call to the mock function threw an error, then this matcher will fail
1400
+ * no matter what value you provided as the expected return value.
1401
+ *
1402
+ * Alias for `expect.toHaveLastReturnedWith`.
1403
+ *
1404
+ * @example
1405
+ * expect(mockFunc).lastReturnedWith('lastValue');
1406
+ */
1407
+ lastReturnedWith: <E>(value: E) => void;
1408
+ /**
1409
+ * Use to test the specific value that a mock function returned for the nth call.
1410
+ * If the nth call to the mock function threw an error, then this matcher will fail
1411
+ * no matter what value you provided as the expected return value.
1412
+ *
1413
+ * Also under the alias `expect.nthReturnedWith`.
1414
+ *
1415
+ * @example
1416
+ * expect(mockFunc).toHaveNthReturnedWith(2, 'nthValue');
1417
+ */
1418
+ toHaveNthReturnedWith: <E>(nthCall: number, value: E) => void;
1419
+ /**
1420
+ * Use to test the specific value that a mock function returned for the nth call.
1421
+ * If the nth call to the mock function threw an error, then this matcher will fail
1422
+ * no matter what value you provided as the expected return value.
1423
+ *
1424
+ * Alias for `expect.toHaveNthReturnedWith`.
1425
+ *
1426
+ * @example
1427
+ * expect(mockFunc).nthReturnedWith(2, 'nthValue');
1428
+ */
1429
+ nthReturnedWith: <E>(nthCall: number, value: E) => void;
1430
+ }
1431
+
1432
+ declare type JsonOptions = FileOptions;
1433
+
1434
+ declare type JsonSummaryOptions = FileOptions;
1435
+
1436
+ declare class JUnitReporter implements Reporter {
1437
+ private rootPath;
1438
+ private outputPath?;
1439
+ constructor({ rootPath, options: { outputPath }, }: {
1440
+ rootPath: string;
1441
+ options?: {
1442
+ outputPath?: string;
1443
+ };
1444
+ });
1445
+ private sanitizeXml;
1446
+ private escapeXml;
1447
+ private createJUnitTestCase;
1448
+ private createJUnitTestSuite;
1449
+ private generateJUnitXml;
1450
+ onTestRunEnd({ results, testResults, duration, getSourcemap, }: {
1451
+ getSourcemap: GetSourcemap;
1452
+ results: TestFileResult[];
1453
+ testResults: TestResult[];
1454
+ duration: Duration;
1455
+ }): Promise<void>;
1456
+ }
1457
+
1458
+ declare interface LcovOnlyOptions extends FileOptions, ProjectOptions {}
1459
+
1460
+ declare interface LcovOptions extends FileOptions, ProjectOptions {}
1461
+
1462
+ declare interface LinkMapper {
1463
+ getPath(node: string | Node_2): string;
1464
+ relativePath(source: string | Node_2, target: string | Node_2): string;
1465
+ assetPath(node: Node_2, name: string): string;
1466
+ }
1467
+
1468
+ export declare type ListCommandResult = {
1469
+ tests: Test[];
1470
+ testPath: string;
1471
+ project: string;
1472
+ errors?: FormattedError[];
1473
+ };
1474
+
1475
+ declare type Location_2 = {
1476
+ line: number;
1477
+ column: number;
1478
+ };
1479
+
1480
+ declare interface Location_3 {
1481
+ line: number;
1482
+ column: number;
1483
+ }
1484
+
1485
+ export declare const logger: Logger & {
1486
+ stderr: (message: string, ...args: any[]) => void;
1487
+ };
1488
+
1489
+ declare function matcherHint(matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions): string;
1490
+
1491
+ declare interface MatcherHintOptions {
1492
+ comment?: string;
1493
+ expectedColor?: Formatter;
1494
+ isDirectExpectCall?: boolean;
1495
+ isNot?: boolean;
1496
+ promise?: string;
1497
+ receivedColor?: Formatter;
1498
+ secondArgument?: string;
1499
+ secondArgumentColor?: Formatter;
1500
+ }
1501
+
1502
+ declare interface Matchers<T = any> {}
1503
+
1504
+ declare type MatchersObject<T extends MatcherState = MatcherState> = Record<string, RawMatcherFn<T>> & ThisType<T> & { [K in keyof Matchers<T>]? : RawMatcherFn<T, Parameters<Matchers<T>[K]>> };
1505
+
1506
+ declare interface MatcherState {
1507
+ customTesters: Array<Tester>;
1508
+ assertionCalls: number;
1509
+ currentTestName?: string;
1510
+ dontThrow?: () => void;
1511
+ error?: Error;
1512
+ equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
1513
+ expand?: boolean;
1514
+ expectedAssertionsNumber?: number | null;
1515
+ expectedAssertionsNumberErrorGen?: (() => Error) | null;
1516
+ isExpectingAssertions?: boolean;
1517
+ isExpectingAssertionsError?: Error | null;
1518
+ isNot: boolean;
1519
+ // environment: VitestEnvironment
1520
+ promise: string;
1521
+ // snapshotState: SnapshotState
1522
+ suppressedErrors: Array<Error>;
1523
+ testPath?: string;
1524
+ utils: ReturnType<typeof getMatcherUtils> & {
1525
+ diff: typeof diff
1526
+ stringify: typeof stringify
1527
+ iterableEquality: Tester
1528
+ subsetEquality: Tester
1529
+ };
1530
+ soft?: boolean;
1531
+ poll?: boolean;
1532
+ }
1533
+
1534
+ declare interface MatcherState_2 extends MatcherState {
1535
+ environment: string;
1536
+ snapshotState: SnapshotState;
1537
+ }
1538
+
1539
+ declare type MaybePromise<T> = T | Promise<T>;
1540
+
1541
+ export declare interface Mock<T extends FunctionLike = FunctionLike> extends MockInstance_2<T> {
1542
+ new (...args: Parameters<T>): ReturnType<T>;
1543
+ (...args: Parameters<T>): ReturnType<T>;
1544
+ }
1545
+
1546
+ declare interface MockContext<T extends Procedure> {
1547
+ /**
1548
+ * This is an array containing all arguments for each call. One item of the array is the arguments of that call.
1549
+ *
1550
+ * @see https://vitest.dev/api/mock#mock-calls
1551
+ * @example
1552
+ * const fn = vi.fn()
1553
+ *
1554
+ * fn('arg1', 'arg2')
1555
+ * fn('arg3')
1556
+ *
1557
+ * fn.mock.calls === [
1558
+ * ['arg1', 'arg2'], // first call
1559
+ * ['arg3'], // second call
1560
+ * ]
1561
+ */
1562
+ calls: Parameters<T>[];
1563
+ /**
1564
+ * This is an array containing all instances that were instantiated when mock was called with a `new` keyword. Note that this is an actual context (`this`) of the function, not a return value.
1565
+ * @see https://vitest.dev/api/mock#mock-instances
1566
+ */
1567
+ instances: ReturnType<T>[];
1568
+ /**
1569
+ * An array of `this` values that were used during each call to the mock function.
1570
+ * @see https://vitest.dev/api/mock#mock-contexts
1571
+ */
1572
+ contexts: ThisParameterType<T>[];
1573
+ /**
1574
+ * The order of mock's execution. This returns an array of numbers which are shared between all defined mocks.
1575
+ *
1576
+ * @see https://vitest.dev/api/mock#mock-invocationcallorder
1577
+ * @example
1578
+ * const fn1 = vi.fn()
1579
+ * const fn2 = vi.fn()
1580
+ *
1581
+ * fn1()
1582
+ * fn2()
1583
+ * fn1()
1584
+ *
1585
+ * fn1.mock.invocationCallOrder === [1, 3]
1586
+ * fn2.mock.invocationCallOrder === [2]
1587
+ */
1588
+ invocationCallOrder: number[];
1589
+ /**
1590
+ * This is an array containing all values that were `returned` from the function.
1591
+ *
1592
+ * The `value` property contains the returned value or thrown error. If the function returned a `Promise`, then `result` will always be `'return'` even if the promise was rejected.
1593
+ *
1594
+ * @see https://vitest.dev/api/mock#mock-results
1595
+ * @example
1596
+ * const fn = vi.fn()
1597
+ * .mockReturnValueOnce('result')
1598
+ * .mockImplementationOnce(() => { throw new Error('thrown error') })
1599
+ *
1600
+ * const result = fn()
1601
+ *
1602
+ * try {
1603
+ * fn()
1604
+ * }
1605
+ * catch {}
1606
+ *
1607
+ * fn.mock.results === [
1608
+ * {
1609
+ * type: 'return',
1610
+ * value: 'result',
1611
+ * },
1612
+ * {
1613
+ * type: 'throw',
1614
+ * value: Error,
1615
+ * },
1616
+ * ]
1617
+ */
1618
+ results: MockResult<ReturnType<T>>[];
1619
+ /**
1620
+ * An array containing all values that were `resolved` or `rejected` from the function.
1621
+ *
1622
+ * This array will be empty if the function was never resolved or rejected.
1623
+ *
1624
+ * @see https://vitest.dev/api/mock#mock-settledresults
1625
+ * @example
1626
+ * const fn = vi.fn().mockResolvedValueOnce('result')
1627
+ *
1628
+ * const result = fn()
1629
+ *
1630
+ * fn.mock.settledResults === []
1631
+ * fn.mock.results === [
1632
+ * {
1633
+ * type: 'return',
1634
+ * value: Promise<'result'>,
1635
+ * },
1636
+ * ]
1637
+ *
1638
+ * await result
1639
+ *
1640
+ * fn.mock.settledResults === [
1641
+ * {
1642
+ * type: 'fulfilled',
1643
+ * value: 'result',
1644
+ * },
1645
+ * ]
1646
+ */
1647
+ settledResults: MockSettledResult<Awaited<ReturnType<T>>>[];
1648
+ /**
1649
+ * This contains the arguments of the last call. If spy wasn't called, will return `undefined`.
1650
+ * @see https://vitest.dev/api/mock#mock-lastcall
1651
+ */
1652
+ lastCall: Parameters<T> | undefined;
1653
+ }
1654
+
1655
+ declare type MockContext_2<T extends FunctionLike = FunctionLike> = {
1656
+ /**
1657
+ * List of the call arguments of all calls that have been made to the mock.
1658
+ */
1659
+ calls: Parameters<T>[];
1660
+ /**
1661
+ * List of all the object instances that have been instantiated from the mock.
1662
+ */
1663
+ instances: ReturnType<T>[];
1664
+ /**
1665
+ * List of all the function contexts that have been applied to calls to the mock.
1666
+ */
1667
+ contexts: ThisParameterType<T>[];
1668
+ /**
1669
+ * The order of mock's execution.
1670
+ * This returns an array of numbers which are shared between all defined mocks.
1671
+ * The index is starting with `1`.
1672
+ */
1673
+ invocationCallOrder: number[];
1674
+ /**
1675
+ * List of the call arguments of the last call that was made to the mock.
1676
+ * If the function was not called, it will return `undefined`.
1677
+ */
1678
+ lastCall: Parameters<T> | undefined;
1679
+ /**
1680
+ * List of the results of all calls that have been made to the mock.
1681
+ */
1682
+ results: MockResult_2<ReturnType<T>>[];
1683
+ /**
1684
+ * List of the results of all values that were `resolved` or `rejected` from the function.
1685
+ */
1686
+ settledResults: MockSettledResult_2<Awaited<ReturnType<T>>>[];
1687
+ };
1688
+
1689
+ declare type MockFactory<T = unknown> = () => MaybePromise<Partial<T>>;
1690
+
1691
+ declare type MockFn = <T extends FunctionLike = FunctionLike>(fn?: T) => Mock<T>;
1692
+
1693
+ declare interface MockInstance<T extends Procedure = Procedure> extends Disposable {
1694
+ /**
1695
+ * Use it to return the name assigned to the mock with the `.mockName(name)` method. By default, it will return `vi.fn()`.
1696
+ * @see https://vitest.dev/api/mock#getmockname
1697
+ */
1698
+ getMockName(): string;
1699
+ /**
1700
+ * Sets the internal mock name. This is useful for identifying the mock when an assertion fails.
1701
+ * @see https://vitest.dev/api/mock#mockname
1702
+ */
1703
+ mockName(name: string): this;
1704
+ /**
1705
+ * Current context of the mock. It stores information about all invocation calls, instances, and results.
1706
+ */
1707
+ mock: MockContext<T>;
1708
+ /**
1709
+ * Clears all information about every call. After calling it, all properties on `.mock` will return to their initial state. This method does not reset implementations. It is useful for cleaning up mocks between different assertions.
1710
+ *
1711
+ * To automatically call this method before each test, enable the [`clearMocks`](https://vitest.dev/config/#clearmocks) setting in the configuration.
1712
+ * @see https://vitest.dev/api/mock#mockclear
1713
+ */
1714
+ mockClear(): this;
1715
+ /**
1716
+ * Does what `mockClear` does and resets inner implementation to the original function. This also resets all "once" implementations.
1717
+ *
1718
+ * Note that resetting a mock from `vi.fn()` will set implementation to an empty function that returns `undefined`.
1719
+ * Resetting a mock from `vi.fn(impl)` will set implementation to `impl`. It is useful for completely resetting a mock to its default state.
1720
+ *
1721
+ * To automatically call this method before each test, enable the [`mockReset`](https://vitest.dev/config/#mockreset) setting in the configuration.
1722
+ * @see https://vitest.dev/api/mock#mockreset
1723
+ */
1724
+ mockReset(): this;
1725
+ /**
1726
+ * Does what `mockReset` does and restores original descriptors of spied-on objects.
1727
+ *
1728
+ * Note that restoring mock from `vi.fn()` will set implementation to an empty function that returns `undefined`. Restoring a `vi.fn(impl)` will restore implementation to `impl`.
1729
+ * @see https://vitest.dev/api/mock#mockrestore
1730
+ */
1731
+ mockRestore(): void;
1732
+ /**
1733
+ * Returns current permanent mock implementation if there is one.
1734
+ *
1735
+ * If mock was created with `vi.fn`, it will consider passed down method as a mock implementation.
1736
+ *
1737
+ * If mock was created with `vi.spyOn`, it will return `undefined` unless a custom implementation was provided.
1738
+ */
1739
+ getMockImplementation(): NormalizedProcedure<T> | undefined;
1740
+ /**
1741
+ * Accepts a function to be used as the mock implementation. TypeScript expects the arguments and return type to match those of the original function.
1742
+ * @see https://vitest.dev/api/mock#mockimplementation
1743
+ * @example
1744
+ * const increment = vi.fn().mockImplementation(count => count + 1);
1745
+ * expect(increment(3)).toBe(4);
1746
+ */
1747
+ mockImplementation(fn: NormalizedProcedure<T>): this;
1748
+ /**
1749
+ * Accepts a function to be used as the mock implementation. TypeScript expects the arguments and return type to match those of the original function. This method can be chained to produce different results for multiple function calls.
1750
+ *
1751
+ * When the mocked function runs out of implementations, it will invoke the default implementation set with `vi.fn(() => defaultValue)` or `.mockImplementation(() => defaultValue)` if they were called.
1752
+ * @see https://vitest.dev/api/mock#mockimplementationonce
1753
+ * @example
1754
+ * const fn = vi.fn(count => count).mockImplementationOnce(count => count + 1);
1755
+ * expect(fn(3)).toBe(4);
1756
+ * expect(fn(3)).toBe(3);
1757
+ */
1758
+ mockImplementationOnce(fn: NormalizedProcedure<T>): this;
1759
+ /**
1760
+ * Overrides the original mock implementation temporarily while the callback is being executed.
1761
+ *
1762
+ * Note that this method takes precedence over the [`mockImplementationOnce`](https://vitest.dev/api/mock#mockimplementationonce).
1763
+ * @see https://vitest.dev/api/mock#withimplementation
1764
+ * @example
1765
+ * const myMockFn = vi.fn(() => 'original')
1766
+ *
1767
+ * myMockFn.withImplementation(() => 'temp', () => {
1768
+ * myMockFn() // 'temp'
1769
+ * })
1770
+ *
1771
+ * myMockFn() // 'original'
1772
+ */
1773
+ withImplementation<T2>(fn: NormalizedProcedure<T>, cb: () => T2): T2 extends Promise<unknown> ? Promise<this> : this;
1774
+ /**
1775
+ * Use this if you need to return the `this` context from the method without invoking the actual implementation.
1776
+ * @see https://vitest.dev/api/mock#mockreturnthis
1777
+ */
1778
+ mockReturnThis(): this;
1779
+ /**
1780
+ * Accepts a value that will be returned whenever the mock function is called. TypeScript will only accept values that match the return type of the original function.
1781
+ * @see https://vitest.dev/api/mock#mockreturnvalue
1782
+ * @example
1783
+ * const mock = vi.fn()
1784
+ * mock.mockReturnValue(42)
1785
+ * mock() // 42
1786
+ * mock.mockReturnValue(43)
1787
+ * mock() // 43
1788
+ */
1789
+ mockReturnValue(value: ReturnType<T>): this;
1790
+ /**
1791
+ * Accepts a value that will be returned whenever the mock function is called. TypeScript will only accept values that match the return type of the original function.
1792
+ *
1793
+ * When the mocked function runs out of implementations, it will invoke the default implementation set with `vi.fn(() => defaultValue)` or `.mockImplementation(() => defaultValue)` if they were called.
1794
+ * @example
1795
+ * const myMockFn = vi
1796
+ * .fn()
1797
+ * .mockReturnValue('default')
1798
+ * .mockReturnValueOnce('first call')
1799
+ * .mockReturnValueOnce('second call')
1800
+ *
1801
+ * // 'first call', 'second call', 'default'
1802
+ * console.log(myMockFn(), myMockFn(), myMockFn())
1803
+ */
1804
+ mockReturnValueOnce(value: ReturnType<T>): this;
1805
+ /**
1806
+ * Accepts a value that will be resolved when the async function is called. TypeScript will only accept values that match the return type of the original function.
1807
+ * @example
1808
+ * const asyncMock = vi.fn().mockResolvedValue(42)
1809
+ * asyncMock() // Promise<42>
1810
+ */
1811
+ mockResolvedValue(value: Awaited<ReturnType<T>>): this;
1812
+ /**
1813
+ * Accepts a value that will be resolved during the next function call. TypeScript will only accept values that match the return type of the original function. If chained, each consecutive call will resolve the specified value.
1814
+ * @example
1815
+ * const myMockFn = vi
1816
+ * .fn()
1817
+ * .mockResolvedValue('default')
1818
+ * .mockResolvedValueOnce('first call')
1819
+ * .mockResolvedValueOnce('second call')
1820
+ *
1821
+ * // Promise<'first call'>, Promise<'second call'>, Promise<'default'>
1822
+ * console.log(myMockFn(), myMockFn(), myMockFn())
1823
+ */
1824
+ mockResolvedValueOnce(value: Awaited<ReturnType<T>>): this;
1825
+ /**
1826
+ * Accepts an error that will be rejected when async function is called.
1827
+ * @example
1828
+ * const asyncMock = vi.fn().mockRejectedValue(new Error('Async error'))
1829
+ * await asyncMock() // throws Error<'Async error'>
1830
+ */
1831
+ mockRejectedValue(error: unknown): this;
1832
+ /**
1833
+ * Accepts a value that will be rejected during the next function call. If chained, each consecutive call will reject the specified value.
1834
+ * @example
1835
+ * const asyncMock = vi
1836
+ * .fn()
1837
+ * .mockResolvedValueOnce('first call')
1838
+ * .mockRejectedValueOnce(new Error('Async error'))
1839
+ *
1840
+ * await asyncMock() // first call
1841
+ * await asyncMock() // throws Error<'Async error'>
1842
+ */
1843
+ mockRejectedValueOnce(error: unknown): this;
1844
+ }
1845
+
1846
+ declare interface MockInstance_2<T extends FunctionLike = FunctionLike> {
1847
+ _isMockFunction: true;
1848
+ /**
1849
+ * Returns the mock name string set by calling `.mockName()`
1850
+ */
1851
+ getMockName(): string;
1852
+ /**
1853
+ * Sets the mock name for this mock.
1854
+ */
1855
+ mockName(name: string): this;
1856
+ mock: MockContext_2<T>;
1857
+ /**
1858
+ * Clears all information about every call.
1859
+ */
1860
+ mockClear(): this;
1861
+ /**
1862
+ * Does what `mockClear` does and resets inner implementation to the original function.
1863
+ */
1864
+ mockReset(): this;
1865
+ /**
1866
+ * Does what `mockReset` does and restores original descriptors of spied-on objects.
1867
+ */
1868
+ mockRestore(): void;
1869
+ /**
1870
+ * Returns current mock implementation if there is one.
1871
+ */
1872
+ getMockImplementation(): NormalizedProcedure_2<T> | undefined;
1873
+ /**
1874
+ * Accepts a function that should be used as the implementation of the mock.
1875
+ */
1876
+ mockImplementation(fn: NormalizedProcedure_2<T>): this;
1877
+ /**
1878
+ * Accepts a function that will be used as an implementation of the mock for one call to the mocked function.
1879
+ */
1880
+ mockImplementationOnce(fn: NormalizedProcedure_2<T>): this;
1881
+ /**
1882
+ * Accepts a function which should be temporarily used as the implementation of the mock while the callback is being executed.
1883
+ */
1884
+ withImplementation<T2>(fn: NormalizedProcedure_2<T>, callback: () => T2): T2 extends Promise<unknown> ? Promise<void> : void;
1885
+ /**
1886
+ * Return the `this` context from the method without invoking the actual implementation.
1887
+ */
1888
+ mockReturnThis(): this;
1889
+ /**
1890
+ * Accepts a value that will be returned whenever the mock function is called.
1891
+ */
1892
+ mockReturnValue(value: ReturnType<T>): this;
1893
+ /**
1894
+ * Accepts a value that will be returned for one call to the mock function.
1895
+ */
1896
+ mockReturnValueOnce(value: ReturnType<T>): this;
1897
+ /**
1898
+ * Accepts a value that will be resolved when the async function is called.
1899
+ */
1900
+ mockResolvedValue(value: Awaited<ReturnType<T>>): this;
1901
+ /**
1902
+ * Accepts a value that will be resolved during the next function call.
1903
+ */
1904
+ mockResolvedValueOnce(value: Awaited<ReturnType<T>>): this;
1905
+ /**
1906
+ * Accepts an error that will be rejected when async function is called.
1907
+ */
1908
+ mockRejectedValue(error: unknown): this;
1909
+ /**
1910
+ * Accepts a value that will be rejected during the next function call.
1911
+ */
1912
+ mockRejectedValueOnce(error: unknown): this;
1913
+ }
1914
+
1915
+ declare type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
1916
+
1917
+ declare type MockResult_2<T> = MockResultReturn_2<T> | MockResultThrow_2 | MockResultIncomplete_2;
1918
+
1919
+ declare interface MockResultIncomplete {
1920
+ type: "incomplete";
1921
+ value: undefined;
1922
+ }
1923
+
1924
+ declare interface MockResultIncomplete_2 {
1925
+ type: 'incomplete';
1926
+ value: undefined;
1927
+ }
1928
+
1929
+ declare interface MockResultReturn<T> {
1930
+ type: "return";
1931
+ /**
1932
+ * The value that was returned from the function. If function returned a Promise, then this will be a resolved value.
1933
+ */
1934
+ value: T;
1935
+ }
1936
+
1937
+ declare interface MockResultReturn_2<T> {
1938
+ type: 'return';
1939
+ /**
1940
+ * The value that was returned from the function. If function returned a Promise, then this will be a resolved value.
1941
+ */
1942
+ value: T;
1943
+ }
1944
+
1945
+ declare interface MockResultThrow {
1946
+ type: "throw";
1947
+ /**
1948
+ * An error that was thrown during function execution.
1949
+ */
1950
+ value: any;
1951
+ }
1952
+
1953
+ declare interface MockResultThrow_2 {
1954
+ type: 'throw';
1955
+ /**
1956
+ * An error that was thrown during function execution.
1957
+ */
1958
+ value: any;
1959
+ }
1960
+
1961
+ declare type MockSettledResult<T> = MockSettledResultFulfilled<T> | MockSettledResultRejected;
1962
+
1963
+ declare type MockSettledResult_2<T> = MockSettledResultFulfilled_2<T> | MockSettledResultRejected_2;
1964
+
1965
+ declare interface MockSettledResultFulfilled<T> {
1966
+ type: "fulfilled";
1967
+ value: T;
1968
+ }
1969
+
1970
+ declare interface MockSettledResultFulfilled_2<T> {
1971
+ type: 'fulfilled';
1972
+ value: T;
1973
+ }
1974
+
1975
+ declare interface MockSettledResultRejected {
1976
+ type: "rejected";
1977
+ value: any;
1978
+ }
1979
+
1980
+ declare interface MockSettledResultRejected_2 {
1981
+ type: 'rejected';
1982
+ value: any;
1983
+ }
1984
+
1985
+ declare type NamesIndex = number;
1986
+
1987
+ declare interface NewPlugin {
1988
+ serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
1989
+ test: Test_2;
1990
+ }
1991
+
1992
+ declare interface Node_2 {
1993
+ isRoot(): boolean;
1994
+ visit(visitor: Visitor, state: any): void;
1995
+ }
1996
+
1997
+ declare type NormalizedBrowserModeConfig = {
1998
+ enabled: boolean;
1999
+ provider: 'playwright';
2000
+ browser: 'chromium' | 'firefox' | 'webkit';
2001
+ headless: boolean;
2002
+ port?: number;
2003
+ };
2004
+
2005
+ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
2006
+ pool: RstestPoolOptions;
2007
+ testEnvironment: EnvironmentWithOptions;
2008
+ coverage: NormalizedCoverageOptions;
2009
+ browser: NormalizedBrowserModeConfig;
2010
+ setupFiles: string[];
2011
+ globalSetup: string[];
2012
+ exclude: {
2013
+ patterns: string[];
2014
+ override?: boolean;
2015
+ };
2016
+ };
2017
+
2018
+ declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, 'thresholds' | 'include'>> & {
2019
+ thresholds?: CoverageThresholds;
2020
+ include?: string[];
2021
+ };
2022
+
2023
+ declare type NormalizedFixture = {
2024
+ isFn: boolean;
2025
+ deps?: string[];
2026
+ value: FixtureFn<any, any, any> | any;
2027
+ options?: FixtureOptions;
2028
+ };
2029
+
2030
+ declare type NormalizedFixtures = Record<string, NormalizedFixture>;
2031
+
2032
+ declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
2033
+
2034
+ declare type NormalizedProcedure_2<T extends Procedure_2> = (...args: Parameters<T>) => ReturnType<T>;
2035
+
2036
+ declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup'>> & Pick<NormalizedConfig, OptionalKeys> & {
2037
+ setupFiles: string[];
2038
+ globalSetup: string[];
2039
+ };
2040
+
2041
+ declare interface OldPlugin {
2042
+ print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
2043
+ test: Test_2;
2044
+ }
2045
+
2046
+ export declare const onTestFailed: Rstest_2['onTestFailed'];
2047
+
2048
+ declare type OnTestFailedHandler = (ctx: TestContext) => MaybePromise<void>;
2049
+
2050
+ export declare const onTestFinished: Rstest_2['onTestFinished'];
2051
+
2052
+ declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
2053
+
2054
+ declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'resolveSnapshotPath' | 'extends';
2055
+
2056
+ declare interface Options {
2057
+ logger: {
2058
+ outputStream: Writable;
2059
+ errorStream: Writable;
2060
+ getColumns: () => number;
2061
+ };
2062
+ interval?: number;
2063
+ getWindow: () => string[];
2064
+ }
2065
+
2066
+ declare type Options_2 = {
2067
+ cwd: string;
2068
+ command: RstestCommand;
2069
+ fileFilters?: string[];
2070
+ configFilePath?: string;
2071
+ projects: Project[];
2072
+ };
2073
+
2074
+ declare type OptionsReceived = PrettyFormatOptions;
2075
+
2076
+ declare interface ParsedStack {
2077
+ method: string;
2078
+ file: string;
2079
+ line: number;
2080
+ column: number;
2081
+ }
2082
+
2083
+ declare type Plugin_2 = NewPlugin | OldPlugin;
2084
+
2085
+ declare interface PluginOptions {
2086
+ edgeSpacing: string;
2087
+ min: boolean;
2088
+ spacing: string;
2089
+ }
2090
+
2091
+ declare type Plugins = Array<Plugin_2>;
2092
+
2093
+ declare interface PrettyFormatOptions {
2094
+ callToJSON?: boolean;
2095
+ escapeRegex?: boolean;
2096
+ escapeString?: boolean;
2097
+ highlight?: boolean;
2098
+ indent?: number;
2099
+ maxDepth?: number;
2100
+ maxWidth?: number;
2101
+ min?: boolean;
2102
+ printBasicPrototype?: boolean;
2103
+ printFunctionName?: boolean;
2104
+ compareKeys?: CompareKeys;
2105
+ plugins?: Plugins;
2106
+ }
2107
+
2108
+ declare type Print = (arg0: unknown) => string;
2109
+
2110
+ declare function printDiffOrStringify(received: unknown, expected: unknown, options?: DiffOptions): string | undefined;
2111
+
2112
+ declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
2113
+
2114
+ declare function printExpected(value: unknown): string;
2115
+
2116
+ declare function printReceived(object: unknown): string;
2117
+
2118
+ declare function printWithType<T>(name: string, value: T, print: (value: T) => string): string;
2119
+
2120
+ declare type Procedure = (...args: any[]) => any;
2121
+
2122
+ declare type Procedure_2 = (...args: any[]) => any;
2123
+
2124
+ declare type Project = {
2125
+ config: RstestConfig;
2126
+ configFilePath?: string;
2127
+ };
2128
+
2129
+ declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'hideSkippedTests' | 'bail'>;
2130
+
2131
+ export declare type ProjectContext = {
2132
+ name: string;
2133
+ environmentName: string;
2134
+ /** The root path of current project. */
2135
+ rootPath: string;
2136
+ /** Whether to output es module. */
2137
+ outputModule: boolean;
2138
+ configFilePath?: string;
2139
+ normalizedConfig: NormalizedProjectConfig;
2140
+ _globalSetups: boolean;
2141
+ };
2142
+
2143
+ declare interface ProjectOptions {
2144
+ projectRoot: string;
2145
+ }
2146
+
2147
+ declare type Promisify<O> = { [K in keyof O] : O[K] extends (...args: infer A) => infer R ? Promisify<O[K]> & ((...args: A) => Promise<R>) : O[K] };
2148
+
2149
+ declare type Promisify_2<O> = {
2150
+ [K in keyof O]: O[K] extends (...args: infer A) => infer R ? Promisify_2<O[K]> & ((...args: A) => Promise<R>) : O[K];
2151
+ };
2152
+
2153
+ declare type PromisifyAssertion<T> = Promisify<Assertion_2<T>>;
2154
+
2155
+ declare type PromisifyAssertion_2<T> = Promisify_2<Assertion<T>>;
2156
+
2157
+ declare interface Range_2 {
2158
+ start: Location_3;
2159
+ end: Location_3;
2160
+ }
2161
+
2162
+ declare interface RawMatcherFn<
2163
+ T extends MatcherState = MatcherState,
2164
+ E extends Array<any> = Array<any>
2165
+ > {
2166
+ (this: T, received: any, ...expected: E): ExpectationResult;
2167
+ }
2168
+
2169
+ declare interface RawSnapshotInfo {
2170
+ file: string;
2171
+ readonly?: boolean;
2172
+ content?: string;
2173
+ }
2174
+
2175
+ declare type Refs = Array<unknown>;
2176
+
2177
+ declare class ReportBase {
2178
+ constructor(options?: Partial<ReportBaseOptions>);
2179
+ execute(context: Context): void;
2180
+ }
2181
+
2182
+ declare interface ReportBaseOptions {
2183
+ summarizer: Summarizers;
2184
+ }
2185
+
2186
+ export declare interface Reporter {
2187
+ /**
2188
+ * Called before test file run.
2189
+ */
2190
+ onTestFileStart?: (test: TestFileInfo) => void;
2191
+ /**
2192
+ * Called after tests in file collected.
2193
+ */
2194
+ onTestFileReady?: (test: TestFileInfo) => void;
2195
+ /**
2196
+ * Called when the test file has finished running.
2197
+ */
2198
+ onTestFileResult?: (test: TestFileResult) => void;
2199
+ /**
2200
+ * Called before running the test suite.
2201
+ */
2202
+ onTestSuiteStart?: (test: TestSuiteInfo) => void;
2203
+ /**
2204
+ * Called when the suite has finished running or was just skipped.
2205
+ *
2206
+ * `result.errors` contains only suite hooks errors
2207
+ */
2208
+ onTestSuiteResult?: (result: TestResult) => void;
2209
+ /**
2210
+ * Called when the test has finished running or was just skipped.
2211
+ */
2212
+ onTestCaseResult?: (result: TestResult) => void;
2213
+ /**
2214
+ * Called before running the test case.
2215
+ */
2216
+ onTestCaseStart?: (test: TestCaseInfo) => void;
2217
+ /**
2218
+ * Called before all tests start
2219
+ */
2220
+ onTestRunStart?: () => MaybePromise<void>;
2221
+ /**
2222
+ * Called after all tests have finished running.
2223
+ */
2224
+ onTestRunEnd?: ({ results, testResults, duration, getSourcemap, snapshotSummary, unhandledErrors, }: {
2225
+ results: TestFileResult[];
2226
+ testResults: TestResult[];
2227
+ duration: Duration;
2228
+ getSourcemap: GetSourcemap;
2229
+ unhandledErrors?: Error[];
2230
+ snapshotSummary: SnapshotSummary;
2231
+ filterRerunTestPaths?: string[];
2232
+ }) => MaybePromise<void>;
2233
+ /**
2234
+ * Called when console log is calling.
2235
+ */
2236
+ onUserConsoleLog?: (log: UserConsoleLog) => void;
2237
+ /**
2238
+ * Called when rstest exit abnormally
2239
+ */
2240
+ onExit?: () => void;
2241
+ }
2242
+
2243
+ declare const reportersMap: {
2244
+ default: typeof DefaultReporter;
2245
+ verbose: typeof VerboseReporter;
2246
+ 'github-actions': typeof GithubActionsReporter;
2247
+ junit: typeof JUnitReporter;
2248
+ };
2249
+
2250
+ declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
2251
+
2252
+ declare interface ReportOptions {
2253
+ clover: CloverOptions;
2254
+ cobertura: CoberturaOptions;
2255
+ "html-spa": HtmlSpaOptions;
2256
+ html: HtmlOptions;
2257
+ json: JsonOptions;
2258
+ "json-summary": JsonSummaryOptions;
2259
+ lcov: LcovOptions;
2260
+ lcovonly: LcovOnlyOptions;
2261
+ none: never;
2262
+ teamcity: TeamcityOptions;
2263
+ text: TextOptions;
2264
+ "text-lcov": TextLcovOptions;
2265
+ "text-summary": TextSummaryOptions;
2266
+ }
2267
+
2268
+ declare type ReportWithOptions<Name extends keyof ReportOptions = keyof ReportOptions> = Name extends keyof ReportOptions ? [Name, Partial<ReportOptions[Name]>] : [Name, Record<string, unknown>];
2269
+
2270
+ declare type Ro<T> = T extends Array<infer V> ? V[] | Readonly<V[]> | RoArray<V> | Readonly<RoArray<V>> : T extends object ? T | Readonly<T> | RoObject<T> | Readonly<RoObject<T>> : T;
2271
+
2272
+ declare type RoArray<T> = Ro<T>[];
2273
+
2274
+ declare type RoObject<T> = {
2275
+ [K in keyof T]: T[K] | Ro<T[K]>;
2276
+ };
2277
+
2278
+ export declare const rs: RstestUtilities;
2279
+
2280
+ export { rsbuild }
2281
+
2282
+ export declare class Rstest implements RstestContext {
2283
+ cwd: string;
2284
+ command: RstestCommand;
2285
+ fileFilters?: string[];
2286
+ configFilePath?: string;
2287
+ reporters: Reporter[];
2288
+ snapshotManager: SnapshotManager;
2289
+ version: string;
2290
+ rootPath: string;
2291
+ originalConfig: RstestConfig;
2292
+ normalizedConfig: NormalizedConfig;
2293
+ reporterResults: {
2294
+ results: TestFileResult[];
2295
+ testResults: TestResult[];
2296
+ };
2297
+ stateManager: TestStateManager;
2298
+ testState: RstestTestState;
2299
+ projects: ProjectContext[];
2300
+ constructor({ cwd, command, fileFilters, configFilePath, projects, }: Options_2, userConfig: RstestConfig);
2301
+ updateReporterResultState(results: TestFileResult[], testResults: TestResult[], deletedEntries?: string[]): void;
2302
+ }
2303
+
2304
+ export declare const rstest: RstestUtilities;
2305
+
2306
+ declare type Rstest_2 = RunnerAPI & {
2307
+ expect: RstestExpect;
2308
+ assert: typeof assert_2;
2309
+ rstest: RstestUtilities;
2310
+ rs: RstestUtilities;
2311
+ };
2312
+
2313
+ declare type RstestCommand = 'watch' | 'run' | 'list';
2314
+
2315
+ declare interface RstestConfig {
2316
+ /**
2317
+ * Extend configuration from adapters
2318
+ */
2319
+ extends?: ExtendConfigFn | ExtendConfig;
2320
+ /**
2321
+ * Project root
2322
+ *
2323
+ * @default process.cwd()
2324
+ */
2325
+ root?: string;
2326
+ /**
2327
+ * Run tests from one or more projects.
2328
+ */
2329
+ projects?: TestProject[];
2330
+ /**
2331
+ * Project name
2332
+ *
2333
+ * @default rstest
2334
+ */
2335
+ name?: string;
2336
+ /**
2337
+ * A list of glob patterns that match your test files.
2338
+ *
2339
+ * @default ['**\/*.{test,spec}.?(c|m)[jt]s?(x)']
2340
+ */
2341
+ include?: string[];
2342
+ /**
2343
+ * A list of glob patterns that should be excluded from your test files.
2344
+ *
2345
+ * @default ['**\/node_modules/**', '**\/dist/**']
2346
+ */
2347
+ exclude?: string[] | {
2348
+ patterns: string[];
2349
+ /**
2350
+ * override default exclude patterns
2351
+ * @default false
2352
+ */
2353
+ override?: boolean;
2354
+ };
2355
+ /**
2356
+ * A list of glob patterns that match your in-source test files
2357
+ *
2358
+ * @default []
2359
+ */
2360
+ includeSource?: string[];
2361
+ /**
2362
+ * Path to setup files. They will be run before each test file.
2363
+ */
2364
+ setupFiles?: string[] | string;
2365
+ /**
2366
+ * Path to global setup files, relative to project root.
2367
+ * A global setup file can either export named functions `setup` and `teardown`
2368
+ * or a `default` function that returns a teardown function.
2369
+ */
2370
+ globalSetup?: string[] | string;
2371
+ /**
2372
+ * Retry the test specific number of times if it fails.
2373
+ * @default 0
2374
+ */
2375
+ retry?: number;
2376
+ /**
2377
+ * Pass when no tests are found.
2378
+ *
2379
+ * @default false
2380
+ */
2381
+ passWithNoTests?: boolean;
2382
+ /**
2383
+ * Pool used to run tests in.
2384
+ */
2385
+ pool?: RstestPoolType | RstestPoolOptions;
2386
+ /**
2387
+ * Run tests in an isolated environment
2388
+ *
2389
+ * @default true
2390
+ */
2391
+ isolate?: boolean;
2392
+ /**
2393
+ * Provide global APIs
2394
+ *
2395
+ * @default false
2396
+ */
2397
+ globals?: boolean;
2398
+ /**
2399
+ * The environment that will be used for testing
2400
+ *
2401
+ * @default 'node'
2402
+ */
2403
+ testEnvironment?: EnvironmentName | EnvironmentWithOptions;
2404
+ /**
2405
+ * Stop running tests after n failures.
2406
+ * Set to 0 to run all tests regardless of failures.
2407
+ *
2408
+ * @default 0
2409
+ */
2410
+ bail?: number;
2411
+ /**
2412
+ * print console traces when calling any console method.
2413
+ *
2414
+ * @default false
2415
+ */
2416
+ printConsoleTrace?: boolean;
2417
+ /**
2418
+ * Disable console intercept. `onConsoleLog` & `printConsoleTrace` configuration will not take effect.
2419
+ *
2420
+ * @default false
2421
+ */
2422
+ disableConsoleIntercept?: boolean;
2423
+ /**
2424
+ * Update snapshot files. Will update all changed snapshots and delete obsolete ones.
2425
+ *
2426
+ * @default false
2427
+ */
2428
+ update?: boolean;
2429
+ /**
2430
+ * Custom reporter for output.
2431
+ * @default ['default']
2432
+ */
2433
+ reporters?: Reporter | BuiltInReporterNames | (Reporter | BuiltInReporterNames | [BuiltInReporterNames] | ReporterWithOptions)[];
2434
+ /**
2435
+ * Hide skipped tests logs.
2436
+ *
2437
+ * @default false
2438
+ */
2439
+ hideSkippedTests?: boolean;
2440
+ /**
2441
+ * Run only tests with a name that matches the regex.
2442
+ */
2443
+ testNamePattern?: string | RegExp;
2444
+ /**
2445
+ * Timeout of a test in milliseconds.
2446
+ * @default 5000
2447
+ */
2448
+ testTimeout?: number;
2449
+ /**
2450
+ * Timeout of hook in milliseconds.
2451
+ * @default 10000
2452
+ */
2453
+ hookTimeout?: number;
2454
+ /**
2455
+ * Automatically clear mock calls, instances, contexts and results before every test.
2456
+ * @default false
2457
+ */
2458
+ clearMocks?: boolean;
2459
+ /**
2460
+ * Automatically reset mock state before every test.
2461
+ * @default false
2462
+ */
2463
+ resetMocks?: boolean;
2464
+ /**
2465
+ * Automatically restore mock state and implementation before every test.
2466
+ * @default false
2467
+ */
2468
+ restoreMocks?: boolean;
2469
+ /**
2470
+ * The number of milliseconds after which a test or suite is considered slow and reported as such in the results.
2471
+ * @default 300
2472
+ */
2473
+ slowTestThreshold?: number;
2474
+ /**
2475
+ * Restores all global variables that were changed with `rstest.stubGlobal` before every test.
2476
+ * @default false
2477
+ */
2478
+ unstubGlobals?: boolean;
2479
+ /**
2480
+ * Restores all `process.env` values that were changed with `rstest.stubEnv` before every test.
2481
+ * @default false
2482
+ */
2483
+ unstubEnvs?: boolean;
2484
+ /**
2485
+ * Maximum number of concurrent tests
2486
+ * @default 5
2487
+ */
2488
+ maxConcurrency?: number;
2489
+ /**
2490
+ * Log heap usage after each test
2491
+ * @default false
2492
+ */
2493
+ logHeapUsage?: boolean;
2494
+ /**
2495
+ * Custom handler for console log in tests
2496
+ */
2497
+ onConsoleLog?: (content: string) => boolean | void;
2498
+ /** Format snapshot output */
2499
+ snapshotFormat?: SnapshotFormat;
2500
+ /**
2501
+ * Resolve custom snapshot path
2502
+ */
2503
+ resolveSnapshotPath?: (testPath: string, snapExtension: string) => string;
2504
+ /**
2505
+ * Custom environment variables available on `process.env` during tests.
2506
+ */
2507
+ env?: Partial<NodeJS.ProcessEnv>;
2508
+ /**
2509
+ * Browser mode configuration.
2510
+ */
2511
+ browser?: BrowserModeConfig;
2512
+ /**
2513
+ * Coverage options
2514
+ */
2515
+ coverage?: CoverageOptions;
2516
+ /**
2517
+ * chai configuration options
2518
+ */
2519
+ chaiConfig?: ChaiConfig;
2520
+ /**
2521
+ * Include `location` property in `TestInfo` received by reporters
2522
+ */
2523
+ includeTaskLocation?: boolean;
2524
+ plugins?: RsbuildConfig['plugins'];
2525
+ source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
2526
+ performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
2527
+ dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
2528
+ output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'>;
2529
+ resolve?: RsbuildConfig['resolve'];
2530
+ tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
2531
+ }
2532
+
2533
+ declare type RstestContext = {
2534
+ /** The Rstest core version. */
2535
+ version: string;
2536
+ /** The root path of rstest. */
2537
+ rootPath: string;
2538
+ /** The original Rstest config passed from the createRstest method. */
2539
+ originalConfig: Readonly<RstestConfig>;
2540
+ /** The normalized Rstest config. */
2541
+ normalizedConfig: NormalizedConfig;
2542
+ /** filter by a filename regex pattern */
2543
+ fileFilters?: string[];
2544
+ /** The config file path. */
2545
+ configFilePath?: string;
2546
+ /**
2547
+ * Run tests from one or more projects.
2548
+ */
2549
+ projects: ProjectContext[];
2550
+ /**
2551
+ * The test state
2552
+ */
2553
+ testState: RstestTestState;
2554
+ /**
2555
+ * The command type.
2556
+ *
2557
+ * - run: `rstest`
2558
+ * - dev: `rstest dev` or watch mode
2559
+ * - list: `rstest list`
2560
+ */
2561
+ command: RstestCommand;
2562
+ reporters: Reporter[];
2563
+ snapshotManager: SnapshotManager;
2564
+ stateManager: TestStateManager;
2565
+ };
2566
+
2567
+ declare type RstestExpect = ExpectStatic;
2568
+
2569
+ declare type RstestPoolOptions = {
2570
+ /** Pool used to run tests in. */
2571
+ type?: RstestPoolType;
2572
+ /** Maximum number or percentage of workers to run tests in. */
2573
+ maxWorkers?: number | string;
2574
+ /** Minimum number or percentage of workers to run tests in. */
2575
+ minWorkers?: number | string;
2576
+ /** Pass additional arguments to node process in the child processes. */
2577
+ execArgv?: string[];
2578
+ };
2579
+
2580
+ declare type RstestPoolType = 'forks';
2581
+
2582
+ declare type RstestTestState = {
2583
+ getRunningModules: () => RunningModules;
2584
+ getTestModules: () => TestFileResult[];
2585
+ /** Get the test files paths. return `undefined` in watch mode. */
2586
+ getTestFiles: () => string[] | undefined;
2587
+ };
2588
+
2589
+ declare interface RstestUtilities {
2590
+ /**
2591
+ * Creates a spy on a function.
2592
+ */
2593
+ fn: MockFn;
2594
+ /**
2595
+ * Creates a spy on a method of an object
2596
+ */
2597
+ spyOn: <T extends Record<string, any>, K extends keyof T>(obj: T, methodName: K, accessType?: 'get' | 'set') => MockInstance_2<T[K]>;
2598
+ /**
2599
+ * Determines if the given function is a mocked function.
2600
+ */
2601
+ isMockFunction: (fn: any) => fn is MockInstance_2;
2602
+ /**
2603
+ * Calls `.mockClear()` on all spies.
2604
+ */
2605
+ clearAllMocks: () => RstestUtilities;
2606
+ /**
2607
+ * Calls `.mockReset()` on all spies.
2608
+ */
2609
+ resetAllMocks: () => RstestUtilities;
2610
+ /**
2611
+ * Calls `.mockRestore()` on all spies.
2612
+ */
2613
+ restoreAllMocks: () => RstestUtilities;
2614
+ /**
2615
+ * Mock a module
2616
+ */
2617
+ mock<T = unknown>(moduleName: string | Promise<T>, moduleFactory?: MockFactory<T>): void;
2618
+ /**
2619
+ * Mock a module
2620
+ */
2621
+ mockRequire: <T = unknown>(moduleName: string, moduleFactory?: () => T) => void;
2622
+ /**
2623
+ * Mock a module, not hoisted.
2624
+ */
2625
+ doMock<T = unknown>(moduleName: string | Promise<T>, moduleFactory?: MockFactory<T>): void;
2626
+ /**
2627
+ * Mock a module, not hoisted.
2628
+ */
2629
+ doMockRequire: <T = unknown>(moduleName: string, moduleFactory?: () => T) => void;
2630
+ /**
2631
+ * Hoisted mock function.
2632
+ */
2633
+ hoisted: <T = unknown>(fn: () => T) => T;
2634
+ /**
2635
+ * Removes module from the mocked registry.
2636
+ */
2637
+ unmock: (path: string) => void;
2638
+ /**
2639
+ * Removes module from the mocked registry, not hoisted.
2640
+ */
2641
+ doUnmock: (path: string) => void;
2642
+ /**
2643
+ * Imports a module with all of its properties (including nested properties) mocked.
2644
+ */
2645
+ importMock: <T = Record<string, unknown>>(path: string) => Promise<T>;
2646
+ /**
2647
+ * Imports a module with all of its properties (including nested properties) mocked.
2648
+ */
2649
+ requireMock: <T = Record<string, unknown>>(path: string) => T;
2650
+ /**
2651
+ * Import and return the actual module instead of a mock, bypassing all checks on whether the module should receive a mock implementation or not.
2652
+ */
2653
+ importActual: <T = Record<string, unknown>>(path: string) => Promise<T>;
2654
+ /**
2655
+ * Require and return the actual module instead of a mock, bypassing all checks on whether the module should receive a mock implementation or not.
2656
+ */
2657
+ requireActual: <T = Record<string, unknown>>(path: string) => T;
2658
+ /**
2659
+ * Resets modules registry by clearing the cache of all modules.
2660
+ */
2661
+ resetModules: () => RstestUtilities;
2662
+ /**
2663
+ * Changes the value of environmental variable on `process.env`.
2664
+ */
2665
+ stubEnv: (name: string, value: string | undefined) => RstestUtilities;
2666
+ /**
2667
+ * Restores all `process.env` values that were changed with `rstest.stubEnv`.
2668
+ */
2669
+ unstubAllEnvs: () => RstestUtilities;
2670
+ /**
2671
+ * Changes the value of global variable.
2672
+ */
2673
+ stubGlobal: (name: string | number | symbol, value: unknown) => RstestUtilities;
2674
+ /**
2675
+ * Restores all global variables that were changed with `rstest.stubGlobal`.
2676
+ */
2677
+ unstubAllGlobals: () => RstestUtilities;
2678
+ /**
2679
+ * Update runtime config for the current test.
2680
+ */
2681
+ setConfig: (config: RuntimeOptions) => void;
2682
+ /**
2683
+ * get runtime config for the current test.
2684
+ */
2685
+ getConfig: () => RuntimeOptions;
2686
+ /**
2687
+ * Reset runtime config that were changed with `rstest.setConfig`.
2688
+ */
2689
+ resetConfig: () => void;
2690
+ /**
2691
+ * Mocks timers using `@sinonjs/fake-timers`.
2692
+ */
2693
+ useFakeTimers: (config?: FakeTimerInstallOpts) => RstestUtilities;
2694
+ useRealTimers: () => RstestUtilities;
2695
+ isFakeTimers: () => boolean;
2696
+ /**
2697
+ * Set the current system time used by fake timers.
2698
+ */
2699
+ setSystemTime: (now?: number | Date) => RstestUtilities;
2700
+ getRealSystemTime: () => number;
2701
+ runAllTicks: () => RstestUtilities;
2702
+ runAllTimers: () => RstestUtilities;
2703
+ runAllTimersAsync: () => Promise<RstestUtilities>;
2704
+ runOnlyPendingTimers: () => RstestUtilities;
2705
+ runOnlyPendingTimersAsync: () => Promise<RstestUtilities>;
2706
+ advanceTimersByTime: (ms: number) => RstestUtilities;
2707
+ advanceTimersByTimeAsync: (ms: number) => Promise<RstestUtilities>;
2708
+ advanceTimersToNextTimer: (steps?: number) => RstestUtilities;
2709
+ advanceTimersToNextTimerAsync: (steps?: number) => Promise<RstestUtilities>;
2710
+ advanceTimersToNextFrame: () => RstestUtilities;
2711
+ /**
2712
+ * Returns the number of fake timers still left to run.
2713
+ */
2714
+ getTimerCount: () => number;
2715
+ /**
2716
+ * Removes all timers that are scheduled to run.
2717
+ */
2718
+ clearAllTimers: () => RstestUtilities;
2719
+ }
2720
+
2721
+ declare type RunnerAPI = {
2722
+ describe: DescribeAPI;
2723
+ it: TestAPIs;
2724
+ test: TestAPIs;
2725
+ beforeAll: (fn: BeforeAllListener, timeout?: number) => MaybePromise<void>;
2726
+ afterAll: (fn: AfterAllListener, timeout?: number) => MaybePromise<void>;
2727
+ beforeEach: (fn: BeforeEachListener, timeout?: number) => MaybePromise<void>;
2728
+ afterEach: (fn: AfterEachListener, timeout?: number) => MaybePromise<void>;
2729
+ onTestFinished: (fn: OnTestFinishedHandler, timeout?: number) => void;
2730
+ onTestFailed: (fn: OnTestFailedHandler, timeout?: number) => void;
2731
+ };
2732
+
2733
+ export declare type RunnerHooks = {
2734
+ onTestSuiteStart?: (test: TestSuiteInfo) => Promise<void>;
2735
+ onTestSuiteResult?: (result: TestResult) => Promise<void>;
2736
+ /**
2737
+ * Called after tests in file collected.
2738
+ */
2739
+ onTestFileReady?: (test: TestFileInfo) => Promise<void>;
2740
+ /**
2741
+ * Called before running the test case.
2742
+ */
2743
+ onTestCaseStart?: (test: TestCaseInfo) => Promise<void>;
2744
+ /**
2745
+ * Called after the test is finished running.
2746
+ */
2747
+ onTestCaseResult?: (result: TestResult) => Promise<void>;
2748
+ /**
2749
+ * The number of failed tests.
2750
+ */
2751
+ getCountOfFailedTests: () => Promise<number>;
2752
+ };
2753
+
2754
+ declare type RunningModules = Map<string, {
2755
+ runningTests: TestCaseInfo[];
2756
+ results: TestResult[];
2757
+ }>;
2758
+
2759
+ export declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout' | 'coverage' | 'snapshotFormat' | 'env' | 'logHeapUsage' | 'bail' | 'chaiConfig' | 'includeTaskLocation'>;
2760
+
2761
+ declare type RuntimeOptions = Partial<Pick<RuntimeConfig, 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'maxConcurrency' | 'retry'>>;
2762
+
2763
+ declare interface SaveStatus {
2764
+ deleted: boolean;
2765
+ saved: boolean;
2766
+ }
2767
+
2768
+ /**
2769
+ * Makes some special types that are not supported for passing into the pool serializable.
2770
+ * eg. RegExp
2771
+ */
2772
+ export declare const serializableConfig: (normalizedConfig: RuntimeConfig) => RuntimeConfig;
2773
+
2774
+ export declare const setRealTimers: () => void;
2775
+
2776
+ declare class SnapshotClient {
2777
+ private options;
2778
+ snapshotStateMap: Map<string, SnapshotState>;
2779
+ constructor(options?: SnapshotClientOptions);
2780
+ setup(filepath: string, options: SnapshotStateOptions): Promise<void>;
2781
+ finish(filepath: string): Promise<SnapshotResult>;
2782
+ skipTest(filepath: string, testName: string): void;
2783
+ clearTest(filepath: string, testId: string): void;
2784
+ getSnapshotState(filepath: string): SnapshotState;
2785
+ assert(options: AssertOptions): void;
2786
+ assertRaw(options: AssertOptions): Promise<void>;
2787
+ clear(): void;
2788
+ }
2789
+
2790
+ declare interface SnapshotClientOptions {
2791
+ isEqual?: (received: unknown, expected: unknown) => boolean;
2792
+ }
2793
+
2794
+ declare interface SnapshotEnvironment {
2795
+ getVersion: () => string;
2796
+ getHeader: () => string;
2797
+ resolvePath: (filepath: string) => Promise<string>;
2798
+ resolveRawPath: (testPath: string, rawPath: string) => Promise<string>;
2799
+ saveSnapshotFile: (filepath: string, snapshot: string) => Promise<void>;
2800
+ readSnapshotFile: (filepath: string) => Promise<string | null>;
2801
+ removeSnapshotFile: (filepath: string) => Promise<void>;
2802
+ processStackTrace?: (stack: ParsedStack) => ParsedStack;
2803
+ }
2804
+
2805
+ declare type SnapshotFormat = Omit<NonNullable<SnapshotStateOptions['snapshotFormat']>, 'plugins' | 'compareKeys'>;
2806
+
2807
+ declare class SnapshotManager {
2808
+ options: Omit<SnapshotStateOptions, "snapshotEnvironment">;
2809
+ summary: SnapshotSummary;
2810
+ extension: string;
2811
+ constructor(options: Omit<SnapshotStateOptions, "snapshotEnvironment">);
2812
+ clear(): void;
2813
+ add(result: SnapshotResult): void;
2814
+ resolvePath<T = any>(testPath: string, context?: T): string;
2815
+ resolveRawPath(testPath: string, rawPath: string): string;
2816
+ }
2817
+
2818
+ declare interface SnapshotMatcher<T> {
2819
+ <U extends {
2820
+ [P in keyof T]: any;
2821
+ }>(snapshot: Partial<U>, message?: string): void;
2822
+ (message?: string): void;
2823
+ }
2824
+
2825
+ declare interface SnapshotMatchOptions {
2826
+ testId: string;
2827
+ testName: string;
2828
+ received: unknown;
2829
+ key?: string;
2830
+ inlineSnapshot?: string;
2831
+ isInline: boolean;
2832
+ error?: Error;
2833
+ rawSnapshot?: RawSnapshotInfo;
2834
+ }
2835
+
2836
+ declare interface SnapshotResult {
2837
+ filepath: string;
2838
+ added: number;
2839
+ fileDeleted: boolean;
2840
+ matched: number;
2841
+ unchecked: number;
2842
+ uncheckedKeys: Array<string>;
2843
+ unmatched: number;
2844
+ updated: number;
2845
+ }
2846
+
2847
+ declare interface SnapshotReturnOptions {
2848
+ actual: string;
2849
+ count: number;
2850
+ expected?: string;
2851
+ key: string;
2852
+ pass: boolean;
2853
+ }
2854
+
2855
+ declare class SnapshotState {
2856
+ testFilePath: string;
2857
+ snapshotPath: string;
2858
+ private _counters;
2859
+ private _dirty;
2860
+ private _updateSnapshot;
2861
+ private _snapshotData;
2862
+ private _initialData;
2863
+ private _inlineSnapshots;
2864
+ private _inlineSnapshotStacks;
2865
+ private _testIdToKeys;
2866
+ private _rawSnapshots;
2867
+ private _uncheckedKeys;
2868
+ private _snapshotFormat;
2869
+ private _environment;
2870
+ private _fileExists;
2871
+ expand: boolean;
2872
+ // getter/setter for jest-image-snapshot compat
2873
+ // https://github.com/vitest-dev/vitest/issues/7322
2874
+ private _added;
2875
+ private _matched;
2876
+ private _unmatched;
2877
+ private _updated;
2878
+ get added(): CounterMap<string>;
2879
+ set added(value: CounterMap<string>);
2880
+ get matched(): CounterMap<string>;
2881
+ set matched(value: CounterMap<string>);
2882
+ get unmatched(): CounterMap<string>;
2883
+ set unmatched(value: CounterMap<string>);
2884
+ get updated(): CounterMap<string>;
2885
+ set updated(value: CounterMap<string>);
2886
+ private constructor();
2887
+ static create(testFilePath: string, options: SnapshotStateOptions): Promise<SnapshotState>;
2888
+ get environment(): SnapshotEnvironment;
2889
+ markSnapshotsAsCheckedForTest(testName: string): void;
2890
+ clearTest(testId: string): void;
2891
+ protected _inferInlineSnapshotStack(stacks: ParsedStack[]): ParsedStack | null;
2892
+ private _addSnapshot;
2893
+ save(): Promise<SaveStatus>;
2894
+ getUncheckedCount(): number;
2895
+ getUncheckedKeys(): Array<string>;
2896
+ removeUncheckedKeys(): void;
2897
+ match({ testId, testName, received, key, inlineSnapshot, isInline, error, rawSnapshot }: SnapshotMatchOptions): SnapshotReturnOptions;
2898
+ pack(): Promise<SnapshotResult>;
2899
+ }
2900
+
2901
+ declare interface SnapshotStateOptions {
2902
+ updateSnapshot: SnapshotUpdateState;
2903
+ snapshotEnvironment: SnapshotEnvironment;
2904
+ expand?: boolean;
2905
+ snapshotFormat?: OptionsReceived;
2906
+ resolveSnapshotPath?: (path: string, extension: string, context?: any) => string;
2907
+ }
2908
+
2909
+ declare interface SnapshotSummary {
2910
+ added: number;
2911
+ didUpdate: boolean;
2912
+ failure: boolean;
2913
+ filesAdded: number;
2914
+ filesRemoved: number;
2915
+ filesRemovedList: Array<string>;
2916
+ filesUnmatched: number;
2917
+ filesUpdated: number;
2918
+ matched: number;
2919
+ total: number;
2920
+ unchecked: number;
2921
+ uncheckedKeysByFile: Array<UncheckedSnapshot>;
2922
+ unmatched: number;
2923
+ updated: number;
2924
+ }
2925
+
2926
+ declare type SnapshotUpdateState = "all" | "new" | "none";
2927
+
2928
+ declare type SourceColumn = number;
2929
+
2930
+ declare type SourceLine = number;
2931
+
2932
+ declare abstract class SourceMap {
2933
+ version: SourceMapV3['version'];
2934
+ file: SourceMapV3['file'];
2935
+ names: SourceMapV3['names'];
2936
+ sourceRoot: SourceMapV3['sourceRoot'];
2937
+ sources: SourceMapV3['sources'];
2938
+ sourcesContent: SourceMapV3['sourcesContent'];
2939
+ resolvedSources: SourceMapV3['sources'];
2940
+ ignoreList: SourceMapV3['ignoreList'];
2941
+ }
2942
+
2943
+ declare type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap;
2944
+
2945
+ declare type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];
2946
+
2947
+ declare interface SourceMapV3 {
2948
+ file?: string | null;
2949
+ names: string[];
2950
+ sourceRoot?: string;
2951
+ sources: (string | null)[];
2952
+ sourcesContent?: (string | null)[];
2953
+ version: 3;
2954
+ ignoreList?: number[];
2955
+ }
2956
+
2957
+ declare type SourcesIndex = number;
2958
+
2959
+ declare class StatusRenderer {
2960
+ private rootPath;
2961
+ private renderer;
2962
+ private startTime;
2963
+ private testState;
2964
+ constructor(rootPath: string, state: RstestTestState, logger?: Options['logger']);
2965
+ getContent(): string[];
2966
+ onTestFileStart(): void;
2967
+ onTestCaseResult(): void;
2968
+ onTestFileResult(): void;
2969
+ clear(): void;
2970
+ }
2971
+
2972
+ declare function stringify(object: unknown, maxDepth?: number, { maxLength,...options }?: StringifyOptions): string;
2973
+
2974
+ declare interface StringifyOptions extends PrettyFormatOptions {
2975
+ maxLength?: number;
2976
+ }
2977
+
2978
+ declare type SuiteContext = {
2979
+ filepath: TestPath;
2980
+ };
2981
+
2982
+ declare type Summarizers = "flat" | "nested" | "pkg" | "defaultSummarizer";
2983
+
2984
+ /** Union type for all supported reporter types */
2985
+ declare type SupportedReporter = keyof ReportOptions | ReportWithOptions | ReportBase | CustomReporter;
2986
+
2987
+ declare interface SyncExpectationResult {
2988
+ pass: boolean;
2989
+ message: () => string;
2990
+ actual?: any;
2991
+ expected?: any;
2992
+ }
2993
+
2994
+ declare interface TaskResult {
2995
+ /**
2996
+ * State of the task. Inherits the `task.mode` during collection.
2997
+ * When the task has finished, it will be changed to `pass` or `fail`.
2998
+ * - **pass**: task ran successfully
2999
+ * - **fail**: task failed
3000
+ */
3001
+ state: TaskState;
3002
+ /**
3003
+ * Errors that occurred during the task execution. It is possible to have several errors
3004
+ * if `expect.soft()` failed multiple times or `retry` was triggered.
3005
+ */
3006
+ errors?: FormattedError[];
3007
+ }
3008
+
3009
+ declare type TaskState = 'pass' | 'fail';
3010
+
3011
+ declare interface TeamcityOptions extends FileOptions {
3012
+ blockName: string;
3013
+ }
3014
+
3015
+ export declare const TEMP_RSTEST_OUTPUT_DIR = "dist/.rstest-temp";
3016
+
3017
+ export declare type Test = TestSuite | TestCase;
3018
+
3019
+ export declare const test: Rstest_2['test'];
3020
+
3021
+ declare type Test_2 = (arg0: any) => boolean;
3022
+
3023
+ declare type TestAPI<ExtraContext = object> = TestFn<ExtraContext> & {
3024
+ each: TestEachFn;
3025
+ for: TestForFn<ExtraContext>;
3026
+ fails: TestAPI<ExtraContext>;
3027
+ concurrent: TestAPI<ExtraContext>;
3028
+ sequential: TestAPI<ExtraContext>;
3029
+ only: TestAPI<ExtraContext>;
3030
+ skip: TestAPI<ExtraContext>;
3031
+ todo: TestAPI<ExtraContext>;
3032
+ runIf: (condition: boolean) => TestAPI<ExtraContext>;
3033
+ skipIf: (condition: boolean) => TestAPI<ExtraContext>;
3034
+ };
3035
+
3036
+ declare type TestAPIs<ExtraContext = object> = TestAPI<ExtraContext> & {
3037
+ extend: <T extends Record<string, any> = object>(fixtures: Fixtures<T, ExtraContext>) => TestAPIs<{
3038
+ [K in keyof T | keyof ExtraContext]: K extends keyof T ? T[K] : K extends keyof ExtraContext ? ExtraContext[K] : never;
3039
+ }>;
3040
+ };
3041
+
3042
+ declare type TestCallbackFn<ExtraContext = object> = (context: TestContext & ExtraContext) => MaybePromise<void>;
3043
+
3044
+ declare type TestCase = TestCaseInfo & {
3045
+ originalFn?: (context: TestContext) => void | Promise<void>;
3046
+ fn?: (context: TestContext) => void | Promise<void>;
3047
+ runMode: TestRunMode;
3048
+ fails?: boolean;
3049
+ each?: boolean;
3050
+ fixtures?: NormalizedFixtures;
3051
+ concurrent?: boolean;
3052
+ sequential?: boolean;
3053
+ inTestEach?: boolean;
3054
+ context: TestContext;
3055
+ only?: boolean;
3056
+ onFinished: OnTestFinishedHandler[];
3057
+ onFailed: OnTestFailedHandler[];
3058
+ /**
3059
+ * Store promises (from async expects) to wait for them before finishing the test
3060
+ */
3061
+ promises?: Promise<any>[];
3062
+ /**
3063
+ * Store stack trace error created when test is registered, used for trace original position
3064
+ */
3065
+ stackTraceError: Error;
3066
+ /**
3067
+ * Result of the task. if `expect.soft()` failed multiple times or `retry` was triggered.
3068
+ */
3069
+ result?: TaskResult;
3070
+ };
3071
+
3072
+ declare type TestCaseInfo = {
3073
+ testId: string;
3074
+ testPath: TestPath;
3075
+ name: string;
3076
+ timeout?: number;
3077
+ parentNames?: string[];
3078
+ project: string;
3079
+ startTime?: number;
3080
+ /** Only included when `includeTaskLocation` config is enabled */
3081
+ location?: Location_2;
3082
+ type: 'case';
3083
+ };
3084
+
3085
+ declare type TestContext = {
3086
+ /**
3087
+ * Metadata of the current test
3088
+ */
3089
+ task: {
3090
+ /** Test name provided by user */
3091
+ name: string;
3092
+ /** Result of the current test, undefined if the test is not run yet */
3093
+ result?: TestResult;
3094
+ };
3095
+ expect: RstestExpect;
3096
+ onTestFinished: RunnerAPI['onTestFinished'];
3097
+ onTestFailed: RunnerAPI['onTestFailed'];
3098
+ };
3099
+
3100
+ declare interface TestEachFn {
3101
+ <T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>, timeout?: number) => void;
3102
+ <T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>, timeout?: number) => void;
3103
+ <T>(cases: readonly T[]): (description: string, fn: (...args: T[]) => MaybePromise<void>, timeout?: number) => void;
3104
+ }
3105
+
3106
+ declare type Tester = (this: TesterContext, a: any, b: any, customTesters: Array<Tester>) => boolean | undefined;
3107
+
3108
+ declare interface TesterContext {
3109
+ equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
3110
+ }
3111
+
3112
+ declare type TestFileInfo = {
3113
+ testPath: TestPath;
3114
+ tests: TestInfo[];
3115
+ };
3116
+
3117
+ export declare type TestFileResult = TestResult & {
3118
+ results: TestResult[];
3119
+ snapshotResult?: SnapshotResult;
3120
+ coverage?: CoverageMapData;
3121
+ };
3122
+
3123
+ declare type TestFn<ExtraContext = object> = (description: string, fn?: TestCallbackFn<ExtraContext>, timeout?: number) => void;
3124
+
3125
+ declare type TestForFn<ExtraContext = object> = <T>(cases: readonly T[]) => (description: string, fn?: (param: T, context: TestContext & ExtraContext) => MaybePromise<void>, timeout?: number) => void;
3126
+
3127
+ declare type TestInfo = TestCaseInfo | (TestSuiteInfo & {
3128
+ tests: TestInfo[];
3129
+ });
3130
+
3131
+ /** The test file original path */
3132
+ declare type TestPath = string;
3133
+
3134
+ declare type TestProject = string | InlineProjectConfig;
3135
+
3136
+ export declare type TestResult = {
3137
+ testId: string;
3138
+ status: TestResultStatus;
3139
+ name: string;
3140
+ testPath: TestPath;
3141
+ parentNames?: string[];
3142
+ duration?: number;
3143
+ errors?: FormattedError[];
3144
+ retryCount?: number;
3145
+ project: string;
3146
+ heap?: number;
3147
+ };
3148
+
3149
+ declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
3150
+
3151
+ declare type TestRunMode = 'run' | 'skip' | 'todo' | 'only';
3152
+
3153
+ declare class TestStateManager {
3154
+ runningModules: Map<string, {
3155
+ runningTests: TestCaseInfo[];
3156
+ results: TestResult[];
3157
+ }>;
3158
+ testModules: TestFileResult[];
3159
+ testFiles: string[] | undefined;
3160
+ onTestFileStart(testPath: string): void;
3161
+ onTestCaseResult(result: TestResult): void;
3162
+ onTestCaseStart(test: TestCaseInfo): void;
3163
+ getCountOfFailedTests(): number;
3164
+ onTestFileResult(test: TestFileResult): void;
3165
+ reset(): void;
3166
+ }
3167
+
3168
+ declare type TestSuite = TestSuiteInfo & {
3169
+ runMode: TestRunMode;
3170
+ each?: boolean;
3171
+ inTestEach?: boolean;
3172
+ concurrent?: boolean;
3173
+ sequential?: boolean;
3174
+ /** nested cases and suite could in a suite */
3175
+ tests: Test[];
3176
+ afterAllListeners?: AfterAllListener[];
3177
+ beforeAllListeners?: BeforeAllListener[];
3178
+ afterEachListeners?: AfterEachListener[];
3179
+ beforeEachListeners?: BeforeEachListener[];
3180
+ };
3181
+
3182
+ declare type TestSuiteInfo = {
3183
+ testId: string;
3184
+ name: string;
3185
+ parentNames?: string[];
3186
+ testPath: TestPath;
3187
+ project: string;
3188
+ type: 'suite';
3189
+ /** Only included when `includeTaskLocation` config is enabled */
3190
+ location?: Location_2;
3191
+ };
3192
+
3193
+ declare type TextLcovOptions = ProjectOptions;
3194
+
3195
+ declare interface TextOptions extends FileOptions {
3196
+ maxCols: number;
3197
+ skipEmpty: boolean;
3198
+ skipFull: boolean;
3199
+ }
3200
+
3201
+ declare type TextSummaryOptions = FileOptions;
3202
+
3203
+ /** check thresholds for matched files */
3204
+ declare type ThresholdGlobRecord = Record<string, CoverageThreshold & {
3205
+ /**
3206
+ * check thresholds per file
3207
+ * @default false
3208
+ */
3209
+ perFile?: boolean;
3210
+ }>;
3211
+
3212
+ declare interface Totals {
3213
+ total: number;
3214
+ covered: number;
3215
+ skipped: number;
3216
+ pct: number;
3217
+ }
3218
+
3219
+ declare class TraceMap implements SourceMap {
3220
+ version: SourceMapV3['version'];
3221
+ file: SourceMapV3['file'];
3222
+ names: SourceMapV3['names'];
3223
+ sourceRoot: SourceMapV3['sourceRoot'];
3224
+ sources: SourceMapV3['sources'];
3225
+ sourcesContent: SourceMapV3['sourcesContent'];
3226
+ ignoreList: SourceMapV3['ignoreList'];
3227
+ resolvedSources: string[];
3228
+ private _encoded;
3229
+ private _decoded;
3230
+ private _decodedMemo;
3231
+ private _bySources;
3232
+ private _bySourceMemos;
3233
+ constructor(map: Ro<SourceMapInput>, mapUrl?: string | null);
3234
+ }
3235
+
3236
+ declare interface Tree<N extends Node_2 = Node_2> {
3237
+ getRoot(): N;
3238
+ visit(visitor: Partial<Visitor<N>>, state: any): void;
3239
+ }
3240
+
3241
+ declare interface UncheckedSnapshot {
3242
+ filePath: string;
3243
+ keys: Array<string>;
3244
+ }
3245
+
3246
+ declare type Use<T> = (value: T) => Promise<void>;
3247
+
3248
+ export declare interface UserConsoleLog {
3249
+ content: string;
3250
+ name: string;
3251
+ trace?: string;
3252
+ testPath: TestPath;
3253
+ type: 'stdout' | 'stderr';
3254
+ }
3255
+
3256
+ declare class VerboseReporter extends DefaultReporter {
3257
+ onTestFileResult(test: TestFileResult): void;
3258
+ }
3259
+
3260
+ declare interface Visitor<N extends Node_2 = Node_2> {
3261
+ onStart(root: N, state: any): void;
3262
+ onSummary(root: N, state: any): void;
3263
+ onDetail(root: N, state: any): void;
3264
+ onSummaryEnd(root: N, state: any): void;
3265
+ onEnd(root: N, state: any): void;
3266
+ }
3267
+
3268
+ declare type VitestAssertion<
3269
+ A,
3270
+ T
3271
+ > = { [K in keyof A] : A[K] extends Chai.Assertion ? Assertion_2<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T> } & ((type: string, message?: string) => Assertion_2);
3272
+
3273
+ declare type Watermark = [number, number];
3274
+
3275
+ declare interface Watermarks {
3276
+ statements: Watermark;
3277
+ functions: Watermark;
3278
+ branches: Watermark;
3279
+ lines: Watermark;
3280
+ }
3281
+
3282
+ declare type WithAsymmetricMatcher<T> = T | AsymmetricMatcher<unknown>;
3283
+
3284
+ declare type WorkerContext = {
3285
+ rootPath: RstestContext['rootPath'];
3286
+ projectRoot: ProjectContext['rootPath'];
3287
+ project: string;
3288
+ runtimeConfig: RuntimeConfig;
3289
+ taskId: number;
3290
+ outputModule: boolean;
3291
+ };
3292
+
3293
+ export declare type WorkerState = WorkerContext & {
3294
+ environment: string;
3295
+ testPath: TestPath;
3296
+ distPath: DistPath;
3297
+ snapshotClient?: SnapshotClient;
3298
+ snapshotOptions: {
3299
+ updateSnapshot: SnapshotUpdateState;
3300
+ snapshotEnvironment: SnapshotEnvironment;
3301
+ snapshotFormat: RuntimeConfig['snapshotFormat'];
3302
+ };
3303
+ };
3304
+
3305
+ declare type XInput = {
3306
+ x_google_ignoreList?: SourceMapV3['ignoreList'];
3307
+ };
3308
+
3309
+ declare interface XmlWriter {
3310
+ indent(str: string): string;
3311
+ /**
3312
+ * writes the opening XML tag with the supplied attributes
3313
+ */
3314
+ openTag(name: string, attrs?: any): void;
3315
+ /**
3316
+ * closes an open XML tag.
3317
+ */
3318
+ closeTag(name: string): void;
3319
+ /**
3320
+ * writes a tag and its value opening and closing it at the same time
3321
+ */
3322
+ inlineTag(name: string, attrs?: any, content?: string): void;
3323
+ /**
3324
+ * closes all open tags and ends the document
3325
+ */
3326
+ closeAll(): void;
3327
+ }
3328
+
3329
+ export { }