vitest 0.0.62 → 0.0.66
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 +2 -1
- package/README.gh.md +11 -15
- package/dist/chunk-5TNYWP3O.js +81 -0
- package/dist/chunk-ANPMHBIF.js +253 -0
- package/dist/chunk-APGELTDH.js +19 -0
- package/dist/chunk-R2SMNEBL.js +95 -0
- package/dist/chunk-VLGIKNLC.js +78 -0
- package/dist/chunk-XUIDSY4V.js +35 -0
- package/dist/chunk-YPKHVZRP.js +86 -0
- package/dist/global-PRFYLY7P.js +22 -0
- package/dist/index.d.ts +33 -10
- package/dist/index.js +46 -1
- package/dist/node/cli.d.ts +0 -12
- package/dist/node/cli.js +2609 -19
- package/dist/{types-c0d293d3.d.ts → options-63a726fa.d.ts} +133 -148
- package/dist/runtime/entry.d.ts +1 -3
- package/dist/runtime/entry.js +2535 -9
- package/dist/{node → runtime}/worker.d.ts +4 -5
- package/dist/runtime/worker.js +263 -0
- package/package.json +40 -27
- package/dist/chunk-4HLM7BTV.js +0 -1
- package/dist/chunk-JKSYS65D.js +0 -1
- package/dist/chunk-LNO4ZIPT.js +0 -1
- package/dist/chunk-NTRHKVSE.js +0 -1
- package/dist/global-GT6TCEAH.js +0 -1
- package/dist/node/worker.js +0 -4
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { MessagePort } from 'worker_threads';
|
|
2
|
-
import { Awaitable } from '@antfu/utils';
|
|
3
1
|
import { TransformResult, ViteDevServer } from 'vite';
|
|
4
2
|
import { OptionsReceived } from 'pretty-format';
|
|
5
3
|
|
|
@@ -21,115 +19,29 @@ declare class SnapshotManager {
|
|
|
21
19
|
add(result: SnapshotResult): void;
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Exclude globs for test files
|
|
33
|
-
* @default ['**\/node_modules\/**']
|
|
34
|
-
*/
|
|
35
|
-
excludes?: string[];
|
|
36
|
-
/**
|
|
37
|
-
* Handling for dependencies inlining or externalizing
|
|
38
|
-
*/
|
|
39
|
-
deps?: {
|
|
40
|
-
/**
|
|
41
|
-
* Externalize means that Vite will bypass the package to native Node.
|
|
42
|
-
*
|
|
43
|
-
* Externaled dependencies will not be applied Vite's transformers and resolvers.
|
|
44
|
-
* And does not support HMR on reload.
|
|
45
|
-
*
|
|
46
|
-
* Typically, packages under `node_modules` are externalized.
|
|
47
|
-
*/
|
|
48
|
-
external?: (string | RegExp)[];
|
|
49
|
-
/**
|
|
50
|
-
* Vite will process inlined modules.
|
|
51
|
-
*
|
|
52
|
-
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
53
|
-
*/
|
|
54
|
-
inline?: (string | RegExp)[];
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Register apis globally
|
|
58
|
-
*
|
|
59
|
-
* @default false
|
|
60
|
-
*/
|
|
61
|
-
global?: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Running environment
|
|
64
|
-
*
|
|
65
|
-
* Supports 'node', 'jsdom', 'happy-dom'
|
|
66
|
-
*
|
|
67
|
-
* @default 'node'
|
|
68
|
-
*/
|
|
69
|
-
environment?: 'node' | 'jsdom' | 'happy-dom';
|
|
70
|
-
/**
|
|
71
|
-
* Update snapshot files
|
|
72
|
-
*
|
|
73
|
-
* @default false
|
|
74
|
-
*/
|
|
75
|
-
update?: boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Watch mode
|
|
78
|
-
*
|
|
79
|
-
* @default false
|
|
80
|
-
*/
|
|
81
|
-
watch?: boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Project root
|
|
84
|
-
*/
|
|
85
|
-
root?: string;
|
|
86
|
-
/**
|
|
87
|
-
* Custom reporter for output
|
|
88
|
-
*/
|
|
89
|
-
reporter?: Reporter;
|
|
90
|
-
/**
|
|
91
|
-
* Enable multi-threading
|
|
92
|
-
*
|
|
93
|
-
* @default true
|
|
94
|
-
*/
|
|
95
|
-
threads?: boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Maximum number of threads
|
|
98
|
-
*
|
|
99
|
-
* @default available CPUs
|
|
100
|
-
*/
|
|
101
|
-
maxThreads?: number;
|
|
102
|
-
/**
|
|
103
|
-
* Minimum number of threads
|
|
104
|
-
*
|
|
105
|
-
* @default available CPUs
|
|
106
|
-
*/
|
|
107
|
-
minThreads?: number;
|
|
108
|
-
interpretDefault?: boolean;
|
|
22
|
+
declare type Awaitable<T> = T | PromiseLike<T>;
|
|
23
|
+
declare type Nullable<T> = T | null | undefined;
|
|
24
|
+
declare type Arrayable<T> = T | Array<T>;
|
|
25
|
+
interface ModuleCache {
|
|
26
|
+
promise?: Promise<any>;
|
|
27
|
+
exports?: any;
|
|
28
|
+
transformResult?: TransformResult;
|
|
109
29
|
}
|
|
110
|
-
interface
|
|
111
|
-
|
|
112
|
-
* Filters by name
|
|
113
|
-
*/
|
|
114
|
-
cliFilters?: string[];
|
|
115
|
-
/**
|
|
116
|
-
* Path to the config file.
|
|
117
|
-
*
|
|
118
|
-
* Default resolving to one of:
|
|
119
|
-
* - `vitest.config.js`
|
|
120
|
-
* - `vitest.config.ts`
|
|
121
|
-
* - `vite.config.js`
|
|
122
|
-
* - `vite.config.ts`
|
|
123
|
-
*/
|
|
124
|
-
config?: string | undefined;
|
|
30
|
+
interface EnvironmentReturn {
|
|
31
|
+
teardown: (global: any) => Awaitable<void>;
|
|
125
32
|
}
|
|
126
|
-
interface
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
depsInline: (string | RegExp)[];
|
|
130
|
-
depsExternal: (string | RegExp)[];
|
|
131
|
-
snapshotOptions: SnapshotStateOptions;
|
|
33
|
+
interface Environment {
|
|
34
|
+
name: string;
|
|
35
|
+
setup(global: any): Awaitable<EnvironmentReturn>;
|
|
132
36
|
}
|
|
37
|
+
interface VitestContext {
|
|
38
|
+
config: ResolvedConfig;
|
|
39
|
+
server: ViteDevServer;
|
|
40
|
+
state: StateManager;
|
|
41
|
+
snapshot: SnapshotManager;
|
|
42
|
+
reporter: Reporter;
|
|
43
|
+
}
|
|
44
|
+
|
|
133
45
|
declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
134
46
|
declare type TaskState = RunMode | 'pass' | 'fail';
|
|
135
47
|
declare type ComputeMode = 'serial' | 'concurrent';
|
|
@@ -211,6 +123,7 @@ interface GlobalContext {
|
|
|
211
123
|
tasks: (SuiteCollector | Test)[];
|
|
212
124
|
currentSuite: SuiteCollector | null;
|
|
213
125
|
}
|
|
126
|
+
|
|
214
127
|
interface Reporter {
|
|
215
128
|
onStart?: (files?: string[]) => Awaitable<void>;
|
|
216
129
|
onFinished?: (files?: File[]) => Awaitable<void>;
|
|
@@ -218,11 +131,7 @@ interface Reporter {
|
|
|
218
131
|
onWatcherStart?: () => Awaitable<void>;
|
|
219
132
|
onWatcherRerun?: (files: string[], trigger: string) => Awaitable<void>;
|
|
220
133
|
}
|
|
221
|
-
|
|
222
|
-
promise?: Promise<any>;
|
|
223
|
-
exports?: any;
|
|
224
|
-
transformResult?: TransformResult;
|
|
225
|
-
}
|
|
134
|
+
|
|
226
135
|
declare type SnapshotData = Record<string, string>;
|
|
227
136
|
declare type SnapshotUpdateState = 'all' | 'new' | 'none';
|
|
228
137
|
declare type SnapshotStateOptions = {
|
|
@@ -268,42 +177,118 @@ interface SnapshotSummary {
|
|
|
268
177
|
unmatched: number;
|
|
269
178
|
updated: number;
|
|
270
179
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
180
|
+
|
|
181
|
+
interface UserOptions {
|
|
182
|
+
/**
|
|
183
|
+
* Include globs for test files
|
|
184
|
+
*
|
|
185
|
+
* @default ['**\/*.test.ts']
|
|
186
|
+
*/
|
|
187
|
+
includes?: string[];
|
|
188
|
+
/**
|
|
189
|
+
* Exclude globs for test files
|
|
190
|
+
* @default ['**\/node_modules\/**']
|
|
191
|
+
*/
|
|
192
|
+
excludes?: string[];
|
|
193
|
+
/**
|
|
194
|
+
* Handling for dependencies inlining or externalizing
|
|
195
|
+
*/
|
|
196
|
+
deps?: {
|
|
197
|
+
/**
|
|
198
|
+
* Externalize means that Vite will bypass the package to native Node.
|
|
199
|
+
*
|
|
200
|
+
* Externaled dependencies will not be applied Vite's transformers and resolvers.
|
|
201
|
+
* And does not support HMR on reload.
|
|
202
|
+
*
|
|
203
|
+
* Typically, packages under `node_modules` are externalized.
|
|
204
|
+
*/
|
|
205
|
+
external?: (string | RegExp)[];
|
|
206
|
+
/**
|
|
207
|
+
* Vite will process inlined modules.
|
|
208
|
+
*
|
|
209
|
+
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
210
|
+
*/
|
|
211
|
+
inline?: (string | RegExp)[];
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Register apis globally
|
|
215
|
+
*
|
|
216
|
+
* @default false
|
|
217
|
+
*/
|
|
218
|
+
global?: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Running environment
|
|
221
|
+
*
|
|
222
|
+
* Supports 'node', 'jsdom', 'happy-dom'
|
|
223
|
+
*
|
|
224
|
+
* @default 'node'
|
|
225
|
+
*/
|
|
226
|
+
environment?: 'node' | 'jsdom' | 'happy-dom';
|
|
227
|
+
/**
|
|
228
|
+
* Update snapshot files
|
|
229
|
+
*
|
|
230
|
+
* @default false
|
|
231
|
+
*/
|
|
232
|
+
update?: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Watch mode
|
|
235
|
+
*
|
|
236
|
+
* @default false
|
|
237
|
+
*/
|
|
238
|
+
watch?: boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Project root
|
|
241
|
+
*/
|
|
242
|
+
root?: string;
|
|
243
|
+
/**
|
|
244
|
+
* Custom reporter for output
|
|
245
|
+
*/
|
|
246
|
+
reporter?: Reporter;
|
|
247
|
+
/**
|
|
248
|
+
* Enable multi-threading
|
|
249
|
+
*
|
|
250
|
+
* @default true
|
|
251
|
+
*/
|
|
252
|
+
threads?: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Maximum number of threads
|
|
255
|
+
*
|
|
256
|
+
* @default available CPUs
|
|
257
|
+
*/
|
|
258
|
+
maxThreads?: number;
|
|
259
|
+
/**
|
|
260
|
+
* Minimum number of threads
|
|
261
|
+
*
|
|
262
|
+
* @default available CPUs
|
|
263
|
+
*/
|
|
264
|
+
minThreads?: number;
|
|
265
|
+
interpretDefault?: boolean;
|
|
266
|
+
testTimeout?: number;
|
|
267
|
+
hookTimeout?: number;
|
|
283
268
|
}
|
|
284
|
-
interface
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
269
|
+
interface CliOptions extends UserOptions {
|
|
270
|
+
/**
|
|
271
|
+
* Filters by name
|
|
272
|
+
*/
|
|
273
|
+
cliFilters?: string[];
|
|
274
|
+
/**
|
|
275
|
+
* Path to the config file.
|
|
276
|
+
*
|
|
277
|
+
* Default resolving to one of:
|
|
278
|
+
* - `vitest.config.js`
|
|
279
|
+
* - `vitest.config.ts`
|
|
280
|
+
* - `vite.config.js`
|
|
281
|
+
* - `vite.config.ts`
|
|
282
|
+
*/
|
|
283
|
+
config?: string | undefined;
|
|
284
|
+
dom?: boolean;
|
|
290
285
|
}
|
|
291
|
-
interface
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
onWatcherStart: [[], void];
|
|
298
|
-
onWatcherRerun: [[files: string[], trigger: string], void];
|
|
299
|
-
snapshotSaved: [[snapshot: SnapshotResult], void];
|
|
286
|
+
interface ResolvedConfig extends Omit<Required<CliOptions>, 'config' | 'filters'> {
|
|
287
|
+
config?: string;
|
|
288
|
+
filters?: string[];
|
|
289
|
+
depsInline: (string | RegExp)[];
|
|
290
|
+
depsExternal: (string | RegExp)[];
|
|
291
|
+
snapshotOptions: SnapshotStateOptions;
|
|
300
292
|
}
|
|
301
|
-
declare type RpcCall = <T extends keyof RpcMap>(method: T, ...args: RpcMap[T][0]) => Promise<RpcMap[T][1]>;
|
|
302
|
-
declare type RpcSend = <T extends keyof RpcMap>(method: T, ...args: RpcMap[T][0]) => void;
|
|
303
|
-
declare type RpcPayload<T extends keyof RpcMap = keyof RpcMap> = {
|
|
304
|
-
id: string;
|
|
305
|
-
method: T;
|
|
306
|
-
args: RpcMap[T][0];
|
|
307
|
-
};
|
|
308
293
|
|
|
309
|
-
export { CliOptions as C, EnvironmentReturn as E, File as F, GlobalContext as G, HookListener as H, ModuleCache as M, ResolvedConfig as R,
|
|
294
|
+
export { Awaitable as A, CliOptions as C, EnvironmentReturn as E, File as F, GlobalContext as G, HookListener as H, ModuleCache as M, Nullable as N, ResolvedConfig as R, SnapshotResult as S, TaskResultPack as T, UserOptions as U, VitestContext as V, TestFactory as a, SuiteCollector as b, TestFunction as c, SuiteHooks as d, RunMode as e, TaskState as f, ComputeMode as g, TaskBase as h, TaskResult as i, Suite as j, Test as k, Task as l, TestCollector as m, Reporter as n, SnapshotData as o, SnapshotUpdateState as p, SnapshotStateOptions as q, SnapshotMatchOptions as r, UncheckedSnapshot as s, SnapshotSummary as t, Arrayable as u, Environment as v };
|