vitest 1.1.3 → 1.2.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 (63) 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.omeaEsoT.js} +60 -6
  4. package/dist/chunks/{integrations-globals.tnKXwyh5.js → integrations-globals.9QpVy4UR.js} +9 -8
  5. package/dist/chunks/{runtime-console.hf2msWA9.js → runtime-console.Iloo9fIt.js} +2 -2
  6. package/dist/{entry.js → chunks/runtime-runBaseTests.S8ZSFig3.js} +20 -18
  7. package/dist/cli-wrapper.js +1 -1
  8. package/dist/cli.js +15 -15
  9. package/dist/config.cjs +12 -1
  10. package/dist/config.d.ts +1 -71
  11. package/dist/config.js +12 -2
  12. package/dist/coverage.d.ts +1 -1
  13. package/dist/environments.d.ts +1 -1
  14. package/dist/environments.js +1 -1
  15. package/dist/execute.d.ts +8 -6
  16. package/dist/execute.js +4 -7
  17. package/dist/index.d.ts +4 -4
  18. package/dist/index.js +8 -7
  19. package/dist/node.d.ts +3 -3
  20. package/dist/node.js +13 -13
  21. package/dist/{reporters-qc5Smpt5.d.ts → reporters-rzC174PQ.d.ts} +188 -29
  22. package/dist/reporters.d.ts +1 -1
  23. package/dist/reporters.js +5 -5
  24. package/dist/runners.d.ts +1 -1
  25. package/dist/runners.js +7 -5
  26. package/dist/{suite-WwpgKT7k.d.ts → suite-MFRDkZcV.d.ts} +1 -1
  27. package/dist/suite.d.ts +2 -2
  28. package/dist/suite.js +3 -3
  29. package/dist/vendor/base.4sEqnqgY.js +38 -0
  30. package/dist/vendor/{base._79unx2z.js → base.QYERqzkH.js} +10 -1
  31. package/dist/vendor/{benchmark.WVm6DARl.js → benchmark.IlKmJkUU.js} +1 -1
  32. package/dist/vendor/{constants.WSvnD_fn.js → constants.i1PoEnhr.js} +9 -1
  33. package/dist/vendor/{coverage.v6aD8iAh.js → coverage.E7sG1b3r.js} +1 -1
  34. package/dist/vendor/{environments.QJtma9XQ.js → environments.sU0TD7wX.js} +19 -7
  35. package/dist/vendor/execute.edwByI27.js +589 -0
  36. package/dist/vendor/{global.L7JRz1qU.js → global.CkGT_TMy.js} +10 -1
  37. package/dist/vendor/{index.h0j9y5vy.js → index.kwCLJK4i.js} +5 -5
  38. package/dist/vendor/{index.XU72Rmy8.js → index.rJjbcrrp.js} +1 -1
  39. package/dist/vendor/{index.IhksUGLR.js → index.vs_-lzuF.js} +6 -6
  40. package/dist/vendor/{node.wTZytysZ.js → node.p6h5JSuL.js} +694 -286
  41. package/dist/vendor/{reporters.7Y4WN6gc.js → reporters.cA9x-5v-.js} +8 -5
  42. package/dist/vendor/{rpc.Bl-ysZIr.js → rpc.w4v8oCkK.js} +23 -2
  43. package/dist/vendor/{run-once.X3E7xx3F.js → run-once.Olz_Zkd8.js} +2 -2
  44. package/dist/vendor/setup-common.4GIL70qB.js +29 -0
  45. package/dist/vendor/utils.GbToHGHI.js +41 -0
  46. package/dist/vendor/{vi.DTC--YO5.js → vi.Bw2UL9c9.js} +21 -8
  47. package/dist/vendor/vm.9N6CwTZh.js +696 -0
  48. package/dist/worker.js +109 -82
  49. package/dist/workers/forks.js +33 -0
  50. package/dist/{entry-vm.js → workers/runVmTests.js} +20 -16
  51. package/dist/workers/threads.js +26 -0
  52. package/dist/workers/vmForks.js +43 -0
  53. package/dist/workers/vmThreads.js +36 -0
  54. package/dist/workers.d.ts +36 -0
  55. package/dist/workers.js +30 -0
  56. package/package.json +12 -8
  57. package/workers.d.ts +1 -0
  58. package/dist/child.js +0 -125
  59. package/dist/vendor/execute.cedv4NLQ.js +0 -1235
  60. package/dist/vendor/inspector.lFAeuaAt.js +0 -26
  61. package/dist/vendor/loader.L9CYwKn1.js +0 -39
  62. package/dist/vm.js +0 -126
  63. /package/dist/{paths.js → path.js} +0 -0
