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.
@@ -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
- interface UserOptions {
25
- /**
26
- * Include globs for test files
27
- *
28
- * @default ['**\/*.test.ts']
29
- */
30
- includes?: string[];
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 CliOptions extends UserOptions {
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 ResolvedConfig extends Omit<Required<CliOptions>, 'config' | 'filters'> {
127
- config?: string;
128
- filters?: string[];
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
- interface ModuleCache {
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
- interface EnvironmentReturn {
272
- teardown: (global: any) => Awaitable<void>;
273
- }
274
- interface Environment {
275
- name: string;
276
- setup(global: any): Awaitable<EnvironmentReturn>;
277
- }
278
- interface WorkerContext {
279
- port: MessagePort;
280
- config: ResolvedConfig;
281
- files: string[];
282
- invalidates?: string[];
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 VitestContext {
285
- config: ResolvedConfig;
286
- server: ViteDevServer;
287
- state: StateManager;
288
- snapshot: SnapshotManager;
289
- reporter: Reporter;
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 RpcMap {
292
- workerReady: [[], void];
293
- fetch: [[id: string], TransformResult | null | undefined];
294
- onCollected: [[files: File[]], void];
295
- onFinished: [[], void];
296
- onTaskUpdate: [[pack: TaskResultPack], void];
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, SuiteCollector as S, TestFactory as T, UserOptions as U, VitestContext as V, WorkerContext as W, TestFunction as a, SuiteHooks as b, RunMode as c, TaskState as d, ComputeMode as e, TaskBase as f, TaskResult as g, TaskResultPack as h, Suite as i, Test as j, Task as k, TestCollector as l, Reporter as m, SnapshotData as n, SnapshotUpdateState as o, SnapshotStateOptions as p, SnapshotMatchOptions as q, SnapshotResult as r, UncheckedSnapshot as s, SnapshotSummary as t, Environment as u, RpcMap as v, RpcCall as w, RpcSend as x, RpcPayload as y };
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 };
@@ -1,6 +1,4 @@
1
- import { R as ResolvedConfig } from '../types-c0d293d3';
2
- import 'worker_threads';
3
- import '@antfu/utils';
1
+ import { R as ResolvedConfig } from '../options-63a726fa';
4
2
  import 'vite';
5
3
  import 'pretty-format';
6
4