vitest 0.25.8 → 0.26.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.
Files changed (45) hide show
  1. package/LICENSE.md +0 -142
  2. package/browser.d.ts +1 -0
  3. package/dist/browser.d.ts +8 -5
  4. package/dist/browser.js +17 -16
  5. package/dist/{chunk-api-setup.dc71e384.js → chunk-api-setup.adeab271.js} +45 -46
  6. package/dist/{chunk-env-node.67948209.js → chunk-env-node.b3664da2.js} +1 -1
  7. package/dist/{chunk-install-pkg.579a5a27.js → chunk-install-pkg.6dd2bae6.js} +19 -19
  8. package/dist/chunk-integrations-globals.96914902.js +27 -0
  9. package/dist/{chunk-node-git.5a1b1656.js → chunk-node-git.a90c0582.js} +10 -6
  10. package/dist/{chunk-runtime-chain.f86e5250.js → chunk-runtime-chain.4cd984be.js} +8 -8
  11. package/dist/{chunk-runtime-error.616e92ca.js → chunk-runtime-error.f5c8aaf2.js} +10 -8
  12. package/dist/{chunk-runtime-mocker.99b910d0.js → chunk-runtime-mocker.3fa602ba.js} +73 -65
  13. package/dist/{chunk-runtime-rpc.42aebbb9.js → chunk-runtime-rpc.54d72169.js} +2 -2
  14. package/dist/{chunk-runtime-setup.5398e2c4.js → chunk-runtime-setup.9cdedce6.js} +21 -34
  15. package/dist/{chunk-vite-node-externalize.b9495318.js → chunk-snapshot-manager.e54d78b8.js} +82 -358
  16. package/dist/{chunk-typecheck-constants.ed987901.js → chunk-typecheck-constants.06e1fe5b.js} +8 -7
  17. package/dist/{chunk-utils-env.03f840f2.js → chunk-utils-env.3fdc1793.js} +8 -8
  18. package/dist/{chunk-runtime-test-state.3f86f48f.js → chunk-utils-import.afe2ffde.js} +50 -19
  19. package/dist/{chunk-utils-source-map.29ff1088.js → chunk-utils-source-map.59ba6b0a.js} +6 -4
  20. package/dist/{chunk-utils-timers.793fd179.js → chunk-utils-timers.715da787.js} +31 -15
  21. package/dist/cli-wrapper.js +10 -5
  22. package/dist/cli.js +30 -25
  23. package/dist/config.d.ts +6 -3
  24. package/dist/entry.js +18 -16
  25. package/dist/environments.d.ts +6 -3
  26. package/dist/environments.js +2 -2
  27. package/dist/{index-5aad25c1.d.ts → index-1e9f7f83.d.ts} +1 -1
  28. package/dist/index.d.ts +30 -12
  29. package/dist/index.js +12 -10
  30. package/dist/loader.js +12 -7
  31. package/dist/node.d.ts +21 -20
  32. package/dist/node.js +33 -25
  33. package/dist/suite.js +10 -8
  34. package/dist/{types-71ccd11d.d.ts → types-c41bae41.d.ts} +39 -279
  35. package/dist/vendor-index.2e96c50b.js +215 -0
  36. package/dist/vendor-index.783e7f3e.js +71 -0
  37. package/dist/{vendor-index.e1d4cf84.js → vendor-index.7a2cebfe.js} +16 -16
  38. package/dist/{vendor-index.737c3cff.js → vendor-index.b2fdde54.js} +9 -8
  39. package/dist/worker.js +21 -18
  40. package/environments.d.ts +1 -0
  41. package/package.json +4 -4
  42. package/dist/chunk-integrations-globals.4d261bb8.js +0 -25
  43. package/dist/chunk-vite-node-source-map.b4ea5792.js +0 -446
  44. package/dist/chunk-vite-node-utils.0e4a6a88.js +0 -1385
  45. package/dist/vendor-source-map-support.1ce17397.js +0 -707