package/dist/runners.js CHANGED
@@ -1,22 +1,24 @@
1
1
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
2
- import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.DTC--YO5.js';
3
- import './vendor/index.XU72Rmy8.js';
4
- import { a as rpc } from './vendor/rpc.Bl-ysZIr.js';
2
+ import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.Bw2UL9c9.js';
3
+ import './vendor/index.rJjbcrrp.js';
4
+ import { r as rpc } from './vendor/rpc.w4v8oCkK.js';
5
5
  import { g as getFullName } from './vendor/tasks.IknbGB2n.js';
6
- import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
6
+ import { g as getWorkerState } from './vendor/global.CkGT_TMy.js';
7
7
  import { getTests, getNames } from '@vitest/runner/utils';
8
8
  import { updateTask } from '@vitest/runner';
9
9
  import { createDefer, getSafeTimers } from '@vitest/utils';
10
- import { a as getBenchOptions, g as getBenchFn } from './vendor/benchmark.WVm6DARl.js';
10
+ import { a as getBenchOptions, g as getBenchFn } from './vendor/benchmark.IlKmJkUU.js';
11
11
  import 'chai';
12
12
  import './vendor/_commonjsHelpers.jjO7Zipk.js';
13
13
  import '@vitest/snapshot';
14
14
  import '@vitest/utils/error';
15
15
  import '@vitest/utils/source-map';
16
+ import './vendor/base.QYERqzkH.js';
16
17
  import './vendor/date.Ns1pGd_X.js';
17
18
  import '@vitest/spy';
18
19
  import 'pathe';
19
20
  import 'std-env';
21
+ import './vendor/index.cAUulNDf.js';
20
22
 
