vitest 1.1.2 → 1.2.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 (62) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.js +5 -31
  3. package/dist/chunks/{api-setup.mFKdEKxa.js → api-setup.MAoRkVWJ.js} +60 -6
  4. package/dist/chunks/{integrations-globals.tnKXwyh5.js → integrations-globals.VbxbZ7hn.js} +9 -8
  5. package/dist/{entry.js → chunks/runtime-runBaseTests.LWFmrzDk.js} +20 -18
  6. package/dist/cli-wrapper.js +1 -1
  7. package/dist/cli.js +14 -14
  8. package/dist/config.cjs +12 -1
  9. package/dist/config.d.ts +5 -2
  10. package/dist/config.js +12 -2
  11. package/dist/coverage.d.ts +1 -1
  12. package/dist/environments.d.ts +1 -1
  13. package/dist/environments.js +1 -1
  14. package/dist/execute.d.ts +8 -6
  15. package/dist/execute.js +4 -7
  16. package/dist/index.d.ts +4 -3
  17. package/dist/index.js +8 -7
  18. package/dist/node.d.ts +3 -3
  19. package/dist/node.js +12 -12
  20. package/dist/{reporters-xH8_lESK.d.ts → reporters-trlZlObr.d.ts} +113 -27
  21. package/dist/reporters.d.ts +1 -1
  22. package/dist/reporters.js +4 -4
  23. package/dist/runners.d.ts +1 -1
  24. package/dist/runners.js +7 -5
  25. package/dist/{suite-GoqTeX8s.d.ts → suite-6Pt_ep5V.d.ts} +1 -1
  26. package/dist/suite.d.ts +2 -2
  27. package/dist/suite.js +3 -3
  28. package/dist/vendor/base.8wUUWReP.js +38 -0
  29. package/dist/vendor/{base._79unx2z.js → base.dzu0Y6Hj.js} +10 -1
  30. package/dist/vendor/{benchmark.WVm6DARl.js → benchmark.IlKmJkUU.js} +1 -1
  31. package/dist/vendor/{constants.WSvnD_fn.js → constants.i1PoEnhr.js} +9 -1
  32. package/dist/vendor/{coverage.v6aD8iAh.js → coverage.E7sG1b3r.js} +1 -1
  33. package/dist/vendor/{environments.QJtma9XQ.js → environments.sU0TD7wX.js} +19 -7
  34. package/dist/vendor/execute.3_hyGknJ.js +589 -0
  35. package/dist/vendor/{global.L7JRz1qU.js → global.CkGT_TMy.js} +10 -1
  36. package/dist/vendor/{index.IhksUGLR.js → index.3iX2R_Z5.js} +6 -6
  37. package/dist/vendor/{index.h0j9y5vy.js → index.D-jOsMas.js} +5 -5
  38. package/dist/vendor/{index.XU72Rmy8.js → index.rJjbcrrp.js} +1 -1
  39. package/dist/vendor/{node.UBNKMR9Y.js → node.xyYo9ZvH.js} +660 -288
  40. package/dist/vendor/{reporters.oUR9etwS.js → reporters.2PaQ2peU.js} +11 -8
  41. package/dist/vendor/{rpc.Bl-ysZIr.js → rpc.w4v8oCkK.js} +23 -2
  42. package/dist/vendor/{run-once.X3E7xx3F.js → run-once.Olz_Zkd8.js} +2 -2
  43. package/dist/vendor/setup-common.j9IXYrbN.js +29 -0
  44. package/dist/vendor/utils.GbToHGHI.js +41 -0
  45. package/dist/vendor/{vi.DTC--YO5.js → vi.smj1Ggd4.js} +9 -5
  46. package/dist/vendor/vm.vFKXXdo0.js +696 -0
  47. package/dist/worker.js +109 -82
  48. package/dist/workers/forks.js +33 -0
  49. package/dist/{entry-vm.js → workers/runVmTests.js} +20 -16
  50. package/dist/workers/threads.js +26 -0
  51. package/dist/workers/vmForks.js +43 -0
  52. package/dist/workers/vmThreads.js +36 -0
  53. package/dist/workers.d.ts +36 -0
  54. package/dist/workers.js +30 -0
  55. package/package.json +11 -7
  56. package/workers.d.ts +1 -0
  57. package/dist/child.js +0 -125
  58. package/dist/vendor/execute.cedv4NLQ.js +0 -1235
  59. package/dist/vendor/inspector.lFAeuaAt.js +0 -26
  60. package/dist/vendor/loader.L9CYwKn1.js +0 -39
  61. package/dist/vm.js +0 -126
  62. /package/dist/{paths.js → path.js} +0 -0
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { processError, startTests } from '@vitest/runner';
2
- import { R as ResolvedConfig, b as CoverageOptions, c as CoverageProvider, d as CoverageProviderModule } from './reporters-xH8_lESK.js';
2
+ import { R as ResolvedConfig, b as CoverageOptions, c as CoverageProvider, d as CoverageProviderModule } from './reporters-trlZlObr.js';
3
3
  import { VitestExecutor } from './execute.js';
4
4
  import 'vite';
5
5
  import 'vite-node';
package/dist/browser.js CHANGED
@@ -1,32 +1,6 @@
1
1
  export { processError, startTests } from '@vitest/runner';