package/dist/index.js CHANGED
@@ -1,21 +1,23 @@
1
- export { b as bench, c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.f86e5250.js';
2
- import { e as dist } from './chunk-runtime-test-state.3f86f48f.js';
3
- export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, k as getRunningMode, h as isFirstRun, l as isWatchMode, o as onTestFailed, g as runOnce, v as vi, j as vitest, w as withCallback } from './chunk-runtime-test-state.3f86f48f.js';
1
+ export { b as bench, c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.4cd984be.js';
2
+ import { e as dist } from './chunk-utils-import.afe2ffde.js';
3
+ export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, k as getRunningMode, h as isFirstRun, l as isWatchMode, o as onTestFailed, g as runOnce, v as vi, j as vitest, w as withCallback } from './chunk-utils-import.afe2ffde.js';
4
4
  import * as chai from 'chai';
5
5
  export { chai };
6
6
  export { assert, should } from 'chai';
7
7
  import 'util';
8
- import './chunk-typecheck-constants.ed987901.js';
9
- import 'path';
10
- import './chunk-utils-env.03f840f2.js';
8
+ import './chunk-typecheck-constants.06e1fe5b.js';
9
+ import 'node:path';
10
+ import './chunk-utils-env.3fdc1793.js';
11
11
  import 'tty';
12
- import 'url';
12
+ import 'node:url';
13
+ import 'path';
13
14
  import 'local-pkg';
14
15
  import './vendor-_commonjsHelpers.addc3445.js';
15
- import './chunk-runtime-rpc.42aebbb9.js';
16
- import './chunk-utils-timers.793fd179.js';
16
+ import './chunk-runtime-rpc.54d72169.js';
17
+ import './chunk-utils-timers.715da787.js';
18
+ import 'node:fs';
19
+ import './chunk-utils-source-map.59ba6b0a.js';
17
20
  import 'fs';
18
- import './chunk-utils-source-map.29ff1088.js';
19
21
  import './spy.js';
20
22
  import 'tinyspy';
21
23
 
package/dist/loader.js CHANGED
@@ -1,15 +1,20 @@
1
- import { pathToFileURL } from 'url';
2
- import { readFile } from 'fs/promises';
3
- import { i as isNodeBuiltin, n as normalizeModuleId, h as hasCJSSyntax } from './chunk-vite-node-utils.0e4a6a88.js';
4
- import { g as getWorkerState } from './chunk-typecheck-constants.ed987901.js';
1
+ import { pathToFileURL } from 'node:url';
2
+ import { readFile } from 'node:fs/promises';
3
+ import { i as isNodeBuiltin, h as hasCJSSyntax } from './vendor-index.2e96c50b.js';
4
+ import { normalizeModuleId } from 'vite-node/utils';
5
+ import { g as getWorkerState } from './chunk-typecheck-constants.06e1fe5b.js';
6
+ import 'acorn';
7
+ import 'node:module';
8
+ import 'node:fs';
9
+ import 'url';
5
10
  import 'fs';
6
- import './chunk-utils-env.03f840f2.js';
7
- import 'tty';
8
11
  import 'path';
9
- import 'acorn';
10
12
  import 'module';
11
13
  import 'assert';
12
14
  import 'util';
15
+ import 'node:path';
16
+ import './chunk-utils-env.3fdc1793.js';
17
+ import 'tty';
13
18
  import 'local-pkg';
14
19
 