21
23
  class VitestTestRunner {
22
24
  constructor(config) {
@@ -1,6 +1,6 @@
1
1
  import { Custom } from '@vitest/runner';
2
2
  import '@vitest/runner/utils';
3
- import { ak as BenchFunction, al as BenchmarkAPI } from './reporters-qc5Smpt5.js';
3
+ import { ao as BenchFunction, ap as BenchmarkAPI } from './reporters-rzC174PQ.js';
4
4
  import { Options } from 'tinybench';
5
5
 
6
6
  declare function getBenchOptions(key: Custom): Options;
package/dist/suite.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { createTaskCollector, getCurrentSuite, getFn, setFn } from '@vitest/runner';
2
2
  export { createChainable } from '@vitest/runner/utils';
3
- export { g as getBenchFn, a as getBenchOptions } from './suite-WwpgKT7k.js';
4
- import './reporters-qc5Smpt5.js';
3
+ export { g as getBenchFn, a as getBenchOptions } from './suite-MFRDkZcV.js';
4
+ import './reporters-rzC174PQ.js';
5
5
  import 'vite';
6
6
  import 'vite-node';
7
7
  import '@vitest/snapshot';
package/dist/suite.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { createTaskCollector, getCurrentSuite, getFn, setFn } from '@vitest/runner';
2
2
  export { createChainable } from '@vitest/runner/utils';
3
- export { g as getBenchFn, a as getBenchOptions } from './vendor/benchmark.WVm6DARl.js';
3
+ export { g as getBenchFn, a as getBenchOptions } from './vendor/benchmark.IlKmJkUU.js';
4
4
  import '@vitest/utils';
5
- import './vendor/index.XU72Rmy8.js';
5
+ import './vendor/index.rJjbcrrp.js';
6
6
  import 'pathe';
7
7
  import 'std-env';
8
- import './vendor/global.L7JRz1qU.js';
8
+ import './vendor/global.CkGT_TMy.js';
@@ -0,0 +1,38 @@
1
+ import { ModuleCacheMap } from 'vite-node/client';
2
+ import { p as provideWorkerState } from './global.CkGT_TMy.js';
3
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.edwByI27.js';
4
+
5
+ let _viteNode;
6
+ const moduleCache = new ModuleCacheMap();
7
+ const mockMap = /* @__PURE__ */ new Map();
8
+ async function startViteNode(options) {
9
+ if (_viteNode)
10
+ return _viteNode;
11
+ _viteNode = await startVitestExecutor(options);
12
+ return _viteNode;
13
+ }
14
+ async function runBaseTests(state) {
15
+ const { ctx } = state;
16
+ state.moduleCache = moduleCache;
17
+ state.mockMap = mockMap;
18
+ provideWorkerState(globalThis, state);
19
+ if (ctx.invalidates) {
20
+ ctx.invalidates.forEach((fsPath) => {
21
+ moduleCache.delete(fsPath);
22
+ moduleCache.delete(`mock:${fsPath}`);
23
+ });
24
+ }
25
+ ctx.files.forEach((i) => state.moduleCache.delete(i));
26
+ const [executor, { run }] = await Promise.all([
27
+ startViteNode({ state, requestStubs: getDefaultRequestStubs() }),
28
+ import('../chunks/runtime-runBaseTests.S8ZSFig3.js')
29
+ ]);
30
+ await run(
31
+ ctx.files,
32
+ ctx.config,
33
+ { environment: state.environment, options: ctx.environment.options },
34
+ executor
35
+ );
36
+ }
37
+
38
+ export { runBaseTests as r };
@@ -92,5 +92,14 @@ class AggregateErrorPonyfill extends Error {
92
92
  this.errors = [...errors];
93
93
  }
94
94
  }
95
+ function isChildProcess() {
96
+ return typeof process !== "undefined" && !!process.send;
97
+ }
98
+ function setProcessTitle(title) {
99
+ try {
100
+ process.title = `node (${title})`;
101
+ } catch {
102
+ }
103
+ }
95
104
 
96
- export { AggregateErrorPonyfill as A, stdout as a, getAllMockableProperties as b, deepMerge as d, groupBy as g, isPrimitive as i, noop as n, slash as s, toArray as t };
105
+ export { AggregateErrorPonyfill as A, isPrimitive as a, slash as b, stdout as c, deepMerge as d, getAllMockableProperties as e, groupBy as g, isChildProcess as i, noop as n, setProcessTitle as s, toArray as t };
@@ -1,7 +1,7 @@
1
1
  import { getCurrentSuite } from '@vitest/runner';
2
2
  import { createChainable } from '@vitest/runner/utils';
3
3
  import { noop } from '@vitest/utils';
4
- import { i as isRunningInBenchmark } from './index.XU72Rmy8.js';
4
+ import { i as isRunningInBenchmark } from './index.rJjbcrrp.js';
5
5
 
6
6
  const benchFns = /* @__PURE__ */ new WeakMap();
7
7
  const benchOptsMap = /* @__PURE__ */ new WeakMap();
@@ -2,6 +2,14 @@ const defaultPort = 51204;
2
2
  const defaultBrowserPort = 63315;
3
3
  const EXIT_CODE_RESTART = 43;
4
4
  const API_PATH = "/__vitest_api__";
5
+ const extraInlineDeps = [
6
+ /^(?!.*(?:node_modules)).*\.mjs$/,
7
+ /^(?!.*(?:node_modules)).*\.cjs\.js$/,
8
+ // Vite client
9
+ /vite\w*\/dist\/client\/env.mjs/,
10
+ // Nuxt
11
+ "@nuxt/test-utils"
12
+ ];
5
13
  const CONFIG_NAMES = [
6
14
  "vitest.config",
7
15
  "vite.config"
@@ -51,4 +59,4 @@ const globalApis = [
51
59
  "afterEach"
52
60
  ];
53
61
 
54
- export { API_PATH as A, CONFIG_NAMES as C, EXIT_CODE_RESTART as E, defaultBrowserPort as a, configFiles as c, defaultPort as d, globalApis as g, workspacesFiles as w };
62
+ export { API_PATH as A, CONFIG_NAMES as C, EXIT_CODE_RESTART as E, defaultBrowserPort as a, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
@@ -50,4 +50,4 @@ async function stopCoverageInsideWorker(options, loader) {
50
50
  return null;
51
51
  }
52
52
 
53
- export { CoverageProviderMap as C, stopCoverageInsideWorker as a, getCoverageProvider as g, startCoverageInsideWorker as s, takeCoverageInsideWorker as t };
53
+ export { CoverageProviderMap as C, startCoverageInsideWorker as a, getCoverageProvider as g, stopCoverageInsideWorker as s, takeCoverageInsideWorker as t };
@@ -28,8 +28,8 @@ var node = {
28
28
  // this is largely copied from jest's node environment
29
29
  async setupVM() {
30
30
  const vm = await import('node:vm');
31
- const context = vm.createContext();
32
- const global = vm.runInContext(
31
+ let context = vm.createContext();
32
+ let global = vm.runInContext(
33
33
  "this",
34
34
  context
35
35
  );
@@ -85,6 +85,8 @@ var node = {
85
85
  return context;
86
86
  },
87
87
  teardown() {
88
+ context = void 0;
89
+ global = void 0;
88
90
  }
89
91
  };
90
92
  },
@@ -453,7 +455,7 @@ var jsdom = {
453
455
  cookieJar = false,
454
456
  ...restOptions
455
457
  } = jsdom;
456
- const dom = new JSDOM(
458
+ let dom = new JSDOM(
457
459
  html,
458
460
  {
459
461
  pretendToBeVisual,
@@ -493,6 +495,7 @@ var jsdom = {
493
495
  teardown() {
494
496
  clearWindowErrors();
495
497
  dom.window.close();
498
+ dom = void 0;
496
499
  }
497
500
  };
498
501
  },
@@ -544,12 +547,20 @@ var jsdom = {
544
547
  }
545
548
  };
546
549
 
550
+ async function teardownWindow(win) {
551
+ if (win.close && win.happyDOM.abort) {
552
+ await win.happyDOM.abort();
553
+ win.close();
554
+ } else {
555
+ win.happyDOM.cancelAsync();
556
+ }
557
+ }
547
558
  var happy = {
548
559
  name: "happy-dom",
549
560
  transformMode: "web",
550
561
  async setupVM({ happyDOM = {} }) {
551
562
  const { Window } = await import('happy-dom');
552
- const win = new Window({
563
+ let win = new Window({
553
564
  ...happyDOM,
554
565
  console: console && globalThis.console ? globalThis.console : void 0,
555
566
  url: happyDOM.url || "http://localhost:3000",
@@ -566,7 +577,8 @@ var happy = {
566
577
  return win;
567
578
  },
568
579
  async teardown() {
569
- await win.happyDOM.cancelAsync();
580
+ await teardownWindow(win);
581
+ win = void 0;
570
582
  }
571
583
  };
572
584
  },
@@ -587,8 +599,8 @@ var happy = {
587
599
  additionalKeys: ["Request", "Response"]
588
600
  });
589
601
  return {
590
- teardown(global2) {
591
- win.happyDOM.cancelAsync();
602
+ async teardown(global2) {
603
+ await teardownWindow(win);
592
604
  keys.forEach((key) => delete global2[key]);
593
605
  originals.forEach((v, k) => global2[k] = v);
594
606
  }