vitest 2.2.0-beta.2 → 3.0.0-beta.2

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 (54) hide show
  1. package/LICENSE.md +75 -0
  2. package/dist/browser.d.ts +13 -10
  3. package/dist/browser.js +2 -2
  4. package/dist/chunks/{RandomSequencer.BPedXEug.js → RandomSequencer.gisBJ77r.js} +11 -4
  5. package/dist/chunks/{base.BS0HhLXd.js → base.CUgXReRN.js} +8 -3
  6. package/dist/chunks/{cac.Cs06pOqp.js → cac.Xzv7eNWw.js} +22 -17
  7. package/dist/chunks/{cli-api.CB-jIbYQ.js → cli-api.CETCDGgZ.js} +985 -498
  8. package/dist/chunks/{config.CPguQ7J1.d.ts → config.BTPBhmK5.d.ts} +1 -1
  9. package/dist/chunks/{coverage.BoMDb1ip.js → coverage.BWeNbfBa.js} +4 -4
  10. package/dist/chunks/{creator.IIqd8RWT.js → creator.DcAcUhMD.js} +1 -4
  11. package/dist/chunks/{environment.CT0jpO-1.d.ts → environment.d8YfPkTm.d.ts} +1 -3
  12. package/dist/chunks/{globals.BCGEw6ON.js → globals.BFncSRNA.js} +2 -2
  13. package/dist/chunks/{index.bzFpKeaq.js → index.9ZEBV_TJ.js} +992 -577
  14. package/dist/chunks/{index.DD5eTY2y.js → index.CkWmZCXU.js} +1 -1
  15. package/dist/chunks/{index.CqYx2Nsr.js → index.DQboAxJm.js} +23 -14
  16. package/dist/chunks/{index.BjjsHdBb.js → index.DoV7W5gc.js} +2 -2
  17. package/dist/chunks/{inspector.70d6emsh.js → inspector.DKLceBVD.js} +1 -1
  18. package/dist/chunks/{reporters.F9D2idOT.d.ts → reporters.DTtxC3KQ.d.ts} +588 -524
  19. package/dist/chunks/{resolveConfig.CLnvCvEs.js → resolveConfig.BA-_OKEx.js} +5599 -5570
  20. package/dist/chunks/{runBaseTests.B7hcVT-s.js → runBaseTests.D0dWpzZV.js} +13 -12
  21. package/dist/chunks/{setup-common.BfGt8K-K.js → setup-common.Cp_bu5q3.js} +1 -1
  22. package/dist/chunks/types.BOjykUpq.d.ts +27 -0
  23. package/dist/chunks/{utils.DJONn5B5.js → utils.CMUTX-p8.js} +5 -2
  24. package/dist/chunks/{vi.BlPttogV.js → vi.S4Fq8wSo.js} +20 -14
  25. package/dist/chunks/{vite.DonA4fvH.d.ts → vite.CXaetSK3.d.ts} +1 -1
  26. package/dist/chunks/{vm.Zr4qWzDJ.js → vm.DGhTouO3.js} +10 -1
  27. package/dist/chunks/{worker.Qz1UB4Fv.d.ts → worker.ClntunZp.d.ts} +1 -1
  28. package/dist/chunks/{worker.9VY11NZs.d.ts → worker.o1PBoDdo.d.ts} +4 -4
  29. package/dist/cli.js +1 -1
  30. package/dist/config.cjs +1 -10
  31. package/dist/config.d.ts +7 -10
  32. package/dist/config.js +1 -10
  33. package/dist/coverage.d.ts +5 -7
  34. package/dist/coverage.js +4 -4
  35. package/dist/environments.d.ts +2 -2
  36. package/dist/execute.d.ts +4 -4
  37. package/dist/index.d.ts +27 -22
  38. package/dist/index.js +2 -2
  39. package/dist/node.d.ts +25 -33
  40. package/dist/node.js +66 -32
  41. package/dist/reporters.d.ts +5 -7
  42. package/dist/reporters.js +5 -4
  43. package/dist/runners.d.ts +3 -4
  44. package/dist/runners.js +9 -14
  45. package/dist/suite.d.ts +1 -1
  46. package/dist/worker.js +1 -1
  47. package/dist/workers/forks.js +1 -1
  48. package/dist/workers/runVmTests.js +9 -9
  49. package/dist/workers/threads.js +1 -1
  50. package/dist/workers/vmForks.js +1 -1
  51. package/dist/workers/vmThreads.js +1 -1
  52. package/dist/workers.d.ts +4 -4
  53. package/dist/workers.js +3 -3
  54. package/package.json +23 -24
@@ -1,17 +1,17 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { startTests, collectTests } from '@vitest/runner';
3
- import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.BjjsHdBb.js';
4
- import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.BoMDb1ip.js';
5
- import { a as globalExpect, v as vi } from './vi.BlPttogV.js';
6
- import { c as closeInspector } from './inspector.70d6emsh.js';
3
+ import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.DoV7W5gc.js';
4
+ import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.BWeNbfBa.js';
5
+ import { a as globalExpect, v as vi } from './vi.S4Fq8wSo.js';
6
+ import { c as closeInspector } from './inspector.DKLceBVD.js';
7
7
  import { createRequire } from 'node:module';
8
8
  import timers from 'node:timers';
9
9
  import util from 'node:util';