15
20
  var ModuleFormat = /* @__PURE__ */ ((ModuleFormat2) => {
package/dist/node.d.ts CHANGED
@@ -1,30 +1,29 @@
1
- import { j as VitestRunMode, U as UserConfig, N as Vitest, ax as ModuleCacheMap, ay as ViteNodeRunnerOptions, az as MockMap, aA as ViteNodeRunner, aB as TestSequencer } from './types-71ccd11d.js';
2
- export { aB as TestSequencer, aD as TestSequencerConstructor, N as Vitest, aC as startVitest } from './types-71ccd11d.js';
1
+ import { j as VitestRunMode, U as UserConfig, N as Vitest, ax as MockMap, ay as TestSequencer } from './types-c41bae41.js';
2
+ export { ay as TestSequencer, aA as TestSequencerConstructor, N as Vitest, az as startVitest } from './types-c41bae41.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
+ import { ViteNodeRunner } from 'vite-node/client';
5
+ import { ViteNodeRunnerOptions } from 'vite-node';
4
6
  import 'tinybench';
5
- import 'fs';
6
- import 'worker_threads';
7
+ import 'vite-node/server';
8
+ import 'node:fs';
9
+ import 'node:worker_threads';
7
10
 
8
11
  declare function createVitest(mode: VitestRunMode, options: UserConfig, viteOverrides?: UserConfig$1): Promise<Vitest>;
9
12
 
10
13
  declare function VitestPlugin(options?: UserConfig, ctx?: Vitest): Promise<Plugin[]>;
11
14
 
12
15
  type Key = string | symbol;
13
- interface ViteRunnerRequest {
14
- (dep: string): any;
15
- callstack: string[];
16
- }
17
16
  declare class VitestMocker {
18
- options: ExecuteOptions;
19
- private moduleCache;
20
- private request;
17
+ runner: VitestRunner;
21
18
  private static pendingIds;
19
+ private static spyModulePath;
22
20
  private static spyModule?;
23
21
  private resolveCache;
24
- constructor(options: ExecuteOptions, moduleCache: ModuleCacheMap, request: ViteRunnerRequest);
22
+ constructor(runner: VitestRunner);
25
23
  private get root();
26
24
  private get base();
27
25
  private get mockMap();
26
+ private get moduleCache();
28
27
  getSuiteFilepath(): string;
29
28
  getMocks(): {
30
29
  [x: string]: string | (() => unknown) | null;
@@ -32,18 +31,17 @@ declare class VitestMocker {
32
31
  private resolvePath;
33
32
  private resolveMocks;
34
33
  private callFunctionMock;
35
- private getMockPath;
34
+ getMockPath(dep: string): string;
36
35
  getDependencyMock(id: string): string | (() => unknown) | null;
37
36
  normalizePath(path: string): string;
38
- getFsPath(path: string, external: string | null): string;
39
37
  resolveMockPath(mockPath: string, external: string | null): string | null;
40
38
  mockObject(object: Record<Key, any>, mockExports?: Record<Key, any>): Record<Key, any>;
41
39
  unmockPath(path: string): void;
42
40
  mockPath(originalId: string, path: string, external: string | null, factory?: () => any): void;
43
- importActual<T>(id: string, importer: string): Promise<T>;
44
- importMock(id: string, importer: string): Promise<any>;
45
- private ensureSpy;
46
- requestWithMock(dep: string): Promise<any>;
41
+ importActual<T>(rawId: string, importee: string): Promise<T>;
42
+ importMock(rawId: string, importee: string): Promise<any>;
43
+ initializeSpyModule(): Promise<void>;
44
+ requestWithMock(url: string, callstack: string[]): Promise<any>;
47
45
  queueMock(id: string, importer: string, factory?: () => unknown): void;
48
46
  queueUnmock(id: string, importer: string): void;
49
47
  }
@@ -53,12 +51,15 @@ interface ExecuteOptions extends ViteNodeRunnerOptions {
53
51
  }
54
52
  declare class VitestRunner extends ViteNodeRunner {
55
53
  options: ExecuteOptions;
54
+ mocker: VitestMocker;
56
55
  constructor(options: ExecuteOptions);
56
+ shouldResolveId(id: string, _importee?: string | undefined): boolean;
57
+ resolveUrl(id: string, importee?: string): Promise<[url: string, fsPath: string]>;
58
+ dependencyRequest(id: string, fsPath: string, callstack: string[]): Promise<any>;
57
59
  prepareContext(context: Record<string, any>): Record<string, any> & {
58
- __vite_ssr_import__: (dep: string) => Promise<any>;
59
- __vite_ssr_dynamic_import__: (dep: string) => Promise<any>;
60
60
  __vitest_mocker__: VitestMocker;
61
61
  };
62
+ shouldInterop(path: string, mod: any): boolean;
62
63
  }
63
64
 
64
65
  declare class BaseSequencer implements TestSequencer {
package/dist/node.js CHANGED
@@ -1,45 +1,53 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.b9495318.js';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.99b910d0.js';
3
- import './chunk-utils-env.03f840f2.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-snapshot-manager.e54d78b8.js';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.3fa602ba.js';
3
+ import './chunk-utils-env.3fdc1793.js';
4
4
  import 'tty';
5
- import 'url';
5
+ import 'node:url';
6
6
  import 'path';
7
7
  import './chunk-integrations-coverage.befed097.js';
8
8
  import 'local-pkg';
9
- import './chunk-env-node.67948209.js';
10
- import 'console';
11
- import './chunk-typecheck-constants.ed987901.js';
9
+ import './chunk-env-node.b3664da2.js';
10
+ import 'node:console';
11
+ import './chunk-typecheck-constants.06e1fe5b.js';
12
+ import 'node:path';
12
13
  import 'vite';
13
- import 'process';
14
- import 'fs';
14
+ import 'node:process';
15
+ import 'node:fs';
15
16
  import 'os';
16
17
  import 'util';
17
18
  import 'stream';
18
19
  import 'events';
20
+ import 'fs';
19
21
  import './vendor-_commonjsHelpers.addc3445.js';
20
- import './chunk-vite-node-source-map.b4ea5792.js';
21
- import 'module';
22
- import 'vm';
23
- import './chunk-vite-node-utils.0e4a6a88.js';
24
- import 'acorn';
22
+ import 'vite-node/client';
23
+ import 'vite-node/server';
24
+ import 'node:fs/promises';
25
+ import './vendor-index.b2fdde54.js';
26
+ import 'node:buffer';
27
+ import 'node:child_process';
28
+ import './vendor-index.7a2cebfe.js';
29
+ import 'child_process';
25
30
  import 'assert';
26
- import 'debug';
27
- import './vendor-source-map-support.1ce17397.js';
28
- import 'source-map';
29
- import 'perf_hooks';
30
- import 'fs/promises';
31
- import './vendor-index.737c3cff.js';
32
31
  import 'buffer';
33
- import 'child_process';
34
- import './vendor-index.e1d4cf84.js';
32
+ import 'node:os';
33
+ import 'source-map';
34
+ import 'module';
35
+ import 'acorn';
35
36
  import 'acorn-walk';
36
- import 'worker_threads';
37
+ import 'node:worker_threads';
37
38
  import 'tinypool';
38
- import './chunk-utils-timers.793fd179.js';
39
- import './chunk-utils-source-map.29ff1088.js';
39
+ import './vendor-index.783e7f3e.js';
40
+ import 'perf_hooks';
41
+ import './chunk-utils-timers.715da787.js';
42
+ import './chunk-utils-source-map.59ba6b0a.js';
40
43
  import 'crypto';
44
+ import 'vite-node/utils';
41
45
  import './vendor-index.9c919048.js';
46
+ import 'node:crypto';
42
47
  import './chunk-magic-string.3a794426.js';
43
48
  import 'strip-literal';
44
49
  import 'readline';
45
50
  import './vendor-index.9f20a9be.js';
51
+ import './vendor-index.2e96c50b.js';
52
+ import 'node:module';
53
+ import 'url';
package/dist/suite.js CHANGED
@@ -1,16 +1,18 @@
1
1
  import 'util';
2
2
  import 'chai';
3
- import './chunk-typecheck-constants.ed987901.js';
4
- export { b as bench, f as clearCollectorContext, q as createSuiteHooks, h as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.f86e5250.js';
5
- import 'path';
6
- import './chunk-utils-env.03f840f2.js';
3
+ import './chunk-typecheck-constants.06e1fe5b.js';
4
+ export { b as bench, f as clearCollectorContext, q as createSuiteHooks, h as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.4cd984be.js';
5
+ import 'node:path';
6
+ import './chunk-utils-env.3fdc1793.js';
7
7
  import 'tty';
8
- import 'url';
8
+ import 'node:url';
9
+ import 'path';
9
10
  import 'local-pkg';
10
11
  import './vendor-_commonjsHelpers.addc3445.js';
11
- import './chunk-runtime-rpc.42aebbb9.js';
12
- import './chunk-utils-timers.793fd179.js';
12
+ import './chunk-runtime-rpc.54d72169.js';
13
+ import './chunk-utils-timers.715da787.js';
14
+ import 'node:fs';
15
+ import './chunk-utils-source-map.59ba6b0a.js';
13
16
  import 'fs';
14
- import './chunk-utils-source-map.29ff1088.js';
15
17
  import './spy.js';
16
18
  import 'tinyspy';
@@ -1,7 +1,10 @@
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 { Stats } from 'fs';
4
- import { MessagePort } from 'worker_threads';
3
+ import { ViteNodeRunner } from 'vite-node/client';
4
+ import { ViteNodeServer } from 'vite-node/server';
5
+ import { RawSourceMap, ViteNodeResolveId, FetchFunction, ModuleCacheMap } from 'vite-node';
6
+ import { Stats } from 'node:fs';
7
+ import { MessagePort } from 'node:worker_threads';
5
8
 
6
9
  /**
7
10
  * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
@@ -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
- type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>;
328
- type FetchFunction = (id: string) => Promise<FetchResult>;
329
- type ResolveIdFunction$1 = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
330
- 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;
@@ -1831,17 +1564,32 @@ interface InlineConfig {
1831
1564
  root?: string;
1832
1565
  /**
1833
1566
  * Custom reporter for output. Can contain one or more built-in report names, reporter instances,
1834
- * and/or paths to custom reporters
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
- * diff output length
1571
+ * Truncates lines in the output to the given length.
1572
+ * @default stdout.columns || 80
1839
1573
  */
1840
1574
  outputTruncateLength?: number;
1841
1575
  /**
1842
- * number of diff output lines
1576
+ * Maximum number of line to show in a single diff.
1577
+ * @default 15
1843
1578
  */
1844
1579
  outputDiffLines?: number;
1580
+ /**
1581
+ * The maximum number of characters allowed in a single object before doing a diff.
1582
+ * Vitest tries to stringify an object before doing a diff, but if the object is too large,
1583
+ * it will reduce the depth of the object to fit within this limit.
1584
+ * Because of this if object is too big or nested, you might not see the diff.
1585
+ * @default 10000
1586
+ */
1587
+ outputDiffMaxSize?: number;
1588
+ /**
1589
+ * Maximum number of lines in a diff overall.
1590
+ * @default 50
1591
+ */
1592
+ outputDiffMaxLines?: number;
1845
1593
  /**
1846
1594
  * Write test results to a file when the --reporter=json` or `--reporter=junit` option is also specified.
1847
1595
  * Also definable individually per reporter by using an object instead.
@@ -1938,6 +1686,16 @@ interface InlineConfig {
1938
1686
  * @default false
1939
1687
  */
1940
1688
  restoreMocks?: boolean;
1689
+ /**
1690
+ * Will restore all global stubs to their original values before each test
1691
+ * @default false
1692
+ */
1693
+ unstubGlobals?: boolean;
1694
+ /**
1695
+ * Will restore all env stubs to their original values before each test
1696
+ * @default false
1697
+ */
1698
+ unstubEnvs?: boolean;
1941
1699
  /**
1942
1700
  * Serve API options.
1943
1701
  *
@@ -2245,7 +2003,9 @@ declare const INVERTED_COLOR: Formatter;
2245
2003
  declare const BOLD_WEIGHT: Formatter;
2246
2004
  declare const DIM_COLOR: Formatter;
2247
2005
  declare function matcherHint(matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions): string;
2248
- declare function stringify(object: unknown, maxDepth?: number, options?: PrettyFormatOptions): string;
2006
+ declare function stringify(object: unknown, maxDepth?: number, { maxLength, ...options }?: PrettyFormatOptions & {
2007
+ maxLength?: number;
2008
+ }): string;
2249
2009
  declare const printReceived: (object: unknown) => string;
2250
2010
  declare const printExpected: (value: unknown) => string;
2251
2011
  declare function diff(a: any, b: any, options?: DiffOptions): string;
@@ -2483,4 +2243,4 @@ type Context = RootAndTarget & {
2483
2243
  lastActivePath?: string;
2484
2244
  };
2485
2245
 
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 };
2246
+ 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 };