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