@rstest/core 0.0.1
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 +21 -0
- package/README.md +11 -0
- package/bin/rstest.js +20 -0
- package/dist/285.js +98 -0
- package/dist/353.js +488 -0
- package/dist/355.js +96 -0
- package/dist/629.js +80 -0
- package/dist/64.js +1735 -0
- package/dist/72.js +1309 -0
- package/dist/773.js +1709 -0
- package/dist/813.js +137 -0
- package/dist/973.js +482 -0
- package/dist/992.js +485 -0
- package/dist/cli.js +3685 -0
- package/dist/node.js +0 -0
- package/dist/public.js +4 -0
- package/dist/worker.js +5727 -0
- package/dist/worker.js.LICENSE.txt +28 -0
- package/dist-types/cli.d.ts +3 -0
- package/dist-types/node.d.ts +368 -0
- package/dist-types/public.d.ts +850 -0
- package/dist-types/worker.d.ts +646 -0
- package/globals.d.ts +13 -0
- package/importMeta.d.ts +3 -0
- package/package.json +85 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* /**
|
|
3
|
+
* * Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
* *
|
|
5
|
+
* * This source code is licensed under the MIT license found in the
|
|
6
|
+
* * LICENSE file in the root directory of this source tree.
|
|
7
|
+
* * /
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @license React
|
|
12
|
+
* react-is.development.js
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the MIT license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @license React
|
|
22
|
+
* react-is.production.min.js
|
|
23
|
+
*
|
|
24
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
25
|
+
*
|
|
26
|
+
* This source code is licensed under the MIT license found in the
|
|
27
|
+
* LICENSE file in the root directory of this source tree.
|
|
28
|
+
*/
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import type { RsbuildConfig } from '@rsbuild/core';
|
|
2
|
+
import type { SnapshotResult } from '@vitest/snapshot';
|
|
3
|
+
import type { SnapshotSummary } from '@vitest/snapshot';
|
|
4
|
+
|
|
5
|
+
declare type BuiltInReporterNames = keyof typeof reportersMap;
|
|
6
|
+
|
|
7
|
+
declare type BuiltinReporterOptions = {
|
|
8
|
+
default: DefaultReporterOptions;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
declare interface DecodedSourceMap extends SourceMapV3 {
|
|
12
|
+
mappings: SourceMapSegment[][];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare type DecodedSourceMapXInput = DecodedSourceMap & XInput;
|
|
16
|
+
|
|
17
|
+
declare class DefaultReporter implements Reporter {
|
|
18
|
+
private rootPath;
|
|
19
|
+
private config;
|
|
20
|
+
private options;
|
|
21
|
+
private statusRenderer;
|
|
22
|
+
constructor({ rootPath, options, config, }: {
|
|
23
|
+
rootPath: string;
|
|
24
|
+
config: NormalizedConfig;
|
|
25
|
+
options: DefaultReporterOptions;
|
|
26
|
+
});
|
|
27
|
+
onTestFileStart(test: TestFileInfo): void;
|
|
28
|
+
onTestFileResult(test: TestFileResult): void;
|
|
29
|
+
onTestCaseResult(_result: TestResult): void;
|
|
30
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
31
|
+
onExit(): Promise<void>;
|
|
32
|
+
onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, }: {
|
|
33
|
+
results: TestFileResult[];
|
|
34
|
+
testResults: TestResult[];
|
|
35
|
+
duration: Duration;
|
|
36
|
+
snapshotSummary: SnapshotSummary;
|
|
37
|
+
getSourcemap: GetSourcemap;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare type DefaultReporterOptions = {
|
|
42
|
+
/**
|
|
43
|
+
* prints out summary of all tests
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
summary?: boolean;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
declare type Duration = {
|
|
50
|
+
totalTime: number;
|
|
51
|
+
buildTime: number;
|
|
52
|
+
testTime: number;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
declare interface EncodedSourceMap extends SourceMapV3 {
|
|
56
|
+
mappings: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare type EncodedSourceMapXInput = EncodedSourceMap & XInput;
|
|
60
|
+
|
|
61
|
+
declare type FormattedError = {
|
|
62
|
+
message: string;
|
|
63
|
+
name?: string;
|
|
64
|
+
stack?: string;
|
|
65
|
+
diff?: string;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
declare type GeneratedColumn = number;
|
|
69
|
+
|
|
70
|
+
declare type GetSourcemap = (sourcePath: string) => SourceMapInput | null;
|
|
71
|
+
|
|
72
|
+
declare type MaybePromise<T> = T | Promise<T>;
|
|
73
|
+
|
|
74
|
+
declare type NamesIndex = number;
|
|
75
|
+
|
|
76
|
+
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool'>> & {
|
|
77
|
+
[key in OptionalKeys]?: RstestConfig[key];
|
|
78
|
+
} & {
|
|
79
|
+
pool: RstestPoolOptions;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
declare type OptionalKeys = 'setupFiles' | 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'onConsoleLog';
|
|
83
|
+
|
|
84
|
+
export declare interface Reporter {
|
|
85
|
+
/**
|
|
86
|
+
* Called before test file run.
|
|
87
|
+
*/
|
|
88
|
+
onTestFileStart?: (test: TestFileInfo) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Called when the test file has finished running.
|
|
91
|
+
*/
|
|
92
|
+
onTestFileResult?: (test: TestFileResult) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Called when the test has finished running or was just skipped.
|
|
95
|
+
*/
|
|
96
|
+
onTestCaseResult?: (result: TestResult) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Called after all tests have finished running.
|
|
99
|
+
*/
|
|
100
|
+
onTestRunEnd?: ({ results, testResults, duration, getSourcemap, snapshotSummary, }: {
|
|
101
|
+
results: TestFileResult[];
|
|
102
|
+
testResults: TestResult[];
|
|
103
|
+
duration: Duration;
|
|
104
|
+
getSourcemap: GetSourcemap;
|
|
105
|
+
snapshotSummary: SnapshotSummary;
|
|
106
|
+
}) => MaybePromise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Called when console log is calling.
|
|
109
|
+
*/
|
|
110
|
+
onUserConsoleLog?: (log: UserConsoleLog) => void;
|
|
111
|
+
/**
|
|
112
|
+
* Called when rstest exit abnormally
|
|
113
|
+
*/
|
|
114
|
+
onExit?: () => void;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
declare const reportersMap: {
|
|
118
|
+
default: typeof DefaultReporter;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
|
|
122
|
+
|
|
123
|
+
export declare type RstestCommand = 'watch' | 'run' | 'list';
|
|
124
|
+
|
|
125
|
+
export declare interface RstestConfig {
|
|
126
|
+
/**
|
|
127
|
+
* Project root
|
|
128
|
+
*
|
|
129
|
+
* @default process.cwd()
|
|
130
|
+
*/
|
|
131
|
+
root?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Project name
|
|
134
|
+
*
|
|
135
|
+
* @default rstest
|
|
136
|
+
*/
|
|
137
|
+
name?: string;
|
|
138
|
+
/**
|
|
139
|
+
* A list of glob patterns that match your test files.
|
|
140
|
+
*
|
|
141
|
+
* @default ['**\/*.{test,spec}.?(c|m)[jt]s?(x)']
|
|
142
|
+
*/
|
|
143
|
+
include?: string[];
|
|
144
|
+
/**
|
|
145
|
+
* A list of glob patterns that should be excluded from your test files.
|
|
146
|
+
*
|
|
147
|
+
* @default ['**\/node_modules/**', '**\/dist/**']
|
|
148
|
+
*/
|
|
149
|
+
exclude?: string[];
|
|
150
|
+
/**
|
|
151
|
+
* A list of glob patterns that match your in-source test files
|
|
152
|
+
*
|
|
153
|
+
* @default []
|
|
154
|
+
*/
|
|
155
|
+
includeSource?: string[];
|
|
156
|
+
/**
|
|
157
|
+
* Path to setup files. They will be run before each test file.
|
|
158
|
+
*/
|
|
159
|
+
setupFiles?: string[] | string;
|
|
160
|
+
/**
|
|
161
|
+
* Retry the test specific number of times if it fails.
|
|
162
|
+
* @default 0
|
|
163
|
+
*/
|
|
164
|
+
retry?: number;
|
|
165
|
+
/**
|
|
166
|
+
* Allows the test suite to pass when no files are found.
|
|
167
|
+
*
|
|
168
|
+
* @default false
|
|
169
|
+
*/
|
|
170
|
+
passWithNoTests?: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Pool used to run tests in.
|
|
173
|
+
*/
|
|
174
|
+
pool?: RstestPoolType | RstestPoolOptions;
|
|
175
|
+
/**
|
|
176
|
+
* Run tests in an isolated environment
|
|
177
|
+
*
|
|
178
|
+
* @default true
|
|
179
|
+
*/
|
|
180
|
+
isolate?: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Provide global APIs
|
|
183
|
+
*
|
|
184
|
+
* @default false
|
|
185
|
+
*/
|
|
186
|
+
globals?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* The environment that will be used for testing
|
|
189
|
+
*
|
|
190
|
+
* TODO: support more test environments
|
|
191
|
+
* @default 'node'
|
|
192
|
+
*/
|
|
193
|
+
testEnvironment?: 'node';
|
|
194
|
+
/**
|
|
195
|
+
* print console traces when calling any console method.
|
|
196
|
+
*
|
|
197
|
+
* @default false
|
|
198
|
+
*/
|
|
199
|
+
printConsoleTrace?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Disable console intercept. `onConsoleLog` & `printConsoleTrace` configuration will not take effect.
|
|
202
|
+
*
|
|
203
|
+
* @default false
|
|
204
|
+
*/
|
|
205
|
+
disableConsoleIntercept?: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Update snapshot files. Will update all changed snapshots and delete obsolete ones.
|
|
208
|
+
*
|
|
209
|
+
* @default false
|
|
210
|
+
*/
|
|
211
|
+
update?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Custom reporter for output.
|
|
214
|
+
* @default ['default']
|
|
215
|
+
*/
|
|
216
|
+
reporters?: Reporter | BuiltInReporterNames | (Reporter | BuiltInReporterNames | [BuiltInReporterNames] | ReporterWithOptions)[];
|
|
217
|
+
/**
|
|
218
|
+
* Run only tests with a name that matches the regex.
|
|
219
|
+
*/
|
|
220
|
+
testNamePattern?: string | RegExp;
|
|
221
|
+
/**
|
|
222
|
+
* Timeout of a test in milliseconds.
|
|
223
|
+
* @default 5000
|
|
224
|
+
*/
|
|
225
|
+
testTimeout?: number;
|
|
226
|
+
/**
|
|
227
|
+
* Automatically clear mock calls, instances, contexts and results before every test.
|
|
228
|
+
* @default false
|
|
229
|
+
*/
|
|
230
|
+
clearMocks?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Automatically reset mock state before every test.
|
|
233
|
+
* @default false
|
|
234
|
+
*/
|
|
235
|
+
resetMocks?: boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Automatically restore mock state and implementation before every test.
|
|
238
|
+
* @default false
|
|
239
|
+
*/
|
|
240
|
+
restoreMocks?: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* The number of milliseconds after which a test or suite is considered slow and reported as such in the results.
|
|
243
|
+
* @default 300
|
|
244
|
+
*/
|
|
245
|
+
slowTestThreshold?: number;
|
|
246
|
+
/**
|
|
247
|
+
* Restores all global variables that were changed with `rstest.stubGlobal` before every test.
|
|
248
|
+
* @default false
|
|
249
|
+
*/
|
|
250
|
+
unstubGlobals?: boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Restores all `process.env` values that were changed with `rstest.stubEnv` before every test.
|
|
253
|
+
* @default false
|
|
254
|
+
*/
|
|
255
|
+
unstubEnvs?: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Maximum number of concurrent tests
|
|
258
|
+
* @default 5
|
|
259
|
+
*/
|
|
260
|
+
maxConcurrency?: number;
|
|
261
|
+
/**
|
|
262
|
+
* Custom handler for console log in tests
|
|
263
|
+
*/
|
|
264
|
+
onConsoleLog?: (content: string) => boolean | void;
|
|
265
|
+
plugins?: RsbuildConfig['plugins'];
|
|
266
|
+
source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
|
|
267
|
+
output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules'>;
|
|
268
|
+
resolve?: RsbuildConfig['resolve'];
|
|
269
|
+
tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
declare type RstestPoolOptions = {
|
|
273
|
+
/** Pool used to run tests in. */
|
|
274
|
+
type: RstestPoolType;
|
|
275
|
+
/** Maximum number or percentage of workers to run tests in. */
|
|
276
|
+
maxWorkers?: number | string;
|
|
277
|
+
/** Minimum number or percentage of workers to run tests in. */
|
|
278
|
+
minWorkers?: number | string;
|
|
279
|
+
/** Pass additional arguments to node process in the child processes. */
|
|
280
|
+
execArgv?: string[];
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
declare type RstestPoolType = 'forks';
|
|
284
|
+
|
|
285
|
+
declare type SourceColumn = number;
|
|
286
|
+
|
|
287
|
+
declare type SourceLine = number;
|
|
288
|
+
|
|
289
|
+
declare abstract class SourceMap {
|
|
290
|
+
version: SourceMapV3['version'];
|
|
291
|
+
file: SourceMapV3['file'];
|
|
292
|
+
names: SourceMapV3['names'];
|
|
293
|
+
sourceRoot: SourceMapV3['sourceRoot'];
|
|
294
|
+
sources: SourceMapV3['sources'];
|
|
295
|
+
sourcesContent: SourceMapV3['sourcesContent'];
|
|
296
|
+
resolvedSources: SourceMapV3['sources'];
|
|
297
|
+
ignoreList: SourceMapV3['ignoreList'];
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
declare type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap;
|
|
301
|
+
|
|
302
|
+
declare type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];
|
|
303
|
+
|
|
304
|
+
declare interface SourceMapV3 {
|
|
305
|
+
file?: string | null;
|
|
306
|
+
names: string[];
|
|
307
|
+
sourceRoot?: string;
|
|
308
|
+
sources: (string | null)[];
|
|
309
|
+
sourcesContent?: (string | null)[];
|
|
310
|
+
version: 3;
|
|
311
|
+
ignoreList?: number[];
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
declare type SourcesIndex = number;
|
|
315
|
+
|
|
316
|
+
declare type TestFileInfo = {
|
|
317
|
+
testPath: TestPath;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
declare type TestFileResult = TestResult & {
|
|
321
|
+
results: TestResult[];
|
|
322
|
+
snapshotResult?: SnapshotResult;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
/** The test file original path */
|
|
326
|
+
declare type TestPath = string;
|
|
327
|
+
|
|
328
|
+
declare type TestResult = {
|
|
329
|
+
status: TestResultStatus;
|
|
330
|
+
name: string;
|
|
331
|
+
testPath: TestPath;
|
|
332
|
+
parentNames?: string[];
|
|
333
|
+
duration?: number;
|
|
334
|
+
errors?: FormattedError[];
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
|
|
338
|
+
|
|
339
|
+
declare class TraceMap implements SourceMap {
|
|
340
|
+
version: SourceMapV3['version'];
|
|
341
|
+
file: SourceMapV3['file'];
|
|
342
|
+
names: SourceMapV3['names'];
|
|
343
|
+
sourceRoot: SourceMapV3['sourceRoot'];
|
|
344
|
+
sources: SourceMapV3['sources'];
|
|
345
|
+
sourcesContent: SourceMapV3['sourcesContent'];
|
|
346
|
+
ignoreList: SourceMapV3['ignoreList'];
|
|
347
|
+
resolvedSources: string[];
|
|
348
|
+
private _encoded;
|
|
349
|
+
private _decoded;
|
|
350
|
+
private _decodedMemo;
|
|
351
|
+
private _bySources;
|
|
352
|
+
private _bySourceMemos;
|
|
353
|
+
constructor(map: SourceMapInput, mapUrl?: string | null);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
declare interface UserConsoleLog {
|
|
357
|
+
content: string;
|
|
358
|
+
name: string;
|
|
359
|
+
trace?: string;
|
|
360
|
+
testPath: TestPath;
|
|
361
|
+
type: 'stdout' | 'stderr';
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
declare type XInput = {
|
|
365
|
+
x_google_ignoreList?: SourceMapV3['ignoreList'];
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
export { }
|