vitest 0.25.7 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/LICENSE.md +29 -171
  2. package/dist/browser.d.ts +6 -3
  3. package/dist/browser.js +9 -10
  4. package/dist/{chunk-api-setup.5669c9a4.js → chunk-api-setup.08f3b356.js} +39 -42
  5. package/dist/{chunk-integrations-globals.57158eb5.js → chunk-integrations-globals.cab94a09.js} +5 -5
  6. package/dist/{chunk-magic-string.ffe2b171.js → chunk-magic-string.3a794426.js} +75 -39
  7. package/dist/{chunk-runtime-chain.dd978482.js → chunk-runtime-chain.e655f6cc.js} +5 -6
  8. package/dist/{chunk-runtime-error.616e92ca.js → chunk-runtime-error.dfbbf9be.js} +5 -5
  9. package/dist/{chunk-runtime-mocker.bf08ae09.js → chunk-runtime-mocker.35fabb8b.js} +65 -64
  10. package/dist/{chunk-runtime-rpc.42aebbb9.js → chunk-runtime-rpc.7959fc79.js} +1 -1
  11. package/dist/{chunk-runtime-setup.bd2deed4.js → chunk-runtime-setup.4c1b529e.js} +16 -29
  12. package/dist/{chunk-vite-node-externalize.5a3e0bdc.js → chunk-snapshot-manager.7d978f79.js} +41 -326
  13. package/dist/{chunk-typecheck-constants.ed987901.js → chunk-typecheck-constants.3f865d14.js} +5 -4
  14. package/dist/{chunk-runtime-test-state.0037e2e0.js → chunk-utils-import.ca62c9d7.js} +49 -18
  15. package/dist/{chunk-utils-source-map.29ff1088.js → chunk-utils-source-map.5bbb50cd.js} +6 -4
  16. package/dist/cli.js +13 -14
  17. package/dist/config.cjs +1 -1
  18. package/dist/config.d.ts +6 -3
  19. package/dist/config.js +1 -1
  20. package/dist/entry.js +9 -9
  21. package/dist/environments.d.ts +4 -1
  22. package/dist/{index-fde81ec3.d.ts → index-c3f83a58.d.ts} +20 -20
  23. package/dist/index.d.ts +28 -10
  24. package/dist/index.js +6 -6
  25. package/dist/loader.js +7 -6
  26. package/dist/node.d.ts +19 -19
  27. package/dist/node.js +15 -15
  28. package/dist/suite.js +4 -4
  29. package/dist/{types-c441ef31.d.ts → types-56bcd6c3.d.ts} +71 -328
  30. package/dist/vendor-index.783e7f3e.js +71 -0
  31. package/dist/vendor-index.96e022fd.js +211 -0
  32. package/dist/worker.js +12 -14
  33. package/package.json +15 -15
  34. package/dist/chunk-vite-node-source-map.2b1f492a.js +0 -445
  35. package/dist/chunk-vite-node-utils.0e4a6a88.js +0 -1385
  36. package/dist/vendor-source-map-support.1ce17397.js +0 -707
@@ -1,5 +1,8 @@
1
- import { ViteDevServer, TransformResult as TransformResult$1, UserConfig as UserConfig$1, CommonServerOptions, AliasOptions } from 'vite';
1
+ import { UserConfig as UserConfig$1, ViteDevServer, CommonServerOptions, AliasOptions } from 'vite';
2
2
  import { Task as Task$1, TaskResult as TaskResult$1, Bench, Options } from 'tinybench';
3
+ import { ViteNodeRunner } from 'vite-node/client';
4
+ import { ViteNodeServer } from 'vite-node/server';
5
+ import { RawSourceMap, ViteNodeResolveId, FetchFunction, ModuleCacheMap } from 'vite-node';
3
6
  import { Stats } from 'fs';
4
7
  import { MessagePort } from 'worker_threads';
5
8
 
@@ -156,276 +159,6 @@ interface FakeTimerInstallOpts {
156
159
  shouldClearNativeTimers?: boolean | undefined;
157
160
  }
158
161
 