2
- import { setSafeTimers } from '@vitest/utils';
3
- import { a as resetRunOnceCounter } from './vendor/run-once.X3E7xx3F.js';
4
- export { g as getCoverageProvider, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './vendor/coverage.v6aD8iAh.js';
5
- import './vendor/global.L7JRz1qU.js';
6
-
7
- let globalSetup = false;
8
- async function setupCommonEnv(config) {
9
- resetRunOnceCounter();
10
- setupDefines(config.defines);
11
- if (globalSetup)
12
- return;
13
- globalSetup = true;
14
- setSafeTimers();
15
- if (config.globals)
16
- (await import('./chunks/integrations-globals.tnKXwyh5.js')).registerApiGlobally();
17
- }
18
- function setupDefines(defines) {
19
- for (const key in defines)
20
- globalThis[key] = defines[key];
21
- }
22
- async function loadDiffConfig(config, executor) {
23
- if (typeof config.diff !== "string")
24
- return;
25
- const diffModule = await executor.executeId(config.diff);
26
- if (diffModule && typeof diffModule.default === "object" && diffModule.default != null)
27
- return diffModule.default;
28
- else
29
- throw new Error(`invalid diff config file ${config.diff}. Must have a default export with config object`);
30
- }
31
-
32
- export { loadDiffConfig, setupCommonEnv };
2
+ export { l as loadDiffConfig, s as setupCommonEnv } from './vendor/setup-common.j9IXYrbN.js';
3
+ export { g as getCoverageProvider, a as startCoverageInsideWorker, s as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './vendor/coverage.E7sG1b3r.js';
4
+ import '@vitest/utils';
5
+ import './vendor/run-once.Olz_Zkd8.js';
6
+ import './vendor/global.CkGT_TMy.js';
@@ -13,14 +13,56 @@ import require$$4 from 'tls';
13
13
  import require$$7 from 'url';
14
14
  import { g as getDefaultExportFromCjs } from '../vendor/_commonjsHelpers.jjO7Zipk.js';
15
15
  import { isFileServingAllowed } from 'vite';
16
- import { A as API_PATH } from '../vendor/constants.WSvnD_fn.js';
17
- import '../vendor/index.XU72Rmy8.js';
16
+ import { A as API_PATH } from '../vendor/constants.i1PoEnhr.js';
17
+ import '../vendor/index.rJjbcrrp.js';
18
+ import { W as WorkspaceProject } from '../vendor/node.xyYo9ZvH.js';
18
19
  import '@vitest/utils';
19
20
  import { parseErrorStacktrace } from '@vitest/utils/source-map';
20
- import { i as isPrimitive } from '../vendor/base._79unx2z.js';
21
+ import { a as isPrimitive } from '../vendor/base.dzu0Y6Hj.js';
21
22
  import 'std-env';
22
23
  import '@vitest/runner/utils';
23
- import '../vendor/global.L7JRz1qU.js';
24
+ import '../vendor/global.CkGT_TMy.js';
25
+ import 'node:path';
26
+ import 'node:url';
27
+ import 'node:process';
28
+ import 'os';
29
+ import 'path';
30
+ import '../vendor/index.xL8XjTLv.js';
31
+ import 'util';
32
+ import 'fs';
33
+ import 'picocolors';
34
+ import 'vite-node/client';
35
+ import '@vitest/snapshot/manager';
36
+ import 'vite-node/server';
37
+ import '../vendor/coverage.E7sG1b3r.js';
38
+ import '../path.js';
39
+ import 'node:v8';
40
+ import 'node:os';
41
+ import 'node:events';
42
+ import 'tinypool';
43
+ import 'node:worker_threads';
44
+ import 'node:fs/promises';
45
+ import 'node:perf_hooks';
46
+ import 'execa';
47
+ import 'module';
48
+ import 'acorn-walk';
49
+ import '../vendor/reporters.2PaQ2peU.js';
50
+ import './runtime-console.hf2msWA9.js';
51
+ import 'node:stream';
52
+ import 'node:console';
53
+ import '../vendor/date.Ns1pGd_X.js';
54
+ import '../vendor/tasks.IknbGB2n.js';
55
+ import 'node:module';
56
+ import 'local-pkg';
57
+ import 'node:crypto';
58
+ import 'vite-node/utils';
59
+ import 'assert';
60
+ import 'magic-string';
61
+ import '@vitest/utils/ast';
62
+ import 'strip-literal';
63
+ import '../vendor/environments.sU0TD7wX.js';
64
+ import 'node:readline';
65
+ import 'readline';
24
66
 
25
67
  async function getModuleGraph(ctx, id) {
26
68
  const graph = {};
@@ -4657,6 +4699,8 @@ function setup(vitestOrWorkspace, _server) {
4657
4699
  await ctx.rerunFiles(files);
4658
4700
  },
4659
4701
  getConfig() {
4702
+ if (vitestOrWorkspace instanceof WorkspaceProject)
4703
+ return wrapConfig(vitestOrWorkspace.getSerializableConfig());
4660
4704
  return vitestOrWorkspace.config;
4661
4705
  },
4662
4706
  async getTransformResult(id) {
@@ -4686,6 +4730,9 @@ function setup(vitestOrWorkspace, _server) {
4686
4730
  // browser should have a separate RPC in the future, UI doesn't care for provided context
4687
4731
  getProvidedContext() {
4688
4732
  return "ctx" in vitestOrWorkspace ? vitestOrWorkspace.getProvidedContext() : {};
4733
+ },
4734
+ getUnhandledErrors() {
4735
+ return ctx.state.getUnhandledErrors();
4689
4736
  }
4690
4737
  },
4691
4738
  {
@@ -4737,10 +4784,10 @@ class WebSocketReporter {
4737
4784
  (_a = client.onTaskUpdate) == null ? void 0 : _a.call(client, packs);
4738
4785
  });
4739
4786
  }
4740
- onFinished(files) {
4787
+ onFinished(files, errors) {
4741
4788
  this.clients.forEach((client) => {
4742
4789
  var _a;
4743
- (_a = client.onFinished) == null ? void 0 : _a.call(client, files);
4790
+ (_a = client.onFinished) == null ? void 0 : _a.call(client, files, errors);
4744
4791
  });
4745
4792
  }
4746
4793
  onUserConsoleLog(log) {
@@ -4750,5 +4797,12 @@ class WebSocketReporter {
4750
4797
  });
4751
4798
  }
4752
4799
  }
4800
+ function wrapConfig(config) {
4801
+ return {
4802
+ ...config,
4803
+ // workaround RegExp serialization
4804
+ testNamePattern: config.testNamePattern ? config.testNamePattern.toString() : void 0
4805
+ };
4806
+ }
4753
4807
 
4754
4808
  export { setup };
@@ -1,15 +1,15 @@
1
- import { g as globalApis } from '../vendor/constants.WSvnD_fn.js';
2
- import { i as index } from '../vendor/index.IhksUGLR.js';
1
+ import { g as globalApis } from '../vendor/constants.i1PoEnhr.js';
2
+ import { V as VitestIndex } from '../vendor/index.3iX2R_Z5.js';
3
3
  import '@vitest/runner';
4
- import '../vendor/benchmark.WVm6DARl.js';
4
+ import '../vendor/benchmark.IlKmJkUU.js';
5
5
  import '@vitest/runner/utils';
6
6
  import '@vitest/utils';
7
- import '../vendor/index.XU72Rmy8.js';
7
+ import '../vendor/index.rJjbcrrp.js';
8
8
  import 'pathe';
9
9
  import 'std-env';
10
- import '../vendor/global.L7JRz1qU.js';
11
- import '../vendor/run-once.X3E7xx3F.js';
12
- import '../vendor/vi.DTC--YO5.js';
10
+ import '../vendor/global.CkGT_TMy.js';
11
+ import '../vendor/run-once.Olz_Zkd8.js';
12
+ import '../vendor/vi.smj1Ggd4.js';
13
13
  import 'chai';
14
14
  import '../vendor/_commonjsHelpers.jjO7Zipk.js';
15
15
  import '@vitest/expect';
@@ -17,12 +17,13 @@ import '@vitest/snapshot';
17
17
  import '@vitest/utils/error';
18
18
  import '../vendor/tasks.IknbGB2n.js';
19
19
  import '@vitest/utils/source-map';
20
+ import '../vendor/base.dzu0Y6Hj.js';
20
21
  import '../vendor/date.Ns1pGd_X.js';
21
22
  import '@vitest/spy';
22
23
 
23
24
  function registerApiGlobally() {
24
25
  globalApis.forEach((api) => {
25
- globalThis[api] = index[api];
26
+ globalThis[api] = VitestIndex[api];
26
27
  });
27
28
  }
28
29
 
@@ -1,42 +1,44 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { startTests } from '@vitest/runner';
3
- import './vendor/index.XU72Rmy8.js';
4
- import { a as globalExpect, r as resetModules, v as vi } from './vendor/vi.DTC--YO5.js';
5
- import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor/coverage.v6aD8iAh.js';
6
- import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor/index.h0j9y5vy.js';
3
+ import '../vendor/index.rJjbcrrp.js';
4
+ import { a as globalExpect, r as resetModules, v as vi } from '../vendor/vi.smj1Ggd4.js';
5
+ import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '../vendor/coverage.E7sG1b3r.js';
6
+ import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '../vendor/index.D-jOsMas.js';
7
7
  import { createRequire } from 'node:module';
8
8
  import util from 'node:util';
9
9
  import timers from 'node:timers';
10
10
  import { isatty } from 'node:tty';
11
11
  import { installSourcemapsSupport } from 'vite-node/source-map';
12
12
  import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
13
- import { i as index } from './vendor/index.IhksUGLR.js';
14
- import { setupCommonEnv } from './browser.js';
15
- import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
13
+ import { V as VitestIndex } from '../vendor/index.3iX2R_Z5.js';
14
+ import { s as setupCommonEnv } from '../vendor/setup-common.j9IXYrbN.js';
15
+ import { g as getWorkerState } from '../vendor/global.CkGT_TMy.js';
16
16
  import 'pathe';
17
17
  import 'std-env';
18
18
  import '@vitest/runner/utils';
19
19
  import 'chai';
20
- import './vendor/_commonjsHelpers.jjO7Zipk.js';
20
+ import '../vendor/_commonjsHelpers.jjO7Zipk.js';
21
21
  import '@vitest/expect';
22
22
  import '@vitest/snapshot';
23
23
  import '@vitest/utils/error';
24
- import './vendor/tasks.IknbGB2n.js';
24
+ import '../vendor/tasks.IknbGB2n.js';
25
25
  import '@vitest/utils/source-map';
26
- import './vendor/date.Ns1pGd_X.js';
26
+ import '../vendor/base.dzu0Y6Hj.js';
27
+ import '../vendor/date.Ns1pGd_X.js';
27
28
  import '@vitest/spy';
28
29
  import '@vitest/snapshot/environment';
29
- import './paths.js';
30
+ import '../path.js';
30
31
  import 'node:url';
31
- import './vendor/rpc.Bl-ysZIr.js';
32
- import './vendor/benchmark.WVm6DARl.js';
33
- import './vendor/run-once.X3E7xx3F.js';
32
+ import '../vendor/rpc.w4v8oCkK.js';
33
+ import '../vendor/index.cAUulNDf.js';
34
+ import '../vendor/benchmark.IlKmJkUU.js';
35
+ import '../vendor/run-once.Olz_Zkd8.js';
34
36
 
35
37
  let globalSetup = false;
36
38
  async function setupGlobalEnv(config, { environment }) {
37
39
  await setupCommonEnv(config);
38
40
  Object.defineProperty(globalThis, "__vitest_index__", {
39
- value: index,
41
+ value: VitestIndex,
40
42
  enumerable: false
41
43
  });
42
44
  const state = getWorkerState();
@@ -63,10 +65,11 @@ async function setupGlobalEnv(config, { environment }) {
63
65
  installSourcemapsSupport({
64
66
  getSourceMap: (source) => state.moduleCache.getSourceMap(source)
65
67
  });
66
- await setupConsoleLogSpy(state);
68
+ if (!config.disableConsoleIntercept)
69
+ await setupConsoleLogSpy(state);
67
70
  }
68
71
  async function setupConsoleLogSpy(state) {
69
- const { createCustomConsole } = await import('./chunks/runtime-console.hf2msWA9.js');
72
+ const { createCustomConsole } = await import('./runtime-console.hf2msWA9.js');
70
73
  globalThis.console = createCustomConsole(state);
71
74
  }
72
75
  async function withEnv({ environment }, options, fn) {
@@ -96,7 +99,6 @@ async function run(files, config, environment, executor) {
96
99
  return (_a = runner.onCancel) == null ? void 0 : _a.call(runner, reason);
97
100
  });
98
101
  workerState.durations.prepare = performance.now() - workerState.durations.prepare;
99
- workerState.environment = environment.environment;
100
102
  workerState.durations.environment = performance.now();
101
103
  await withEnv(environment, environment.options || config.environmentOptions || {}, async () => {
102
104
  var _a, _b, _c, _d;
@@ -1,7 +1,7 @@
1
1
  import { fileURLToPath } from 'node:url';
2
2
  import c from 'picocolors';
3
3
  import { execa } from 'execa';
4
- import { E as EXIT_CODE_RESTART } from './vendor/constants.WSvnD_fn.js';
4
+ import { E as EXIT_CODE_RESTART } from './vendor/constants.i1PoEnhr.js';
5
5
 
6
6
  const ENTRY = new URL("./cli.js", import.meta.url);
7
7
  const NODE_ARGS = [
package/dist/cli.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { normalize } from 'pathe';
2
2
  import cac from 'cac';
3
3
  import c from 'picocolors';
4
- import { v as version, s as startVitest } from './vendor/node.UBNKMR9Y.js';
5
- import './vendor/index.XU72Rmy8.js';
6
- import { d as divider } from './vendor/reporters.oUR9etwS.js';
7
- import { t as toArray } from './vendor/base._79unx2z.js';
4
+ import { v as version, s as startVitest } from './vendor/node.xyYo9ZvH.js';
5
+ import './vendor/index.rJjbcrrp.js';
6
+ import { d as divider } from './vendor/reporters.2PaQ2peU.js';
7
+ import { t as toArray } from './vendor/base.dzu0Y6Hj.js';
8
8
  import 'vite';
9
9
  import 'node:path';
10
10
  import 'node:url';
11
11
  import 'node:process';
12
12
  import 'node:fs';
13
- import './vendor/constants.WSvnD_fn.js';
13
+ import './vendor/constants.i1PoEnhr.js';
14
14
  import './vendor/_commonjsHelpers.jjO7Zipk.js';
15
15
  import 'os';
16
16
  import 'path';
@@ -19,12 +19,11 @@ import 'util';
19
19
  import 'stream';
20
20
  import 'events';
21
21
  import 'fs';
22
- import 'vite-node/utils';
23
22
  import 'vite-node/client';
24
23
  import '@vitest/snapshot/manager';
25
24
  import 'vite-node/server';
26
- import './vendor/coverage.v6aD8iAh.js';
27
- import './paths.js';
25
+ import './vendor/coverage.E7sG1b3r.js';
26
+ import './path.js';
28
27
  import 'node:v8';
29
28
  import 'node:os';
30
29
  import 'node:events';
@@ -36,29 +35,30 @@ import 'node:fs/promises';
36
35
  import 'node:perf_hooks';
37
36
  import 'execa';
38
37
  import '@vitest/utils/source-map';
39
- import 'node:module';
40
- import 'local-pkg';
41
- import 'std-env';
42
38
  import 'module';
43
39
  import 'acorn-walk';
44
40
  import '@vitest/runner/utils';
41
+ import 'local-pkg';
42
+ import 'std-env';
45
43
  import 'node:crypto';
44
+ import 'vite-node/utils';
46
45
  import 'assert';
47
46
  import 'magic-string';
48
47
  import '@vitest/utils/ast';
49
48
  import 'strip-literal';
50
- import './vendor/environments.QJtma9XQ.js';
49
+ import 'node:module';
50
+ import './vendor/environments.sU0TD7wX.js';
51
51
  import 'node:console';
52
52
  import 'node:readline';
53
53
  import 'readline';
54
- import './vendor/global.L7JRz1qU.js';
54
+ import './vendor/global.CkGT_TMy.js';
55
55
  import './chunks/runtime-console.hf2msWA9.js';
56
56
  import 'node:stream';
57
57
  import './vendor/date.Ns1pGd_X.js';
58
58
  import './vendor/tasks.IknbGB2n.js';
59
59
 
60
60
  const cli = cac("vitest");
61
- cli.version(version).option("-r, --root <path>", "Root path").option("-c, --config <path>", "Path to config file").option("-u, --update", "Update snapshot").option("-w, --watch", "Enable watch mode").option("-t, --testNamePattern <pattern>", "Run tests with full names matching the specified regexp pattern").option("--dir <path>", "Base directory to scan for the test files").option("--ui", "Enable UI").option("--open", "Open UI automatically (default: !process.env.CI))").option("--api [api]", "Serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--silent", "Silent console output from tests").option("--hideSkippedTests", "Hide logs for skipped tests").option("--reporter <name>", "Specify reporters").option("--outputFile <filename/-s>", "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "Enable coverage report").option("--coverage.all", "Whether to include all files, including the untested ones into report", { default: true }).option("--run", "Disable watch mode").option("--mode <name>", "Override Vite mode (default: test)").option("--workspace <path>", "Path to a workspace configuration file").option("--isolate", "Run every test file in isolation. To disable isolation, use --no-isolate (default: true)").option("--globals", "Inject apis globally").option("--dom", "Mock browser API with happy-dom").option("--browser [options]", "Run tests in the browser (default: false)").option("--pool <pool>", "Specify pool, if not running in the browser (default: threads)").option("--poolOptions <options>", "Specify pool options").option("--poolOptions.threads.isolate", "Isolate tests in threads pool (default: true)").option("--poolOptions.forks.isolate", "Isolate tests in forks pool (default: true)").option("--fileParallelism", "Should all test files run in parallel. Use --no-file-parallelism to disable (default: true)").option("--maxWorkers", "Maximum number of workers to run tests in").option("--minWorkers", "Minimum number of workers to run tests in").option("--environment <env>", "Specify runner environment, if not running in the browser (default: node)").option("--passWithNoTests", "Pass when no tests found").option("--logHeapUsage", "Show the size of heap for each test").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order, use --sequence.concurrent to run tests in parallel)").option("--segfaultRetry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--no-color", "Removes colors from the console output").option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").option("--test-timeout <time>", "Default timeout of a test in milliseconds (default: 5000)").option("--bail <number>", "Stop test execution when given number of tests have failed (default: 0)").option("--retry <times>", "Retry the test specific number of times if it fails (default: 0)").option("--diff <path>", "Path to a diff config that will be used to generate diff interface").option("--exclude <glob>", "Additional file globs to be excluded from test").option("--expand-snapshot-diff", "Show full diff when snapshot fails").option("--typecheck [options]", "Custom options for typecheck pool").option("--typecheck.enabled", "Enable typechecking alongside tests (default: false)").option("--typecheck.only", "Run only typecheck tests. This automatically enables typecheck (default: false)").option("--project <name>", "The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: --project=1 --project=2").help();
61
+ cli.version(version).option("-r, --root <path>", "Root path").option("-c, --config <path>", "Path to config file").option("-u, --update", "Update snapshot").option("-w, --watch", "Enable watch mode").option("-t, --testNamePattern <pattern>", "Run tests with full names matching the specified regexp pattern").option("--dir <path>", "Base directory to scan for the test files").option("--ui", "Enable UI").option("--open", "Open UI automatically (default: !process.env.CI))").option("--api [api]", "Serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--silent", "Silent console output from tests").option("--hideSkippedTests", "Hide logs for skipped tests").option("--reporter <name>", "Specify reporters").option("--outputFile <filename/-s>", "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "Enable coverage report").option("--coverage.all", "Whether to include all files, including the untested ones into report", { default: true }).option("--run", "Disable watch mode").option("--mode <name>", "Override Vite mode (default: test)").option("--workspace <path>", "Path to a workspace configuration file").option("--isolate", "Run every test file in isolation. To disable isolation, use --no-isolate (default: true)").option("--globals", "Inject apis globally").option("--dom", "Mock browser API with happy-dom").option("--browser [options]", "Run tests in the browser (default: false)").option("--pool <pool>", "Specify pool, if not running in the browser (default: threads)").option("--poolOptions <options>", "Specify pool options").option("--poolOptions.threads.isolate", "Isolate tests in threads pool (default: true)").option("--poolOptions.forks.isolate", "Isolate tests in forks pool (default: true)").option("--fileParallelism", "Should all test files run in parallel. Use --no-file-parallelism to disable (default: true)").option("--maxWorkers <workers>", "Maximum number of workers to run tests in").option("--minWorkers <workers>", "Minimum number of workers to run tests in").option("--environment <env>", "Specify runner environment, if not running in the browser (default: node)").option("--passWithNoTests", "Pass when no tests found").option("--logHeapUsage", "Show the size of heap for each test").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order, use --sequence.concurrent to run tests in parallel)").option("--segfaultRetry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--no-color", "Removes colors from the console output").option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").option("--test-timeout <time>", "Default timeout of a test in milliseconds (default: 5000)").option("--bail <number>", "Stop test execution when given number of tests have failed (default: 0)").option("--retry <times>", "Retry the test specific number of times if it fails (default: 0)").option("--diff <path>", "Path to a diff config that will be used to generate diff interface").option("--exclude <glob>", "Additional file globs to be excluded from test").option("--expand-snapshot-diff", "Show full diff when snapshot fails").option("--disable-console-intercept", "Disable automatic interception of console logging (default: `false`)").option("--typecheck [options]", "Custom options for typecheck pool").option("--typecheck.enabled", "Enable typechecking alongside tests (default: false)").option("--typecheck.only", "Run only typecheck tests. This automatically enables typecheck (default: false)").option("--project <name>", "The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: --project=1 --project=2").help();
62
62
  cli.command("run [...filters]").action(run);
63
63
  cli.command("related [...filters]").action(runRelated);
64
64
  cli.command("watch [...filters]").action(watch);
package/dist/config.cjs CHANGED
@@ -95,10 +95,20 @@ const config = {
95
95
  include: ["**/*.{test,spec}-d.?(c|m)[jt]s?(x)"],
96
96
  exclude: defaultExclude
97
97
  },
98
- slowTestThreshold: 300
98
+ slowTestThreshold: 300,
99
+ disableConsoleIntercept: false
99
100
  };
100
101
  const configDefaults = Object.freeze(config);
101
102
 
103
+ const extraInlineDeps = [
104
+ /^(?!.*(?:node_modules)).*\.mjs$/,
105
+ /^(?!.*(?:node_modules)).*\.cjs\.js$/,
106
+ // Vite client
107
+ /vite\w*\/dist\/client\/env.mjs/,
108
+ // Nuxt
109
+ "@nuxt/test-utils"
110
+ ];
111
+
102
112
  function defineConfig(config) {
103
113
  return config;
104
114
  }
@@ -120,3 +130,4 @@ exports.defaultInclude = defaultInclude;
120
130
  exports.defineConfig = defineConfig;
121
131
  exports.defineProject = defineProject;
122
132
  exports.defineWorkspace = defineWorkspace;
133
+ exports.extraInlineDeps = extraInlineDeps;
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { UserConfig, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv, UserConfig, mergeConfig } from 'vite';
3
- import { a as ResolvedCoverageOptions, C as CoverageV8Options, P as ProjectConfig } from './reporters-xH8_lESK.js';
3
+ import { a as ResolvedCoverageOptions, C as CoverageV8Options, P as ProjectConfig } from './reporters-trlZlObr.js';
4
4
  import '@vitest/runner';
5
5
  import 'vite-node';
6
6
  import '@vitest/snapshot';
@@ -60,8 +60,11 @@ declare const configDefaults: Readonly<{
60
60
  exclude: string[];
61
61
  };
62
62
  slowTestThreshold: number;
63
+ disableConsoleIntercept: false;
63
64
  }>;
64
65
 
66
+ declare const extraInlineDeps: (string | RegExp)[];
67
+
65
68
  interface UserWorkspaceConfig extends UserConfig {
66
69
  test?: ProjectConfig;
67
70
  }
@@ -82,4 +85,4 @@ type Workspace = (string | (UserProjectConfigExport & {
82
85
  }));
83
86
  declare function defineWorkspace(config: Workspace[]): Workspace[];
84
87
 
85
- export { type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type UserProjectConfigExport, type UserProjectConfigFn, type UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace };
88
+ export { type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type UserProjectConfigExport, type UserProjectConfigFn, type UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace, extraInlineDeps };
package/dist/config.js CHANGED
@@ -93,10 +93,20 @@ const config = {
93
93
  include: ["**/*.{test,spec}-d.?(c|m)[jt]s?(x)"],
94
94
  exclude: defaultExclude
95
95
  },
96
- slowTestThreshold: 300
96
+ slowTestThreshold: 300,
97
+ disableConsoleIntercept: false
97
98
  };
98
99
  const configDefaults = Object.freeze(config);
99
100
 
101
+ const extraInlineDeps = [
102
+ /^(?!.*(?:node_modules)).*\.mjs$/,
103
+ /^(?!.*(?:node_modules)).*\.cjs\.js$/,
104
+ // Vite client
105
+ /vite\w*\/dist\/client\/env.mjs/,
106
+ // Nuxt
107
+ "@nuxt/test-utils"
108
+ ];
109
+
100
110
  function defineConfig(config) {
101
111
  return config;
102
112
  }
@@ -107,4 +117,4 @@ function defineWorkspace(config) {
107
117
  return config;
108
118
  }
109
119
 
110
- export { configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace };
120
+ export { configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace, extraInlineDeps };
@@ -1,4 +1,4 @@
1
- import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-xH8_lESK.js';
1
+ import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-trlZlObr.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
@@ -1,4 +1,4 @@
1
- import { E as Environment } from './reporters-xH8_lESK.js';
1
+ import { E as Environment } from './reporters-trlZlObr.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
@@ -1,2 +1,2 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './vendor/environments.QJtma9XQ.js';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './vendor/environments.sU0TD7wX.js';
2
2
  import 'node:console';
package/dist/execute.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import vm from 'node:vm';
2
2
  import { ViteNodeRunner } from 'vite-node/client';
3
3
  import { ViteNodeRunnerOptions } from 'vite-node';
4
- import { am as PendingSuiteMock, an as MockFactory, ao as MockMap, a2 as WorkerGlobalState, g as RuntimeRPC } from './reporters-xH8_lESK.js';
4
+ import { ap as PendingSuiteMock, aq as MockFactory, h as RuntimeRPC, r as WorkerGlobalState, ar as MockMap } from './reporters-trlZlObr.js';
5
5
  import 'vite';
6
6
  import '@vitest/runner';
7
7
  import '@vitest/snapshot';
@@ -87,10 +87,13 @@ declare class FileMap {
87
87
  readBuffer(path: string): Buffer;
88
88
  }
89
89
 
90
- interface ExternalModulesExecutorOptions extends ExecuteOptions {
90
+ interface ExternalModulesExecutorOptions {
91
91
  context: vm.Context;
92
92
  fileMap: FileMap;
93
93
  packageCache: Map<string, any>;
94
+ transform: RuntimeRPC['transform'];
95
+ interopDefault?: boolean;
96
+ viteClientModule: Record<string, unknown>;
94
97
  }
95
98
  declare class ExternalModulesExecutor {
96
99
  private options;
@@ -116,11 +119,10 @@ declare class ExternalModulesExecutor {
116
119
 
117
120
  interface ExecuteOptions extends ViteNodeRunnerOptions {
118
121
  mockMap: MockMap;
119
- packageCache: Map<string, string>;
120
122
  moduleDirectories?: string[];
121
- context?: vm.Context;
122
123
  state: WorkerGlobalState;
123
- transform: RuntimeRPC['transform'];
124
+ context?: vm.Context;
125
+ externalModulesExecutor?: ExternalModulesExecutor;
124
126
  }
125
127
  declare class VitestExecutor extends ViteNodeRunner {
126
128
  options: ExecuteOptions;
@@ -133,7 +135,7 @@ declare class VitestExecutor extends ViteNodeRunner {
133
135
  Reflect: typeof Reflect;
134
136
  Symbol: SymbolConstructor;
135
137
  };
136
- get state(): any;
138
+ get state(): WorkerGlobalState;
137
139
  shouldResolveId(id: string, _importee?: string | undefined): boolean;
138
140
  originalResolveUrl(id: string, importer?: string): Promise<[url: string, fsPath: string]>;
139
141
  resolveUrl(id: string, importer?: string): Promise<[string, string]>;
package/dist/execute.js CHANGED
@@ -1,14 +1,11 @@
1
- export { V as VitestExecutor } from './vendor/execute.cedv4NLQ.js';
2
- import 'node:url';
1
+ export { V as VitestExecutor } from './vendor/execute.3_hyGknJ.js';
3
2
  import 'node:vm';
3
+ import 'node:url';
4
4
  import 'vite-node/client';
5
5
  import 'vite-node/utils';
6
6
  import 'pathe';
7
7
  import '@vitest/utils/error';
8
- import './paths.js';
8
+ import './path.js';
9
9
  import 'node:fs';
10
10
  import '@vitest/utils';
11
- import './vendor/base._79unx2z.js';
12
- import 'node:path';
13
- import 'node:module';
14
- import 'vite-node/constants';
11
+ import './vendor/base.dzu0Y6Hj.js';
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { TaskPopulated, File, TaskResultPack, CancelReason } from '@vitest/runner';
2
2
  export { Custom, DoneCallback, ExtendedContext, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskContext, TaskCustomOptions, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
3
- export { b as bench } from './suite-GoqTeX8s.js';
3
+ export { b as bench } from './suite-6Pt_ep5V.js';
4
4
  import { ExpectStatic } from '@vitest/expect';
5
5
  export { Assertion, AsymmetricMatchersContaining, ExpectStatic, JestAssertion } from '@vitest/expect';
6
- import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper, n as RuntimeConfig, f as ProvidedContext, A as AfterSuiteRunMeta, o as UserConsoleLog, R as ResolvedConfig, p as ModuleGraphData, q as Reporter } from './reporters-xH8_lESK.js';
7
- export { K as ApiConfig, a6 as ArgumentsType, a5 as Arrayable, a3 as Awaitable, B as BaseCoverageOptions, ak as BenchFunction, ai as Benchmark, al as BenchmarkAPI, aj as BenchmarkResult, ah as BenchmarkUserOptions, D as BuiltinEnvironment, I as CSSModuleScopeStrategy, u as CollectLineNumbers, v as CollectLines, a8 as Constructable, x as Context, _ as ContextRPC, Y as ContextTestEnvironment, af as CoverageIstanbulOptions, b as CoverageOptions, c as CoverageProvider, d as CoverageProviderModule, ae as CoverageReporter, C as CoverageV8Options, ag as CustomProviderOptions, N as DepsOptimizationOptions, E as Environment, L as EnvironmentOptions, aa as EnvironmentReturn, H as HappyDOMOptions, Q as InlineConfig, J as JSDOMOptions, a9 as ModuleCache, a7 as MutableArray, a4 as Nullable, ac as OnServerRestartHandler, y as Pool, z as PoolOptions, P as ProjectConfig, r as RawErrsMap, ad as ReportContext, a0 as ResolveIdFunction, a as ResolvedCoverageOptions, Z as ResolvedTestEnvironment, w as RootAndTarget, X as RunnerRPC, g as RuntimeRPC, O as TransformModePatterns, t as TscErrorInfo, S as TypecheckConfig, U as UserConfig, e as Vitest, G as VitestEnvironment, V as VitestRunMode, ab as VmEnvironmentReturn, $ as WorkerContext, a2 as WorkerGlobalState, a1 as WorkerRPC } from './reporters-xH8_lESK.js';
6
+ import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper, u as RuntimeConfig, g as ProvidedContext, A as AfterSuiteRunMeta, v as UserConsoleLog, R as ResolvedConfig, w as ModuleGraphData, x as Reporter } from './reporters-trlZlObr.js';
7
+ export { X as ApiConfig, a9 as ArgumentsType, a8 as Arrayable, a6 as Awaitable, B as BaseCoverageOptions, an as BenchFunction, al as Benchmark, ao as BenchmarkAPI, am as BenchmarkResult, ak as BenchmarkUserOptions, O as BuiltinEnvironment, S as CSSModuleScopeStrategy, D as CollectLineNumbers, G as CollectLines, ab as Constructable, I as Context, q as ContextRPC, a2 as ContextTestEnvironment, ai as CoverageIstanbulOptions, b as CoverageOptions, c as CoverageProvider, d as CoverageProviderModule, ah as CoverageReporter, C as CoverageV8Options, aj as CustomProviderOptions, Z as DepsOptimizationOptions, E as Environment, Y as EnvironmentOptions, ad as EnvironmentReturn, N as HappyDOMOptions, $ as InlineConfig, L as JSDOMOptions, ac as ModuleCache, aa as MutableArray, a7 as Nullable, af as OnServerRestartHandler, J as Pool, K as PoolOptions, P as ProjectConfig, y as RawErrsMap, ag as ReportContext, a4 as ResolveIdFunction, a as ResolvedCoverageOptions, a3 as ResolvedTestEnvironment, H as RootAndTarget, a1 as RunnerRPC, h as RuntimeRPC, _ as TransformModePatterns, z as TscErrorInfo, a0 as TypecheckConfig, U as UserConfig, f as Vitest, Q as VitestEnvironment, V as VitestRunMode, ae as VmEnvironmentReturn, t as WorkerContext, r as WorkerGlobalState, a5 as WorkerRPC } from './reporters-trlZlObr.js';
8
8
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
9
9
  export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy';
10
10
  export { SnapshotEnvironment } from '@vitest/snapshot/environment';
@@ -705,6 +705,7 @@ interface WebSocketHandlers {
705
705
  rerun(files: string[]): Promise<void>;
706
706
  updateSnapshot(file?: File): Promise<void>;
707
707
  getProvidedContext(): ProvidedContext;
708
+ getUnhandledErrors(): unknown[];
708
709
  }
709
710
  interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected'> {
710
711
  onCancel(reason: CancelReason): void;
package/dist/index.js CHANGED
@@ -1,24 +1,25 @@
1
1
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
2
- export { b as bench } from './vendor/benchmark.WVm6DARl.js';
3
- export { i as isFirstRun, r as runOnce } from './vendor/run-once.X3E7xx3F.js';
4
- export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.DTC--YO5.js';
5
- import { d as dist } from './vendor/index.IhksUGLR.js';
6
- export { c as assertType, g as getRunningMode, a as inject, b as isWatchMode } from './vendor/index.IhksUGLR.js';
2
+ export { b as bench } from './vendor/benchmark.IlKmJkUU.js';
3
+ export { i as isFirstRun, a as runOnce } from './vendor/run-once.Olz_Zkd8.js';
4
+ export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.smj1Ggd4.js';
5
+ import { d as dist } from './vendor/index.3iX2R_Z5.js';
6
+ export { b as assertType, g as getRunningMode, i as inject, a as isWatchMode } from './vendor/index.3iX2R_Z5.js';
7
7
  import * as chai from 'chai';
8
8
  export { chai };
9
9
  export { assert, should } from 'chai';
10
10
  import '@vitest/runner/utils';
11
11
  import '@vitest/utils';
12
- import './vendor/index.XU72Rmy8.js';
12
+ import './vendor/index.rJjbcrrp.js';
13
13
  import 'pathe';
14
14
  import 'std-env';
15
- import './vendor/global.L7JRz1qU.js';
15
+ import './vendor/global.CkGT_TMy.js';
16
16
  import './vendor/_commonjsHelpers.jjO7Zipk.js';
17
17
  import '@vitest/expect';
18
18
  import '@vitest/snapshot';
19
19
  import '@vitest/utils/error';
20
20
  import './vendor/tasks.IknbGB2n.js';
21
21
  import '@vitest/utils/source-map';
22
+ import './vendor/base.dzu0Y6Hj.js';
22
23
  import './vendor/date.Ns1pGd_X.js';
23
24
  import '@vitest/spy';
24
25
 
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { V as VitestRunMode, U as UserConfig, e as Vitest, R as ResolvedConfig, f as ProvidedContext, W as WorkspaceProject, g as RuntimeRPC, T as TestSequencer, h as WorkspaceSpec } from './reporters-xH8_lESK.js';
2
- export { l as BrowserProvider, k as BrowserProviderInitializationOptions, m as BrowserProviderOptions, i as ProcessPool, j as TestSequencerConstructor, s as startVitest } from './reporters-xH8_lESK.js';
1
+ import { V as VitestRunMode, U as UserConfig, e as VitestOptions, f as Vitest, R as ResolvedConfig, g as ProvidedContext, W as WorkspaceProject, h as RuntimeRPC, T as TestSequencer, i as WorkspaceSpec } from './reporters-trlZlObr.js';
2
+ export { n as BrowserProvider, m as BrowserProviderInitializationOptions, o as BrowserProviderOptions, j as ProcessPool, l as TestSequencerConstructor, k as VitestPackageInstaller, s as startVitest } from './reporters-trlZlObr.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
4
  import '@vitest/runner';
5
5
  import 'vite-node';
@@ -15,7 +15,7 @@ import 'node:worker_threads';
15
15
  import 'node:fs';
16
16
  import 'chai';
17
17
 
18
- declare function createVitest(mode: VitestRunMode, options: UserConfig, viteOverrides?: UserConfig$1): Promise<Vitest>;
18
+ declare function createVitest(mode: VitestRunMode, options: UserConfig, viteOverrides?: UserConfig$1, vitestOptions?: VitestOptions): Promise<Vitest>;
19
19
 
20
20
  declare function VitestPlugin(options?: UserConfig, ctx?: Vitest): Promise<Plugin[]>;
21
21