@rstest/core 0.7.8 → 0.8.0

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