159
- interface UpdatePayload {
160
- type: 'update'
161
- updates: Update[]
162
- }
163
-
164
- interface Update {
165
- type: 'js-update' | 'css-update'
166
- path: string
167
- acceptedPath: string
168
- timestamp: number
169
- /**
170
- * @experimental internal
171
- */
172
- explicitImportRequired?: boolean | undefined
173
- }
174
-
175
- interface PrunePayload {
176
- type: 'prune'
177
- paths: string[]
178
- }
179
-
180
- interface FullReloadPayload {
181
- type: 'full-reload'
182
- path?: string
183
- }
184
-
185
- interface ErrorPayload {
186
- type: 'error'
187
- err: {
188
- [name: string]: any
189
- message: string
190
- stack: string
191
- id?: string
192
- frame?: string
193
- plugin?: string
194
- pluginCode?: string
195
- loc?: {
196
- file?: string
197
- line: number
198
- column: number
199
- }
200
- }
201
- }
202
-
203
- interface CustomEventMap {
204
- 'vite:beforeUpdate': UpdatePayload
205
- 'vite:afterUpdate': UpdatePayload
206
- 'vite:beforePrune': PrunePayload
207
- 'vite:beforeFullReload': FullReloadPayload
208
- 'vite:error': ErrorPayload
209
- 'vite:invalidate': InvalidatePayload
210
- }
211
-
212
- interface InvalidatePayload {
213
- path: string
214
- message: string | undefined
215
- }
216
-
217
- type InferCustomEventPayload<T extends string> =
218
- T extends keyof CustomEventMap ? CustomEventMap[T] : any
219
-
220
- type ModuleNamespace = Record<string, any> & {
221
- [Symbol.toStringTag]: 'Module'
222
- }
223
-
224
- interface ViteHotContext {
225
- readonly data: any
226
-
227
- accept(): void
228
- accept(cb: (mod: ModuleNamespace | undefined) => void): void
229
- accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
230
- accept(
231
- deps: readonly string[],
232
- cb: (mods: Array<ModuleNamespace | undefined>) => void,
233
- ): void
234
-
235
- acceptExports(
236
- exportNames: string | readonly string[],
237
- cb?: (mod: ModuleNamespace | undefined) => void,
238
- ): void
239
-
240
- dispose(cb: (data: any) => void): void
241
- prune(cb: (data: any) => void): void
242
- invalidate(message?: string): void
243
-
244
- on<T extends string>(
245
- event: T,
246
- cb: (payload: InferCustomEventPayload<T>) => void,
247
- ): void
248
- send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
249
- }
250
- declare class ModuleCacheMap extends Map<string, ModuleCache$1> {
251
- normalizePath(fsPath: string): string;
252
- /**
253
- * Assign partial data to the map
254
- */
255
- update(fsPath: string, mod: Partial<ModuleCache$1>): this;
256
- set(fsPath: string, mod: ModuleCache$1): this;
257
- get(fsPath: string): ModuleCache$1;
258
- delete(fsPath: string): boolean;
259
- /**
260
- * Invalidate modules that dependent on the given modules, up to the main entry
261
- */
262
- invalidateDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
263
- /**
264
- * Invalidate dependency modules of the given modules, down to the bottom-level dependencies
265
- */
266
- invalidateSubDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
267
- /**
268
- * Return parsed source map based on inlined source map of the module
269
- */
270
- getSourceMap(id: string): RawSourceMap | null;
271
- }
272
- declare class ViteNodeRunner {
273
- options: ViteNodeRunnerOptions;
274
- root: string;
275
- debug: boolean;
276
- /**
277
- * Holds the cache of modules
278
- * Keys of the map are filepaths, or plain package names
279
- */
280
- moduleCache: ModuleCacheMap;
281
- constructor(options: ViteNodeRunnerOptions);
282
- executeFile(file: string): Promise<any>;
283
- executeId(id: string): Promise<any>;
284
- getSourceMap(id: string): RawSourceMap | null;
285
- /** @internal */
286
- cachedRequest(rawId: string, callstack: string[]): Promise<any>;
287
- /** @internal */
288
- directRequest(id: string, fsPath: string, _callstack: string[]): Promise<any>;
289
- prepareContext(context: Record<string, any>): Record<string, any>;
290
- shouldResolveId(dep: string): boolean;
291
- /**
292
- * Define if a module should be interop-ed
293
- * This function mostly for the ability to override by subclass
294
- */
295
- shouldInterop(path: string, mod: any): boolean;
296
- /**
297
- * Import a module and interop it
298
- */
299
- interopedImport(path: string): Promise<any>;
300
- hasNestedDefault(target: any): any;
301
- }
302
- interface DepsHandlingOptions {
303
- external?: (string | RegExp)[];
304
- inline?: (string | RegExp)[] | true;
305
- /**
306
- * Try to guess the CJS version of a package when it's invalid ESM
307
- * @default false
308
- */
309
- fallbackCJS?: boolean;
310
- }
311
- interface StartOfSourceMap {
312
- file?: string;
313
- sourceRoot?: string;
314
- }
315
- interface RawSourceMap extends StartOfSourceMap {
316
- version: string;
317
- sources: string[];
318
- names: string[];
319
- sourcesContent?: string[];
320
- mappings: string;
321
- }
322
- interface FetchResult {
323
- code?: string;
324
- externalize?: string;
325
- map?: RawSourceMap;
326
- }
327
- declare type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>;
328
- declare type FetchFunction = (id: string) => Promise<FetchResult>;
329
- declare type ResolveIdFunction$1 = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
330
- declare type CreateHotContextFunction = (runner: ViteNodeRunner, url: string) => HotContext;
331
- interface ModuleCache$1 {
332
- promise?: Promise<any>;
333
- exports?: any;
334
- evaluated?: boolean;
335
- code?: string;
336
- map?: RawSourceMap;
337
- /**
338
- * Module ids that imports this module
339
- */
340
- importers?: Set<string>;
341
- }
342
- interface ViteNodeRunnerOptions {
343
- root: string;
344
- fetchModule: FetchFunction;
345
- resolveId?: ResolveIdFunction$1;
346
- createHotContext?: CreateHotContextFunction;
347
- base?: string;
348
- moduleCache?: ModuleCacheMap;
349
- interopDefault?: boolean;
350
- requestStubs?: Record<string, any>;
351
- debug?: boolean;
352
- }
353
- interface ViteNodeResolveId {
354
- external?: boolean | 'absolute' | 'relative';
355
- id: string;
356
- meta?: Record<string, any> | null;
357
- moduleSideEffects?: boolean | 'no-treeshake' | null;
358
- syntheticNamedExports?: boolean | string | null;
359
- }
360
- interface ViteNodeServerOptions {
361
- /**
362
- * Inject inline sourcemap to modules
363
- * @default 'inline'
364
- */
365
- sourcemap?: 'inline' | boolean;
366
- /**
367
- * Deps handling
368
- */
369
- deps?: DepsHandlingOptions;
370
- /**
371
- * Transform method for modules
372
- */
373
- transformMode?: {
374
- ssr?: RegExp[];
375
- web?: RegExp[];
376
- };
377
- debug?: DebuggerOptions;
378
- }
379
- interface DebuggerOptions {
380
- /**
381
- * Dump the transformed module to filesystem
382
- * Passing a string will dump to the specified path
383
- */
384
- dumpModules?: boolean | string;
385
- /**
386
- * Read dumpped module from filesystem whenever exists.
387
- * Useful for debugging by modifying the dump result from the filesystem.
388
- */
389
- loadDumppedModules?: boolean;
390
- }
391
-
392
- declare class Debugger {
393
- options: DebuggerOptions;
394
- dumpDir: string | undefined;
395
- initPromise: Promise<void> | undefined;
396
- externalizeMap: Map<string, string>;
397
- constructor(root: string, options: DebuggerOptions);
398
- clearDump(): Promise<void>;
399
- encodeId(id: string): string;
400
- recordExternalize(id: string, path: string): Promise<void>;
401
- dumpFile(id: string, result: TransformResult$1 | null): Promise<void>;
402
- loadDump(id: string): Promise<TransformResult$1 | null>;
403
- writeInfo(): Promise<void>;
404
- }
405
-
406
- declare class ViteNodeServer {
407
- server: ViteDevServer;
408
- options: ViteNodeServerOptions;
409
- private fetchPromiseMap;
410
- private transformPromiseMap;
411
- fetchCache: Map<string, {
412
- duration?: number | undefined;
413
- timestamp: number;
414
- result: FetchResult;
415
- }>;
416
- externalizeCache: Map<string, Promise<string | false>>;
417
- debugger?: Debugger;
418
- constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
419
- shouldExternalize(id: string): Promise<string | false>;
420
- resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;
421
- getSourceMap(source: string): RawSourceMap | null;
422
- fetchModule(id: string): Promise<FetchResult>;
423
- transformRequest(id: string): Promise<TransformResult$1 | null | undefined>;
424
- getTransformMode(id: string): "web" | "ssr";
425
- private _fetchModule;
426
- private _transformRequest;
427
- }
428
-
429
162
  declare class SnapshotManager {
430
163
  options: SnapshotStateOptions;
431
164
  summary: SnapshotSummary;
@@ -470,7 +203,7 @@ interface ErrorsCache {
470
203
  files: File[];
471
204
  sourceErrors: TypeCheckError[];
472
205
  }
473
- declare type Callback<Args extends Array<any> = []> = (...args: Args) => Awaitable<void>;
206
+ type Callback<Args extends Array<any> = []> = (...args: Args) => Awaitable<void>;
474
207
  declare class Typechecker {
475
208
  protected ctx: Vitest;
476
209
  protected files: string[];
@@ -503,7 +236,7 @@ declare class Typechecker {
503
236
  getTestFiles(): File[];
504
237
  }
505
238
 
506
- declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
239
+ type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
507
240
  interface WorkerPool {
508
241
  runTests: RunWithFiles;
509
242
  close: () => Promise<void>;
@@ -596,7 +329,7 @@ interface CliOptions extends UserConfig {
596
329
  */
597
330
  declare function startVitest(mode: VitestRunMode, cliFilters: string[], options: CliOptions, viteOverrides?: UserConfig$1): Promise<Vitest | undefined>;
598
331
 
599
- declare type FileStatsCache = Pick<Stats, 'size'>;
332
+ type FileStatsCache = Pick<Stats, 'size'>;
600
333
  declare class FilesStatsCache {
601
334
  cache: Map<string, FileStatsCache>;
602
335
  getStats(fsPath: string): FileStatsCache | undefined;
@@ -676,7 +409,7 @@ declare class Vitest {
676
409
  onAfterSetServer(fn: OnServerRestartHandler): void;
677
410
  }
678
411
 
679
- declare type MockMap = Map<string, Record<string, string | null | (() => unknown)>>;
412
+ type MockMap = Map<string, Record<string, string | null | (() => unknown)>>;
680
413
 
681
414
  interface TestSequencer {
682
415
  /**
@@ -852,7 +585,7 @@ declare const BenchmarkReportsMap: {
852
585
  verbose: typeof VerboseReporter;
853
586
  json: typeof JsonReporter;
854
587
  };
855
- declare type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
588
+ type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
856
589
 
857
590
  declare const ReportersMap: {
858
591
  default: typeof DefaultReporter;
@@ -863,7 +596,7 @@ declare const ReportersMap: {
863
596
  'tap-flat': typeof TapFlatReporter;
864
597
  junit: typeof JUnitReporter;
865
598
  };
866
- declare type BuiltinReporters = keyof typeof ReportersMap;
599
+ type BuiltinReporters = keyof typeof ReportersMap;
867
600
 
868
601
  interface RollupError extends RollupLogProps {
869
602
  parserError?: Error;
@@ -1070,17 +803,17 @@ interface AcornNode {
1070
803
  type: string;
1071
804
  }
1072
805
 
1073
- declare type Awaitable<T> = T | PromiseLike<T>;
1074
- declare type Nullable<T> = T | null | undefined;
1075
- declare type Arrayable<T> = T | Array<T>;
1076
- declare type ArgumentsType$1<T> = T extends (...args: infer U) => any ? U : never;
1077
- declare type MergeInsertions<T> = T extends object ? {
806
+ type Awaitable<T> = T | PromiseLike<T>;
807
+ type Nullable<T> = T | null | undefined;
808
+ type Arrayable<T> = T | Array<T>;
809
+ type ArgumentsType$1<T> = T extends (...args: infer U) => any ? U : never;
810
+ type MergeInsertions<T> = T extends object ? {
1078
811
  [K in keyof T]: MergeInsertions<T[K]>;
1079
812
  } : T;
1080
- declare type DeepMerge<F, S> = MergeInsertions<{
813
+ type DeepMerge<F, S> = MergeInsertions<{
1081
814
  [K in keyof F | keyof S]: K extends keyof S & keyof F ? DeepMerge<F[K], S[K]> : K extends keyof S ? S[K] : K extends keyof F ? F[K] : never;
1082
815
  }>;
1083
- declare type MutableArray<T extends readonly any[]> = {
816
+ type MutableArray<T extends readonly any[]> = {
1084
817
  -readonly [k in keyof T]: T[k];
1085
818
  };
1086
819
  interface Constructable {
@@ -1135,7 +868,7 @@ interface ModuleGraphData {
1135
868
  externalized: string[];
1136
869
  inlined: string[];
1137
870
  }
1138
- declare type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
871
+ type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
1139
872
 
1140
873
  declare type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
1141
874
  declare type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
@@ -1150,7 +883,7 @@ declare type BirpcReturn<RemoteFunctions> = {
1150
883
  [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
1151
884
  };
1152
885
 
1153
- declare type ChainableFunction<T extends string, Args extends any[], R = any, E = {}> = {
886
+ type ChainableFunction<T extends string, Args extends any[], R = any, E = {}> = {
1154
887
  (...args: Args): R;
1155
888
  } & {
1156
889
  [x in T]: ChainableFunction<T, Args, R, E>;
@@ -1198,8 +931,8 @@ interface BenchmarkResult extends TaskResult$1 {
1198
931
  name: string;
1199
932
  rank: number;
1200
933
  }
1201
- declare type BenchFunction = (this: Bench) => Promise<void> | void;
1202
- declare type BenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', [
934
+ type BenchFunction = (this: Bench) => Promise<void> | void;
935
+ type BenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', [
1203
936
  name: string,
1204
937
  fn?: BenchFunction,
1205
938
  options?: Options
@@ -1208,8 +941,8 @@ declare type BenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', [
1208
941
  runIf(condition: any): BenchmarkAPI;
1209
942
  };
1210
943
 
1211
- declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
1212
- declare type TaskState = RunMode | 'pass' | 'fail';
944
+ type RunMode = 'run' | 'skip' | 'only' | 'todo';
945
+ type TaskState = RunMode | 'pass' | 'fail';
1213
946
  interface TaskBase {
1214
947
  id: string;
1215
948
  name: string;
@@ -1233,7 +966,7 @@ interface TaskResult {
1233
966
  benchmark?: BenchmarkResult;
1234
967
  retryCount?: number;
1235
968
  }
1236
- declare type TaskResultPack = [id: string, result: TaskResult | undefined];
969
+ type TaskResultPack = [id: string, result: TaskResult | undefined];
1237
970
  interface Suite extends TaskBase {
1238
971
  type: 'suite';
1239
972
  tasks: Task[];
@@ -1256,10 +989,10 @@ interface Test<ExtraContext = {}> extends TaskBase {
1256
989
  interface TypeCheck extends TaskBase {
1257
990
  type: 'typecheck';
1258
991
  }
1259
- declare type Task = Test | Suite | File | Benchmark | TypeCheck;
1260
- declare type DoneCallback = (error?: any) => void;
1261
- declare type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
1262
- declare type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
992
+ type Task = Test | Suite | File | Benchmark | TypeCheck;
993
+ type DoneCallback = (error?: any) => void;
994
+ type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
995
+ type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
1263
996
  1: [T[0]];
1264
997
  2: [T[0], T[1]];
1265
998
  3: [T[0], T[1], T[2]];
@@ -1283,7 +1016,7 @@ interface TestEachFunction {
1283
1016
  <T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>, options?: number | TestOptions) => void;
1284
1017
  (...args: [TemplateStringsArray, ...any]): (name: string, fn: (...args: any[]) => Awaitable<void>, options?: number | TestOptions) => void;
1285
1018
  }
1286
- declare type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
1019
+ type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
1287
1020
  name: string,
1288
1021
  fn?: TestFunction<ExtraContext>,
1289
1022
  options?: number | TestOptions
@@ -1304,12 +1037,12 @@ interface TestOptions {
1304
1037
  */
1305
1038
  retry?: number;
1306
1039
  }
1307
- declare type TestAPI<ExtraContext = {}> = ChainableTestAPI<ExtraContext> & {
1040
+ type TestAPI<ExtraContext = {}> = ChainableTestAPI<ExtraContext> & {
1308
1041
  each: TestEachFunction;
1309
1042
  skipIf(condition: any): ChainableTestAPI<ExtraContext>;
1310
1043
  runIf(condition: any): ChainableTestAPI<ExtraContext>;
1311
1044
  };
1312
- declare type ChainableSuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'shuffle', [
1045
+ type ChainableSuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'shuffle', [
1313
1046
  name: string,
1314
1047
  factory?: SuiteFactory<ExtraContext>,
1315
1048
  options?: number | TestOptions
@@ -1317,13 +1050,13 @@ declare type ChainableSuiteAPI<ExtraContext = {}> = ChainableFunction<'concurren
1317
1050
  each: TestEachFunction;
1318
1051
  <T extends ExtraContext>(name: string, factory?: SuiteFactory<T>): SuiteCollector<T>;
1319
1052
  }>;
1320
- declare type SuiteAPI<ExtraContext = {}> = ChainableSuiteAPI<ExtraContext> & {
1053
+ type SuiteAPI<ExtraContext = {}> = ChainableSuiteAPI<ExtraContext> & {
1321
1054
  each: SuiteEachFunction;
1322
1055
  skipIf(condition: any): ChainableSuiteAPI<ExtraContext>;
1323
1056
  runIf(condition: any): ChainableSuiteAPI<ExtraContext>;
1324
1057
  };
1325
- declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
1326
- declare type HookCleanupCallback = (() => Awaitable<unknown>) | void;
1058
+ type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
1059
+ type HookCleanupCallback = (() => Awaitable<unknown>) | void;
1327
1060
  interface SuiteHooks<ExtraContext = {}> {
1328
1061
  beforeAll: HookListener<[Suite | File], HookCleanupCallback>[];
1329
1062
  afterAll: HookListener<[Suite | File]>[];
@@ -1341,7 +1074,7 @@ interface SuiteCollector<ExtraContext = {}> {
1341
1074
  clear: () => void;
1342
1075
  on: <T extends keyof SuiteHooks<ExtraContext>>(name: T, ...fn: SuiteHooks<ExtraContext>[T]) => void;
1343
1076
  }
1344
- declare type SuiteFactory<ExtraContext = {}> = (test: (name: string, fn: TestFunction<ExtraContext>) => void) => Awaitable<void>;
1077
+ type SuiteFactory<ExtraContext = {}> = (test: (name: string, fn: TestFunction<ExtraContext>) => void) => Awaitable<void>;
1345
1078
  interface RuntimeContext {
1346
1079
  tasks: (SuiteCollector | Test)[];
1347
1080
  currentSuite: SuiteCollector | null;
@@ -1360,10 +1093,10 @@ interface TestContext {
1360
1093
  */
1361
1094
  onTestFailed: (fn: OnTestFailedHandler) => void;
1362
1095
  }
1363
- declare type OnTestFailedHandler = (result: TaskResult) => Awaitable<void>;
1096
+ type OnTestFailedHandler = (result: TaskResult) => Awaitable<void>;
1364
1097
 
1365
- declare type SnapshotData = Record<string, string>;
1366
- declare type SnapshotUpdateState = 'all' | 'new' | 'none';
1098
+ type SnapshotData = Record<string, string>;
1099
+ type SnapshotUpdateState = 'all' | 'new' | 'none';
1367
1100
  interface SnapshotStateOptions {
1368
1101
  updateSnapshot: SnapshotUpdateState;
1369
1102
  expand?: boolean;
@@ -1416,7 +1149,7 @@ interface WorkerContext {
1416
1149
  files: string[];
1417
1150
  invalidates?: string[];
1418
1151
  }
1419
- declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
1152
+ type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
1420
1153
  interface AfterSuiteRunMeta {
1421
1154
  coverage?: unknown;
1422
1155
  }
@@ -1466,15 +1199,15 @@ interface CoverageProviderModule {
1466
1199
  */
1467
1200
  takeCoverage?(): unknown | Promise<unknown>;
1468
1201
  }
1469
- declare type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
1470
- declare type CoverageOptions = BaseCoverageOptions & {
1202
+ type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
1203
+ type CoverageOptions = BaseCoverageOptions & {
1471
1204
  provider?: null | CoverageProviderModule;
1472
1205
  } | CoverageC8Options & {
1473
1206
  provider?: 'c8';
1474
1207
  } | CoverageIstanbulOptions & {
1475
1208
  provider?: 'istanbul';
1476
1209
  };
1477
- declare type ResolvedCoverageOptions = {
1210
+ type ResolvedCoverageOptions = {
1478
1211
  tempDirectory: string;
1479
1212
  } & Required<CoverageOptions>;
1480
1213
  interface BaseCoverageOptions {
@@ -1706,11 +1439,11 @@ interface Reporter {
1706
1439
  onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
1707
1440
  }
1708
1441
 
1709
- declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
1710
- declare type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
1711
- declare type CSSModuleScopeStrategy = 'stable' | 'scoped' | 'non-scoped';
1712
- declare type SequenceHooks = 'stack' | 'list' | 'parallel';
1713
- declare type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
1442
+ type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
1443
+ type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
1444
+ type CSSModuleScopeStrategy = 'stable' | 'scoped' | 'non-scoped';
1445
+ type SequenceHooks = 'stack' | 'list' | 'parallel';
1446
+ type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
1714
1447
 
1715
1448
  interface EnvironmentOptions {
1716
1449
  /**
@@ -1719,7 +1452,7 @@ interface EnvironmentOptions {
1719
1452
  jsdom?: JSDOMOptions;
1720
1453
  [x: string]: unknown;
1721
1454
  }
1722
- declare type VitestRunMode = 'test' | 'benchmark' | 'typecheck';
1455
+ type VitestRunMode = 'test' | 'benchmark' | 'typecheck';
1723
1456
  interface InlineConfig {
1724
1457
  /**
1725
1458
  * Benchmark options.
@@ -1833,7 +1566,7 @@ interface InlineConfig {
1833
1566
  * Custom reporter for output. Can contain one or more built-in report names, reporter instances,
1834
1567
  * and/or paths to custom reporters
1835
1568
  */
1836
- reporters?: Arrayable<BuiltinReporters | Reporter | Omit<string, BuiltinReporters>>;
1569
+ reporters?: Arrayable<BuiltinReporters | 'html' | Reporter | Omit<string, BuiltinReporters>>;
1837
1570
  /**
1838
1571
  * diff output length
1839
1572
  */
@@ -1938,6 +1671,16 @@ interface InlineConfig {
1938
1671
  * @default false
1939
1672
  */
1940
1673
  restoreMocks?: boolean;
1674
+ /**
1675
+ * Will restore all global stubs to their original values before each test
1676
+ * @default false
1677
+ */
1678
+ unstubGlobals?: boolean;
1679
+ /**
1680
+ * Will restore all env stubs to their original values before each test
1681
+ * @default false
1682
+ */
1683
+ unstubEnvs?: boolean;
1941
1684
  /**
1942
1685
  * Serve API options.
1943
1686
  *
@@ -2190,13 +1933,13 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
2190
1933
  };
2191
1934
  typecheck: TypecheckConfig;
2192
1935
  }
2193
- declare type RuntimeConfig = Pick<UserConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency'> & {
1936
+ type RuntimeConfig = Pick<UserConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency'> & {
2194
1937
  sequence?: {
2195
1938
  hooks?: SequenceHooks;
2196
1939
  };
2197
1940
  };
2198
1941
 
2199
- declare type VitestInlineConfig = InlineConfig;
1942
+ type VitestInlineConfig = InlineConfig;
2200
1943
  declare module 'vite' {
2201
1944
  interface UserConfig {
2202
1945
  /**
@@ -2206,7 +1949,7 @@ declare module 'vite' {
2206
1949
  }
2207
1950
  }
2208
1951
 
2209
- declare type Formatter = (input: string | number | null | undefined) => string;
1952
+ type Formatter = (input: string | number | null | undefined) => string;
2210
1953
 
2211
1954
  interface MatcherHintOptions {
2212
1955
  comment?: string;
@@ -2322,7 +2065,7 @@ declare class SnapshotState {
2322
2065
  pack(): Promise<SnapshotResult>;
2323
2066
  }
2324
2067
 
2325
- declare type Tester = (a: any, b: any) => boolean | undefined;
2068
+ type Tester = (a: any, b: any) => boolean | undefined;
2326
2069
  interface MatcherState {
2327
2070
  assertionCalls: number;
2328
2071
  currentTestName?: string;
@@ -2351,14 +2094,14 @@ interface SyncExpectationResult {
2351
2094
  actual?: any;
2352
2095
  expected?: any;
2353
2096
  }
2354
- declare type AsyncExpectationResult = Promise<SyncExpectationResult>;
2355
- declare type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
2097
+ type AsyncExpectationResult = Promise<SyncExpectationResult>;
2098
+ type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
2356
2099
  interface RawMatcherFn<T extends MatcherState = MatcherState> {
2357
2100
  (this: T, received: any, expected: any, options?: any): ExpectationResult;
2358
2101
  }
2359
- declare type MatchersObject<T extends MatcherState = MatcherState> = Record<string, RawMatcherFn<T>>;
2102
+ type MatchersObject<T extends MatcherState = MatcherState> = Record<string, RawMatcherFn<T>>;
2360
2103
 
2361
- declare type Promisify<O> = {
2104
+ type Promisify<O> = {
2362
2105
  [K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify<O[K]> : (...args: A) => Promise<R> : O[K];
2363
2106
  };
2364
2107
  declare global {
@@ -2457,7 +2200,7 @@ declare global {
2457
2200
  }
2458
2201
  }
2459
2202
 
2460
- declare type RawErrsMap = Map<string, TscErrorInfo[]>;
2203
+ type RawErrsMap = Map<string, TscErrorInfo[]>;
2461
2204
  interface TscErrorInfo {
2462
2205
  filePath: string;
2463
2206
  errCode: number;
@@ -2470,17 +2213,17 @@ interface CollectLineNumbers {
2470
2213
  next: number;
2471
2214
  prev?: number;
2472
2215
  }
2473
- declare type CollectLines = {
2216
+ type CollectLines = {
2474
2217
  [key in keyof CollectLineNumbers]: string;
2475
2218
  };
2476
2219
  interface RootAndTarget {
2477
2220
  root: string;
2478
2221
  targetAbsPath: string;
2479
2222
  }
2480
- declare type Context = RootAndTarget & {
2223
+ type Context = RootAndTarget & {
2481
2224
  rawErrsMap: RawErrsMap;
2482
2225
  openedDirs: Set<string>;
2483
2226
  lastActivePath?: string;
2484
2227
  };
2485
2228
 
2486
- export { WorkerContext as $, ApiConfig as A, BuiltinEnvironment as B, CollectLineNumbers as C, DoneCallback as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, SuiteFactory as G, HookListener as H, InlineConfig as I, JSDOMOptions as J, RuntimeContext as K, TestContext as L, ModuleGraphData as M, Vitest as N, OnTestFailedHandler as O, SnapshotData as P, SnapshotUpdateState as Q, RuntimeConfig as R, SequenceHooks as S, TaskResultPack as T, UserConfig as U, VitestEnvironment as V, SnapshotStateOptions as W, SnapshotMatchOptions as X, SnapshotResult as Y, UncheckedSnapshot as Z, SnapshotSummary as _, File as a, ResolveIdFunction as a0, AfterSuiteRunMeta as a1, WorkerRPC as a2, WorkerGlobalState as a3, Awaitable as a4, Nullable as a5, Arrayable as a6, ArgumentsType$1 as a7, MergeInsertions as a8, DeepMerge as a9, ViteNodeRunner as aA, TestSequencer as aB, startVitest as aC, TestSequencerConstructor as aD, MutableArray as aa, Constructable as ab, ModuleCache as ac, EnvironmentReturn as ad, Environment as ae, UserConsoleLog as af, Position as ag, ParsedStack as ah, ErrorWithDiff as ai, OnServerRestartHandler as aj, CoverageProvider as ak, CoverageProviderModule as al, CoverageReporter as am, CoverageOptions as an, ResolvedCoverageOptions as ao, BaseCoverageOptions as ap, CoverageIstanbulOptions as aq, CoverageC8Options as ar, BenchmarkUserOptions as as, Benchmark as at, BenchmarkResult as au, BenchFunction as av, BenchmarkAPI as aw, ModuleCacheMap as ax, ViteNodeRunnerOptions as ay, MockMap as az, ResolvedConfig as b, Reporter as c, RawErrsMap as d, TscErrorInfo as e, CollectLines as f, RootAndTarget as g, Context as h, CSSModuleScopeStrategy as i, VitestRunMode as j, TypecheckConfig as k, RunMode as l, TaskState as m, TaskBase as n, TaskResult as o, Suite as p, Test as q, TypeCheck as r, Task as s, TestFunction as t, TestOptions as u, TestAPI as v, SuiteAPI as w, HookCleanupCallback as x, SuiteHooks as y, SuiteCollector as z };
2229
+ export { WorkerContext as $, ApiConfig as A, BuiltinEnvironment as B, CollectLineNumbers as C, DoneCallback as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, SuiteFactory as G, HookListener as H, InlineConfig as I, JSDOMOptions as J, RuntimeContext as K, TestContext as L, ModuleGraphData as M, Vitest as N, OnTestFailedHandler as O, SnapshotData as P, SnapshotUpdateState as Q, RuntimeConfig as R, SequenceHooks as S, TaskResultPack as T, UserConfig as U, VitestEnvironment as V, SnapshotStateOptions as W, SnapshotMatchOptions as X, SnapshotResult as Y, UncheckedSnapshot as Z, SnapshotSummary as _, File as a, ResolveIdFunction as a0, AfterSuiteRunMeta as a1, WorkerRPC as a2, WorkerGlobalState as a3, Awaitable as a4, Nullable as a5, Arrayable as a6, ArgumentsType$1 as a7, MergeInsertions as a8, DeepMerge as a9, TestSequencerConstructor as aA, MutableArray as aa, Constructable as ab, ModuleCache as ac, EnvironmentReturn as ad, Environment as ae, UserConsoleLog as af, Position as ag, ParsedStack as ah, ErrorWithDiff as ai, OnServerRestartHandler as aj, CoverageProvider as ak, CoverageProviderModule as al, CoverageReporter as am, CoverageOptions as an, ResolvedCoverageOptions as ao, BaseCoverageOptions as ap, CoverageIstanbulOptions as aq, CoverageC8Options as ar, BenchmarkUserOptions as as, Benchmark as at, BenchmarkResult as au, BenchFunction as av, BenchmarkAPI as aw, MockMap as ax, TestSequencer as ay, startVitest as az, ResolvedConfig as b, Reporter as c, RawErrsMap as d, TscErrorInfo as e, CollectLines as f, RootAndTarget as g, Context as h, CSSModuleScopeStrategy as i, VitestRunMode as j, TypecheckConfig as k, RunMode as l, TaskState as m, TaskBase as n, TaskResult as o, Suite as p, Test as q, TypeCheck as r, Task as s, TestFunction as t, TestOptions as u, TestAPI as v, SuiteAPI as w, HookCleanupCallback as x, SuiteHooks as y, SuiteCollector as z };