10
10
  import { getSafeTimers } from '@vitest/utils';
11
11
  import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
12
12
  import { installSourcemapsSupport } from 'vite-node/source-map';
13
- import { V as VitestIndex } from './index.DD5eTY2y.js';
14
- import { s as setupCommonEnv } from './setup-common.BfGt8K-K.js';
13
+ import { V as VitestIndex } from './index.CkWmZCXU.js';
14
+ import { s as setupCommonEnv } from './setup-common.Cp_bu5q3.js';
15
15
  import { g as getWorkerState, r as resetModules } from './utils.C8RiOc4B.js';
16
16
  import 'chai';
17
17
  import 'node:path';
@@ -97,8 +97,11 @@ async function withEnv({ environment }, options, fn) {
97
97
 
98
98
  async function run(method, files, config, environment, executor) {
99
99
  const workerState = getWorkerState();
100
+ const isIsolatedThreads = config.pool === "threads" && (config.poolOptions?.threads?.isolate ?? true);
101
+ const isIsolatedForks = config.pool === "forks" && (config.poolOptions?.forks?.isolate ?? true);
102
+ const isolate = isIsolatedThreads || isIsolatedForks;
100
103
  await setupGlobalEnv(config, environment, executor);
101
- await startCoverageInsideWorker(config.coverage, executor);
104
+ await startCoverageInsideWorker(config.coverage, executor, { isolate });
102
105
  if (config.chaiConfig) {
103
106
  setupChaiConfig(config.chaiConfig);
104
107
  }
@@ -115,13 +118,11 @@ async function run(method, files, config, environment, executor) {
115
118
  async () => {
116
119
  workerState.durations.environment = performance.now() - workerState.durations.environment;
117
120
  for (const file of files) {
118
- const isIsolatedThreads = config.pool === "threads" && (config.poolOptions?.threads?.isolate ?? true);
119
- const isIsolatedForks = config.pool === "forks" && (config.poolOptions?.forks?.isolate ?? true);
120
- if (isIsolatedThreads || isIsolatedForks) {
121
+ if (isolate) {
121
122
  executor.mocker.reset();
122
123
  resetModules(workerState.moduleCache, true);
123
124
  }
124
- workerState.filepath = file;
125
+ workerState.filepath = file.filepath;
125
126
  if (method === "run") {
126
127
  await startTests([file], runner);
127
128
  } else {
@@ -130,7 +131,7 @@ async function run(method, files, config, environment, executor) {
130
131
  vi.resetConfig();
131
132
  vi.restoreAllMocks();
132
133
  }
133
- await stopCoverageInsideWorker(config.coverage, executor);
134
+ await stopCoverageInsideWorker(config.coverage, executor, { isolate });
134
135
  }
135
136
  );
136
137
  workerState.environmentTeardownRun = true;
@@ -13,7 +13,7 @@ async function setupCommonEnv(config) {
13
13
  globalSetup = true;
14
14
  setSafeTimers();
15
15
  if (config.globals) {
16
- (await import('./globals.BCGEw6ON.js')).registerApiGlobally();
16
+ (await import('./globals.BFncSRNA.js')).registerApiGlobally();
17
17
  }
18
18
  }
19
19
  function setupDefines(defines) {
@@ -0,0 +1,27 @@
1
+ type RawErrsMap = Map<string, TscErrorInfo[]>;
2
+ interface TscErrorInfo {
3
+ filePath: string;
4
+ errCode: number;
5
+ errMsg: string;
6
+ line: number;
7
+ column: number;
8
+ }
9
+ interface CollectLineNumbers {
10
+ target: number;
11
+ next: number;
12
+ prev?: number;
13
+ }
14
+ type CollectLines = {
15
+ [key in keyof CollectLineNumbers]: string;
16
+ };
17
+ interface RootAndTarget {
18
+ root: string;
19
+ targetAbsPath: string;
20
+ }
21
+ type Context = RootAndTarget & {
22
+ rawErrsMap: RawErrsMap;
23
+ openedDirs: Set<string>;
24
+ lastActivePath?: string;
25
+ };
26
+
27
+ export type { CollectLineNumbers as C, RawErrsMap as R, TscErrorInfo as T, CollectLines as a, RootAndTarget as b, Context as c };
@@ -166,9 +166,12 @@ function formatProjectName(name, suffix = " ") {
166
166
  if (!name) {
167
167
  return "";
168
168
  }
169
+ if (!c.isColorSupported) {
170
+ return `|${name}|${suffix}`;
171
+ }
169
172
  const index = name.split("").reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0);
170
- const colors = [c.blue, c.yellow, c.cyan, c.green, c.magenta];
171
- return colors[index % colors.length](`|${name}|`) + suffix;
173
+ const colors = [c.black, c.yellow, c.cyan, c.green, c.magenta];
174
+ return c.inverse(colors[index % colors.length](` ${name} `)) + suffix;
172
175
  }
173
176
  function withLabel(color, label, message) {
174
177
  return `${c.bold(c.inverse(c[color](` ${label} `)))} ${message ? c[color](message) : ""}`;
@@ -1,4 +1,4 @@
1
- import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters } from '@vitest/expect';
1
+ import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters, customMatchers } from '@vitest/expect';
2
2
  import { getCurrentTest } from '@vitest/runner';
3
3
  import { getNames, getTestName } from '@vitest/runner/utils';
4
4
  import * as chai$1 from 'chai';
@@ -274,9 +274,9 @@ function recordAsyncExpect(_test, promise, assertion, error) {
274
274
  }
275
275
  });
276
276
  return {
277
- then(onFullfilled, onRejected) {
277
+ then(onFulfilled, onRejected) {
278
278
  resolved = true;
279
- return promise.then(onFullfilled, onRejected);
279
+ return promise.then(onFulfilled, onRejected);
280
280
  },
281
281
  catch(onRejected) {
282
282
  return promise.catch(onRejected);
@@ -318,15 +318,20 @@ function getError(expected, promise) {
318
318
  throw new Error("snapshot function didn't throw");
319
319
  }
320
320
  function getTestNames(test) {
321
- if (!test) {
322
- return {};
323
- }
324
321
  return {
325
322
  filepath: test.file.filepath,
326
- name: getNames(test).slice(1).join(" > ")
323
+ name: getNames(test).slice(1).join(" > "),
324
+ testId: test.id
327
325
  };
328
326
  }
329
327
  const SnapshotPlugin = (chai, utils) => {
328
+ function getTest(assertionName, obj) {
329
+ const test = utils.flag(obj, "vitest-test");
330
+ if (!test) {
331
+ throw new Error(`'${assertionName}' cannot be used without test context`);
332
+ }
333
+ return test;
334
+ }
330
335
  for (const key of ["matchSnapshot", "toMatchSnapshot"]) {
331
336
  utils.addMethod(
332
337
  chai.Assertion.prototype,
@@ -338,7 +343,7 @@ const SnapshotPlugin = (chai, utils) => {
338
343
  throw new Error(`${key} cannot be used with "not"`);
339
344
  }
340
345
  const expected = utils.flag(this, "object");
341
- const test = utils.flag(this, "vitest-test");
346
+ const test = getTest(key, this);
342
347
  if (typeof properties === "string" && typeof message === "undefined") {
343
348
  message = properties;
344
349
  properties = void 0;
@@ -366,7 +371,7 @@ const SnapshotPlugin = (chai, utils) => {
366
371
  }
367
372
  const error = new Error("resolves");
368
373
  const expected = utils.flag(this, "object");
369
- const test = utils.flag(this, "vitest-test");
374
+ const test = getTest("toMatchFileSnapshot", this);
370
375
  const errorMessage = utils.flag(this, "message");
371
376
  const promise = getSnapshotClient().assertRaw({
372
377
  received: expected,
@@ -395,8 +400,8 @@ const SnapshotPlugin = (chai, utils) => {
395
400
  if (isNot) {
396
401
  throw new Error('toMatchInlineSnapshot cannot be used with "not"');
397
402
  }
398
- const test = utils.flag(this, "vitest-test");
399
- const isInsideEach = test && (test.each || test.suite?.each);
403
+ const test = getTest("toMatchInlineSnapshot", this);
404
+ const isInsideEach = test.each || test.suite?.each;
400
405
  if (isInsideEach) {
401
406
  throw new Error(
402
407
  "InlineSnapshot cannot be used inside of test.each or describe.each"
@@ -437,7 +442,7 @@ const SnapshotPlugin = (chai, utils) => {
437
442
  );
438
443
  }
439
444
  const expected = utils.flag(this, "object");
440
- const test = utils.flag(this, "vitest-test");
445
+ const test = getTest("toThrowErrorMatchingSnapshot", this);
441
446
  const promise = utils.flag(this, "promise");
442
447
  const errorMessage = utils.flag(this, "message");
443
448
  getSnapshotClient().assert({
@@ -458,8 +463,8 @@ const SnapshotPlugin = (chai, utils) => {
458
463
  'toThrowErrorMatchingInlineSnapshot cannot be used with "not"'
459
464
  );
460
465
  }
461
- const test = utils.flag(this, "vitest-test");
462
- const isInsideEach = test && (test.each || test.suite?.each);
466
+ const test = getTest("toThrowErrorMatchingInlineSnapshot", this);
467
+ const isInsideEach = test.each || test.suite?.each;
463
468
  if (isInsideEach) {
464
469
  throw new Error(
465
470
  "InlineSnapshot cannot be used inside of test.each or describe.each"
@@ -561,6 +566,7 @@ function createExpect(test) {
561
566
  }
562
567
  chai$1.util.addMethod(expect, "assertions", assertions);
563
568
  chai$1.util.addMethod(expect, "hasAssertions", hasAssertions);
569
+ expect.extend(customMatchers);
564
570
  return expect;
565
571
  }
566
572
  const globalExpect = createExpect();
@@ -1,4 +1,4 @@
1
- import { I as InlineConfig } from './reporters.F9D2idOT.js';
1
+ import { I as InlineConfig } from './reporters.DTtxC3KQ.js';
2
2
 
3
3
  type VitestInlineConfig = InlineConfig;
4
4
  declare module 'vite' {
@@ -119,6 +119,7 @@ class CommonjsExecutor {
119
119
  static constants = Module.constants;
120
120
  static enableCompileCache = Module.enableCompileCache;
121
121
  static getCompileCacheDir = Module.getCompileCacheDir;
122
+ static flushCompileCache = Module.flushCompileCache;
122
123
  static Module = Module$1;
123
124
  };
124
125
  this.extensions[".js"] = this.requireJs;
@@ -830,8 +831,16 @@ async function runVmTests(method, state) {
830
831
  const { run } = await executor.importExternalModule(
831
832
  entryFile
832
833
  );
834
+ const fileSpecs = ctx.files.map(
835
+ (f) => typeof f === "string" ? { filepath: f, testLocations: void 0 } : f
836
+ );
833
837
  try {
834
- await run(method, ctx.files, ctx.config, executor);
838
+ await run(
839
+ method,
840
+ fileSpecs,
841
+ ctx.config,
842
+ executor
843
+ );
835
844
  } finally {
836
845
  await vm.teardown?.();
837
846
  state.environmentTeardownRun = true;
@@ -1,5 +1,5 @@
1
1
  import { MessagePort } from 'node:worker_threads';
2
- import { C as ContextRPC } from './worker.9VY11NZs.js';
2
+ import { C as ContextRPC } from './worker.o1PBoDdo.js';
3
3
 
4
4
  interface WorkerContext extends ContextRPC {
5
5
  port: MessagePort;
@@ -1,7 +1,7 @@
1
- import { File, TaskResultPack, CancelReason, Task } from '@vitest/runner';
1
+ import { File, TaskResultPack, CancelReason, FileSpecification, Task } from '@vitest/runner';
2
2
  import { ViteNodeResolveId, ModuleCacheMap } from 'vite-node';
3
- import { S as SerializedConfig } from './config.CPguQ7J1.js';
4
- import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.CT0jpO-1.js';
3
+ import { S as SerializedConfig } from './config.BTPBhmK5.js';
4
+ import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.d8YfPkTm.js';
5
5
  import { SnapshotResult } from '@vitest/snapshot';
6
6
 
7
7
  type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
@@ -130,7 +130,7 @@ interface ContextRPC {
130
130
  workerId: number;
131
131
  config: SerializedConfig;
132
132
  projectName: string;
133
- files: string[];
133
+ files: string[] | FileSpecification[];
134
134
  environment: ContextTestEnvironment;
135
135
  providedContext: Record<string, any>;
136
136
  invalidates?: string[];
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createCLI } from './chunks/cac.Cs06pOqp.js';
1
+ import { c as createCLI } from './chunks/cac.Xzv7eNWw.js';
2
2
  import '@vitest/utils';
3
3
  import 'events';
4
4
  import 'pathe';
package/dist/config.cjs CHANGED
@@ -81,16 +81,7 @@ const coverageConfigDefaults = {
81
81
  };
82
82
  const fakeTimersDefaults = {
83
83
  loopLimit: 1e4,
84
- shouldClearNativeTimers: true,
85
- toFake: [
86
- "setTimeout",
87
- "clearTimeout",
88
- "setInterval",
89
- "clearInterval",
90
- "setImmediate",
91
- "clearImmediate",
92
- "Date"
93
- ]
84
+ shouldClearNativeTimers: true
94
85
  };
95
86
  const config = {
96
87
  allowOnly: !stdEnv.isCI,
package/dist/config.d.ts CHANGED
@@ -1,25 +1,23 @@
1
1
  import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';
3
- import { R as ResolvedCoverageOptions, d as CoverageV8Options, U as UserWorkspaceConfig, e as UserProjectConfigFn, f as UserProjectConfigExport, T as TestProjectConfiguration } from './chunks/reporters.F9D2idOT.js';
4
- export { W as WorkspaceProjectConfiguration } from './chunks/reporters.F9D2idOT.js';
5
- import './chunks/vite.DonA4fvH.js';
3
+ import { R as ResolvedCoverageOptions, d as CoverageV8Options, U as UserWorkspaceConfig, e as UserProjectConfigFn, f as UserProjectConfigExport, T as TestProjectConfiguration } from './chunks/reporters.DTtxC3KQ.js';
4
+ export { W as WorkspaceProjectConfiguration } from './chunks/reporters.DTtxC3KQ.js';
5
+ import './chunks/vite.CXaetSK3.js';
6
6
  import '@vitest/runner';
7
- import './chunks/environment.CT0jpO-1.js';
8
- import 'node:stream';
7
+ import './chunks/environment.d8YfPkTm.js';
9
8
  import '@vitest/utils';
10
- import 'vite-node';
9
+ import 'node:stream';
11
10
  import '@vitest/utils/source-map';
12
- import './chunks/config.CPguQ7J1.js';
11
+ import './chunks/config.BTPBhmK5.js';
13
12
  import '@vitest/pretty-format';
14
13
  import '@vitest/snapshot';
15
14
  import '@vitest/snapshot/environment';
16
15
  import '@vitest/utils/diff';
16
+ import 'vite-node';
17
17
  import 'chai';
18
18
  import './chunks/benchmark.CFFwLv-O.js';
19
19
  import '@vitest/runner/utils';
20
20
  import 'tinybench';
21
- import 'vite-node/client';
22
- import 'vite-node/server';
23
21
  import '@vitest/snapshot/manager';
24
22
  import 'node:fs';
25
23
 
@@ -60,7 +58,6 @@ declare const configDefaults: Readonly<{
60
58
  fakeTimers: {
61
59
  loopLimit: number;
62
60
  shouldClearNativeTimers: true;
63
- toFake: ("setTimeout" | "setInterval" | "clearInterval" | "clearTimeout" | "setImmediate" | "clearImmediate" | "Date")[];
64
61
  };
65
62
  maxConcurrency: number;
66
63
  dangerouslyIgnoreUnhandledErrors: false;
package/dist/config.js CHANGED
@@ -79,16 +79,7 @@ const coverageConfigDefaults = {
79
79
  };
80
80
  const fakeTimersDefaults = {
81
81
  loopLimit: 1e4,
82
- shouldClearNativeTimers: true,
83
- toFake: [
84
- "setTimeout",
85
- "clearTimeout",
86
- "setInterval",
87
- "clearInterval",
88
- "setImmediate",
89
- "clearImmediate",
90
- "Date"
91
- ]
82
+ shouldClearNativeTimers: true
92
83
  };
93
84
  const config = {
94
85
  allowOnly: !isCI,
@@ -1,22 +1,20 @@
1
1
  import * as vite from 'vite';
2
- import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, a as ReportContext } from './chunks/reporters.F9D2idOT.js';
3
- import { A as AfterSuiteRunMeta } from './chunks/environment.CT0jpO-1.js';
2
+ import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, a as ReportContext } from './chunks/reporters.DTtxC3KQ.js';
3
+ import { A as AfterSuiteRunMeta } from './chunks/environment.d8YfPkTm.js';
4
4
  import '@vitest/runner';
5
- import 'node:stream';
6
5
  import '@vitest/utils';
7
- import 'vite-node';
6
+ import 'node:stream';
8
7
  import '@vitest/utils/source-map';
9
- import './chunks/config.CPguQ7J1.js';
8
+ import './chunks/config.BTPBhmK5.js';
10
9
  import '@vitest/pretty-format';
11
10
  import '@vitest/snapshot';
12
11
  import '@vitest/snapshot/environment';
13
12
  import '@vitest/utils/diff';
13
+ import 'vite-node';
14
14
  import 'chai';
15
15
  import './chunks/benchmark.CFFwLv-O.js';
16
16
  import '@vitest/runner/utils';
17
17
  import 'tinybench';
18
- import 'vite-node/client';
19
- import 'vite-node/server';
20
18
  import '@vitest/snapshot/manager';
21
19
  import 'node:fs';
22
20
 
package/dist/coverage.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import { existsSync, promises, readdirSync, writeFileSync } from 'node:fs';
2
- import { c as coverageConfigDefaults, r as resolveCoverageReporters, m as mm } from './chunks/resolveConfig.CLnvCvEs.js';
2
+ import { c as coverageConfigDefaults, r as resolveCoverageReporters, m as mm } from './chunks/resolveConfig.BA-_OKEx.js';
3
3
  import { resolve, relative } from 'pathe';
4
4
  import c from 'tinyrainbow';
5
5
  import '@vitest/utils';
6
- import 'node:path';
7
6
  import 'node:fs/promises';
8
- import 'node:process';
9
7
  import 'node:module';
8
+ import 'node:path';
9
+ import 'node:process';
10
10
  import 'node:url';
11
11
  import 'node:assert';
12
12
  import 'node:v8';
13
13
  import 'node:util';
14
14
  import './chunks/constants.fzPh7AOq.js';
15
15
  import 'node:os';
16
- import './chunks/RandomSequencer.BPedXEug.js';
16
+ import './chunks/RandomSequencer.gisBJ77r.js';
17
17
  import 'std-env';
18
18
  import 'node:perf_hooks';
19
19
  import '@vitest/runner/utils';
@@ -1,5 +1,5 @@
1
- import { E as Environment } from './chunks/environment.CT0jpO-1.js';
2
- export { a as EnvironmentReturn, V as VmEnvironmentReturn } from './chunks/environment.CT0jpO-1.js';
1
+ import { E as Environment } from './chunks/environment.d8YfPkTm.js';
2
+ export { a as EnvironmentReturn, V as VmEnvironmentReturn } from './chunks/environment.d8YfPkTm.js';
3
3
 
4
4
  declare const environments: {
5
5
  node: Environment;
package/dist/execute.d.ts CHANGED
@@ -1,24 +1,24 @@
1
1
  import { ViteNodeRunnerOptions } from 'vite-node';
2
2
  import { ViteNodeRunner } from 'vite-node/client';
3
- import { R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.9VY11NZs.js';
3
+ import { R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.o1PBoDdo.js';
4
4
  import vm from 'node:vm';
5
5
  import * as _vitest_mocker from '@vitest/mocker';
6
6
  import { MockedModuleType } from '@vitest/mocker';
7
7
  import { P as PendingSuiteMock, b as MockFactory, a as MockOptions } from './chunks/mocker.cRtM890J.js';
8
8
  import '@vitest/runner';
9
- import './chunks/config.CPguQ7J1.js';
9
+ import './chunks/config.BTPBhmK5.js';
10
10
  import '@vitest/pretty-format';
11
11
  import '@vitest/snapshot';
12
12
  import '@vitest/snapshot/environment';
13
13
  import '@vitest/utils/diff';
14
- import './chunks/environment.CT0jpO-1.js';
14
+ import './chunks/environment.d8YfPkTm.js';
15
15
 
16
16
  declare class FileMap {
17
17
  private fsCache;
18
18
  private fsBufferCache;
19
19
  readFileAsync(path: string): Promise<string>;
20
20
  readFile(path: string): string;
21
- readBuffer(path: string): Buffer;
21
+ readBuffer(path: string): Buffer<ArrayBufferLike>;
22
22
  }
23
23
 
24
24
  interface ModuleEvaluateOptions {
package/dist/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { TaskResultPack as TaskResultPack$1, File as File$1, TaskPopulated, Suite as Suite$1, Test as Test$1, Custom as Custom$1, Task as Task$1, TaskBase as TaskBase$1, TaskResult as TaskResult$1, DoneCallback as DoneCallback$1, RuntimeContext as RuntimeContext$1, SuiteHooks as SuiteHooks$1, SequenceHooks as SequenceHooks$1, SequenceSetupFiles as SequenceSetupFiles$1 } from '@vitest/runner';
2
2
  export { CancelReason, ExtendedContext, HookCleanupCallback, HookListener, OnTestFailedHandler, OnTestFinishedHandler, RunMode, Custom as RunnerCustomCase, Task as RunnerTask, TaskBase as RunnerTaskBase, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SuiteAPI, SuiteCollector, SuiteFactory, TaskContext, TaskCustomOptions, TaskMeta, TaskState, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
3
- import { g as VitestEnvironment$1, S as SerializedTestSpecification, h as RawErrsMap$1, i as TscErrorInfo$1, j as CollectLineNumbers$1, k as CollectLines$1, l as RootAndTarget$1, m as Context$1, b as CoverageProvider$1, a as ReportContext$1, c as CoverageProviderModule$1, n as CoverageReporter$1, o as CoverageProviderName, p as CoverageOptions$1, R as ResolvedCoverageOptions$1, B as BaseCoverageOptions$1, q as CoverageIstanbulOptions$1, d as CoverageV8Options$1, r as CustomProviderOptions$1, s as Reporter$1, V as Vitest$1, t as BrowserScript$1, u as BrowserConfigOptions$1, v as BuiltinEnvironment$1, P as Pool$1, w as PoolOptions$1, x as CSSModuleScopeStrategy$1, A as ApiConfig$1, y as VitestRunMode$1, D as DepsOptimizationOptions$1, z as TransformModePatterns$1, I as InlineConfig$1, E as TypecheckConfig$1, F as UserConfig$1, G as ResolvedConfig$1, H as ProjectConfig$1, U as UserWorkspaceConfig$1, J as BenchmarkUserOptions$1 } from './chunks/reporters.F9D2idOT.js';
4
- import { W as WorkerContext$1 } from './chunks/worker.Qz1UB4Fv.js';
5
- import { U as UserConsoleLog, M as ModuleGraphData, b as Awaitable$1, P as ProvidedContext, N as Nullable$1, c as Arrayable$1, d as ArgumentsType$1, e as MutableArray$1, C as Constructable$1, O as OnServerRestartHandler$1, a as EnvironmentReturn$1, V as VmEnvironmentReturn$1, E as Environment$1, R as ResolvedTestEnvironment$1, J as JSDOMOptions$1, H as HappyDOMOptions$1, f as EnvironmentOptions$1 } from './chunks/environment.CT0jpO-1.js';
6
- export { A as AfterSuiteRunMeta, g as ModuleCache } from './chunks/environment.CT0jpO-1.js';
7
- import { a as BirpcReturn, b as WorkerRPC$1 } from './chunks/worker.9VY11NZs.js';
8
- export { C as ContextRPC, d as ContextTestEnvironment, e as ResolveIdFunction, c as RunnerRPC, R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.9VY11NZs.js';
9
- import './chunks/vite.DonA4fvH.js';
3
+ import { S as SerializedTestSpecification, b as CoverageProvider$1, a as ReportContext$1, c as CoverageProviderModule$1, g as CoverageReporter$1, h as CoverageProviderName, i as CoverageOptions$1, R as ResolvedCoverageOptions$1, B as BaseCoverageOptions$1, j as CoverageIstanbulOptions$1, d as CoverageV8Options$1, k as CustomProviderOptions$1, l as Reporter$1, V as Vitest$1, m as BrowserScript$1, n as BrowserConfigOptions$1, o as BuiltinEnvironment$1, p as VitestEnvironment$1, P as Pool$1, q as PoolOptions$1, r as CSSModuleScopeStrategy$1, A as ApiConfig$1, s as VitestRunMode$1, D as DepsOptimizationOptions$1, t as TransformModePatterns$1, I as InlineConfig$1, u as TypecheckConfig$1, v as UserConfig$1, w as ResolvedConfig$1, x as ProjectConfig$1, U as UserWorkspaceConfig$1, y as BenchmarkUserOptions$1 } from './chunks/reporters.DTtxC3KQ.js';
4
+ import { W as WorkerContext$1 } from './chunks/worker.ClntunZp.js';
5
+ import { R as RawErrsMap$1, T as TscErrorInfo$1, C as CollectLineNumbers$1, a as CollectLines$1, b as RootAndTarget$1, c as Context$1 } from './chunks/types.BOjykUpq.js';
6
+ import { U as UserConsoleLog, M as ModuleGraphData, b as Awaitable$1, P as ProvidedContext, N as Nullable$1, c as Arrayable$1, d as ArgumentsType$1, e as MutableArray$1, C as Constructable$1, a as EnvironmentReturn$1, V as VmEnvironmentReturn$1, E as Environment$1, R as ResolvedTestEnvironment$1, J as JSDOMOptions$1, H as HappyDOMOptions$1, f as EnvironmentOptions$1 } from './chunks/environment.d8YfPkTm.js';
7
+ export { A as AfterSuiteRunMeta, g as ModuleCache } from './chunks/environment.d8YfPkTm.js';
8
+ import { a as BirpcReturn, b as WorkerRPC$1 } from './chunks/worker.o1PBoDdo.js';
9
+ export { C as ContextRPC, d as ContextTestEnvironment, e as ResolveIdFunction, c as RunnerRPC, R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.o1PBoDdo.js';
10
+ import './chunks/vite.CXaetSK3.js';
10
11
  import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
11
12
  export { Assertion, AsymmetricMatchersContaining, ExpectPollOptions, ExpectStatic, JestAssertion } from '@vitest/expect';
12
13
  import { Plugin } from '@vitest/pretty-format';
@@ -14,8 +15,8 @@ import { SnapshotState } from '@vitest/snapshot';
14
15
  export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotSerializer, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
15
16
  import { B as BenchmarkResult } from './chunks/benchmark.CFFwLv-O.js';
16
17
  export { a as BenchFunction, b as Benchmark, c as BenchmarkAPI } from './chunks/benchmark.CFFwLv-O.js';
17
- import { S as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.CPguQ7J1.js';
18
- export { b as RuntimeConfig, a as SerializedCoverageConfig } from './chunks/config.CPguQ7J1.js';
18
+ import { S as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.BTPBhmK5.js';
19
+ export { b as RuntimeConfig, a as SerializedCoverageConfig } from './chunks/config.BTPBhmK5.js';
19
20
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
20
21
  export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject } from '@vitest/spy';
21
22
  import { M as MockFactoryWithHelper, a as MockOptions } from './chunks/mocker.cRtM890J.js';
@@ -29,10 +30,8 @@ export { assert, should } from 'chai';
29
30
  export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
30
31
  import 'node:stream';
31
32
  import 'vite';
32
- import 'vite-node';
33
33
  import '@vitest/utils/source-map';
34
- import 'vite-node/client';
35
- import 'vite-node/server';
34
+ import 'vite-node';
36
35
  import '@vitest/snapshot/manager';
37
36
  import 'node:fs';
38
37
  import 'node:worker_threads';
@@ -64,7 +63,7 @@ interface InlineSnapshotMatcher<T> {
64
63
  }
65
64
  declare module '@vitest/expect' {
66
65
  interface MatcherState {
67
- environment: VitestEnvironment$1;
66
+ environment: string;
68
67
  snapshotState: SnapshotState;
69
68
  }
70
69
  interface ExpectPollOptions {
@@ -504,19 +503,27 @@ interface VitestUtils {
504
503
  */
505
504
  isMockFunction: (fn: any) => fn is MockInstance;
506
505
  /**
507
- * Calls [`.mockClear()`](https://vitest.dev/api/mock#mockclear) on every mocked function. This will only empty `.mock` state, it will not reset implementation.
506
+ * Calls [`.mockClear()`](https://vitest.dev/api/mock#mockclear) on every mocked function.
508
507
  *
509
- * It is useful if you need to clean up mock between different assertions.
508
+ * This will only empty `.mock` state, it will not affect mock implementations.
509
+ *
510
+ * This is useful if you need to clean up mocks between different assertions within a test.
510
511
  */
511
512
  clearAllMocks: () => VitestUtils;
512
513
  /**
513
- * Calls [`.mockReset()`](https://vitest.dev/api/mock#mockreset) on every mocked function. This will empty `.mock` state, reset "once" implementations and force the base implementation to return `undefined` when invoked.
514
+ * Calls [`.mockReset()`](https://vitest.dev/api/mock#mockreset) on every mocked function.
515
+ *
516
+ * This will empty `.mock` state, reset "once" implementations, and reset each mock's base implementation to its original.
514
517
  *
515
- * This is useful when you want to completely reset a mock to the default state.
518
+ * This is useful when you want to reset all mocks to their original states.
516
519
  */
517
520
  resetAllMocks: () => VitestUtils;
518
521
  /**
519
- * Calls [`.mockRestore()`](https://vitest.dev/api/mock#mockrestore) on every mocked function. This will restore all original implementations.
522
+ * Calls [`.mockRestore()`](https://vitest.dev/api/mock#mockrestore) on every mocked function.
523
+ *
524
+ * This will empty `.mock` state, restore all original mock implementations, and restore original descriptors of spied-on objects.
525
+ *
526
+ * This is useful for inter-test cleanup and/or removing mocks created by [`vi.spyOn(...)`](https://vitest.dev/api/vi#vi-spyon).
520
527
  */
521
528
  restoreAllMocks: () => VitestUtils;
522
529
  /**
@@ -591,7 +598,7 @@ type Suite = Suite$1;
591
598
  type File = File$1;
592
599
  /** @deprecated use `RunnerTestCase` instead */
593
600
  type Test = Test$1;
594
- /** @deprecated use `RunnerCustomCase` instead */
601
+ /** @deprecated do not use `Custom`, use `RunnerTestCase` instead */
595
602
  type Custom = Custom$1;
596
603
  /** @deprecated use `RunnerTask` instead */
597
604
  type Task = Task$1;
@@ -625,8 +632,6 @@ type ArgumentsType<T> = ArgumentsType$1<T>;
625
632
  type MutableArray<T extends readonly any[]> = MutableArray$1<T>;
626
633
  /** @deprecated do not use, internal helper */
627
634
  type Constructable = Constructable$1;
628
- /** @deprecated import from `vitest/node` instead */
629
- type OnServerRestartHandler = OnServerRestartHandler$1;
630
635
 
631
636
  /** @deprecated import from `vitest/environments` instead */
632
637
  type EnvironmentReturn = EnvironmentReturn$1;
@@ -713,4 +718,4 @@ type SerializableSpec = SerializedTestSpecification;
713
718
  /** @deprecated import from `vitest/node` instead */
714
719
  type BenchmarkUserOptions = BenchmarkUserOptions$1;
715
720
 
716
- export { type ApiConfig, type ArgumentsType, type Arrayable, type AssertType, type Awaitable, type BaseCoverageOptions, BenchmarkResult, type BenchmarkUserOptions, type BrowserConfigOptions, type BrowserScript, type BrowserUI, type BuiltinEnvironment, type CSSModuleScopeStrategy, type CollectLineNumbers, type CollectLines, type Constructable, type Context, type CoverageIstanbulOptions, type CoverageOptions, type CoverageProvider, type CoverageProviderModule, type CoverageReporter, type CoverageV8Options, type Custom, type CustomProviderOptions, type DepsOptimizationOptions, type DoneCallback, type Environment, type EnvironmentOptions, type EnvironmentReturn, type File, type HappyDOMOptions, type InlineConfig, type JSDOMOptions, ModuleGraphData, type MutableArray, type Nullable, type OnServerRestartHandler, type Pool, type PoolOptions, type ProjectConfig, ProvidedContext, type RawErrsMap, type ReportContext, type Reporter, type ResolvedConfig, type ResolvedCoverageOptions, type ResolvedTestEnvironment, type RootAndTarget, type RuntimeContext, type SequenceHooks, type SequenceSetupFiles, type SerializableSpec, SerializedConfig, SerializedTestSpecification, type Suite, type SuiteHooks, type Task, type TaskBase, type TaskResult, type TaskResultPack, type Test, type TransformModePatterns, type TransformResultWithSource, type TscErrorInfo, type TypecheckConfig, type UserConfig, UserConsoleLog, type UserWorkspaceConfig, type Vitest, type VitestEnvironment, type VitestRunMode, type VitestUtils, type VmEnvironmentReturn, type WebSocketEvents, type WebSocketHandlers, type WebSocketRPC, type WorkerContext, type WorkerRPC, assertType, createExpect, globalExpect as expect, getRunningMode, inject, isFirstRun, isWatchMode, runOnce, vi, vitest };
721
+ export { type ApiConfig, type ArgumentsType, type Arrayable, type AssertType, type Awaitable, type BaseCoverageOptions, BenchmarkResult, type BenchmarkUserOptions, type BrowserConfigOptions, type BrowserScript, type BrowserUI, type BuiltinEnvironment, type CSSModuleScopeStrategy, type CollectLineNumbers, type CollectLines, type Constructable, type Context, type CoverageIstanbulOptions, type CoverageOptions, type CoverageProvider, type CoverageProviderModule, type CoverageReporter, type CoverageV8Options, type Custom, type CustomProviderOptions, type DepsOptimizationOptions, type DoneCallback, type Environment, type EnvironmentOptions, type EnvironmentReturn, type File, type HappyDOMOptions, type InlineConfig, type JSDOMOptions, ModuleGraphData, type MutableArray, type Nullable, type Pool, type PoolOptions, type ProjectConfig, ProvidedContext, type RawErrsMap, type ReportContext, type Reporter, type ResolvedConfig, type ResolvedCoverageOptions, type ResolvedTestEnvironment, type RootAndTarget, type RuntimeContext, type SequenceHooks, type SequenceSetupFiles, type SerializableSpec, SerializedConfig, SerializedTestSpecification, type Suite, type SuiteHooks, type Task, type TaskBase, type TaskResult, type TaskResultPack, type Test, type TransformModePatterns, type TransformResultWithSource, type TscErrorInfo, type TypecheckConfig, type UserConfig, UserConsoleLog, type UserWorkspaceConfig, type Vitest, type VitestEnvironment, type VitestRunMode, type VitestUtils, type VmEnvironmentReturn, type WebSocketEvents, type WebSocketHandlers, type WebSocketRPC, type WorkerContext, type WorkerRPC, assertType, createExpect, globalExpect as expect, getRunningMode, inject, isFirstRun, isWatchMode, runOnce, vi, vitest };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { c as createExpect, a as expect, i as inject, v as vi, b as vitest } from './chunks/vi.BlPttogV.js';
1
+ export { c as createExpect, a as expect, i as inject, v as vi, b as vitest } from './chunks/vi.S4Fq8wSo.js';
2
2
  export { i as isFirstRun, a as runOnce } from './chunks/run-once.2ogXb3JV.js';
3
- export { a as assertType, g as getRunningMode, i as isWatchMode } from './chunks/index.DD5eTY2y.js';
3
+ export { a as assertType, g as getRunningMode, i as isWatchMode } from './chunks/index.CkWmZCXU.js';
4
4
  export { b as bench } from './chunks/benchmark.Cdu9hjj4.js';
5
5
  export { expectTypeOf } from 'expect-type';
6
6
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';