vitest 2.1.3 → 2.1.4

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 (74) hide show
  1. package/LICENSE.md +1 -209
  2. package/dist/browser.d.ts +21 -21
  3. package/dist/browser.js +7 -7
  4. package/dist/chunks/{RandomSequencer.Bh5-tlNJ.js → RandomSequencer.CMRlh2v4.js} +143 -142
  5. package/dist/chunks/{base.BO5Jx7vw.js → base.C3xNdjV6.js} +3 -3
  6. package/dist/chunks/{benchmark.C8CRJYG4.js → benchmark.Cdu9hjj4.js} +2 -2
  7. package/dist/chunks/{benchmark.JVlTzojj.d.ts → benchmark.geERunq4.d.ts} +1 -1
  8. package/dist/chunks/{cac.BSMVokHR.js → cac.DrfPaMvZ.js} +11 -10
  9. package/dist/chunks/{cli-api.btGgw3PC.js → cli-api.CKrRYkw8.js} +732 -577
  10. package/dist/chunks/{console.CfT1Wjed.js → console.BYGVloWk.js} +2 -6
  11. package/dist/chunks/{coverage.zlNdAMHK.js → coverage.BoMDb1ip.js} +1 -1
  12. package/dist/chunks/{creator.CBPphXqR.js → creator.IIqd8RWT.js} +8 -8
  13. package/dist/chunks/{execute._eQQfgI8.js → execute.2pr0rHgK.js} +8 -6
  14. package/dist/chunks/{globals.Bdzt04Qm.js → globals.Bp645TTJ.js} +8 -13
  15. package/dist/chunks/{index.BpSiYbpB.js → index.68735LiX.js} +28 -5
  16. package/dist/chunks/{index.X0nbfr6-.js → index.BJDntFik.js} +7 -7
  17. package/dist/chunks/{index.Dz2opmmU.js → index.Bn81VaWg.js} +3808 -3787
  18. package/dist/chunks/{index.CPD77dLA.js → index.CqYx2Nsr.js} +7 -7
  19. package/dist/chunks/{index.4GFF2h22.js → index.D3d79vc8.js} +6 -6
  20. package/dist/chunks/index.Dqe5k2Rk.js +54 -0
  21. package/dist/chunks/{node.Bx4JZjMG.js → node.AKq966Jp.js} +1 -5
  22. package/dist/chunks/{reporters.C4ZHgdxQ.d.ts → reporters.anwo7Y6a.d.ts} +1328 -1313
  23. package/dist/chunks/{resolveConfig.Dha6ilPI.js → resolveConfig.DPmbhVlP.js} +3193 -3175
  24. package/dist/chunks/{rpc.B7Mfb-Yf.js → rpc.C3q9uwRX.js} +2 -2
  25. package/dist/chunks/{run-once.Sxe67Wng.js → run-once.2ogXb3JV.js} +1 -1
  26. package/dist/chunks/{runBaseTests.Cx4wXyTR.js → runBaseTests.Dm-659zB.js} +21 -25
  27. package/dist/chunks/{setup-common.BKyF15v_.js → setup-common.DDmVKp6O.js} +3 -3
  28. package/dist/chunks/{suite.BMWOKiTe.d.ts → suite.B2jumIFP.d.ts} +2 -2
  29. package/dist/chunks/{utils.CY6Spixo.js → utils.BB4zjzR8.js} +2 -2
  30. package/dist/chunks/utils.C8RiOc4B.js +77 -0
  31. package/dist/chunks/{vi.BskyZC5g.js → vi.JMQoNY_Z.js} +94 -141
  32. package/dist/chunks/{vite.YH7MrecS.d.ts → vite.BdBj-UWY.d.ts} +1 -1
  33. package/dist/chunks/{vm.DB_hLchi.js → vm.jpyrB0xy.js} +5 -8
  34. package/dist/chunks/{worker.B6RjTtbk.d.ts → worker.BAlI9hII.d.ts} +12 -3
  35. package/dist/chunks/{worker.CcJLfX8w.d.ts → worker.DHnGaO2M.d.ts} +1 -1
  36. package/dist/cli.js +3 -4
  37. package/dist/config.cjs +4 -4
  38. package/dist/config.d.ts +10 -10
  39. package/dist/config.js +4 -4
  40. package/dist/coverage.d.ts +9 -9
  41. package/dist/coverage.js +8 -11
  42. package/dist/environments.d.ts +2 -2
  43. package/dist/environments.js +1 -1
  44. package/dist/execute.d.ts +53 -53
  45. package/dist/execute.js +7 -6
  46. package/dist/index.d.ts +75 -1099
  47. package/dist/index.js +7 -18
  48. package/dist/node.d.ts +43 -41
  49. package/dist/node.js +22 -28
  50. package/dist/path.js +1 -1
  51. package/dist/reporters.d.ts +10 -10
  52. package/dist/reporters.js +12 -18
  53. package/dist/runners.d.ts +12 -19
  54. package/dist/runners.js +142 -148
  55. package/dist/snapshot.js +2 -6
  56. package/dist/suite.d.ts +2 -2
  57. package/dist/suite.js +2 -6
  58. package/dist/worker.js +5 -6
  59. package/dist/workers/forks.js +9 -8
  60. package/dist/workers/runVmTests.js +16 -20
  61. package/dist/workers/threads.js +9 -8
  62. package/dist/workers/vmForks.js +9 -12
  63. package/dist/workers/vmThreads.js +9 -12
  64. package/dist/workers.d.ts +13 -13
  65. package/dist/workers.js +14 -18
  66. package/package.json +26 -26
  67. package/dist/chunks/base.DwXGwWst.js +0 -89
  68. package/dist/chunks/env.CmHVDJnw.js +0 -7
  69. package/dist/chunks/index.-d_XpZEA.js +0 -140
  70. package/dist/chunks/index.CxRxs566.js +0 -23
  71. package/dist/chunks/tasks.BZnCS9aT.js +0 -18
  72. package/dist/chunks/utils.Ck2hJTRs.js +0 -23
  73. package/dist/chunks/{environment.CzISCQ7o.d.ts → environment.LoooBwUu.d.ts} +24 -24
  74. package/dist/chunks/{index.lVXYBqEP.js → index.BMoXz_-n.js} +186 -186
@@ -1,14 +1,10 @@
1
- import { Writable } from 'node:stream';
2
1
  import { Console } from 'node:console';
3
2
  import { relative } from 'node:path';
3
+ import { Writable } from 'node:stream';
4
4
  import { getSafeTimers } from '@vitest/utils';
5
5
  import c from 'tinyrainbow';
6
6
  import { R as RealDate } from './date.W2xKR2qe.js';
7
- import 'pathe';
8
- import '@vitest/runner/utils';
9
- import { g as getWorkerState } from './utils.Ck2hJTRs.js';
10
- import './env.CmHVDJnw.js';
11
- import 'std-env';
7
+ import { g as getWorkerState } from './utils.C8RiOc4B.js';
12
8
 
13
9
  const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
14
10
  function getTaskIdByStack(root) {
@@ -65,4 +65,4 @@ async function stopCoverageInsideWorker(options, loader) {
65
65
  return null;
66
66
  }
67
67
 
68
- export { CoverageProviderMap as C, startCoverageInsideWorker as a, getCoverageProvider as g, stopCoverageInsideWorker as s, takeCoverageInsideWorker as t };
68
+ export { CoverageProviderMap as C, stopCoverageInsideWorker as a, getCoverageProvider as g, startCoverageInsideWorker as s, takeCoverageInsideWorker as t };
@@ -1,19 +1,19 @@
1
- import { resolve, dirname, relative } from 'node:path';
2
1
  import { existsSync, writeFileSync, readFileSync } from 'node:fs';
3
2
  import { mkdir, writeFile } from 'node:fs/promises';
4
- import { p as prompt, f as findUp } from './index.X0nbfr6-.js';
5
- import c from 'tinyrainbow';
6
- import { detectPackageManager, installPackage } from './index.CPD77dLA.js';
3
+ import { resolve, dirname, relative } from 'node:path';
4
+ import { detectPackageManager, installPackage } from './index.CqYx2Nsr.js';
5
+ import { p as prompt, f as findUp } from './index.BJDntFik.js';
7
6
  import { x } from 'tinyexec';
7
+ import c from 'tinyrainbow';
8
8
  import { c as configFiles } from './constants.fzPh7AOq.js';
9
- import 'node:url';
9
+ import 'process';
10
10
  import 'node:process';
11
+ import 'fs';
12
+ import 'path';
13
+ import 'node:url';
11
14
  import './_commonjsHelpers.BFTU3MAI.js';
12
15
  import 'readline';
13
16
  import 'events';
14
- import 'process';
15
- import 'fs';
16
- import 'path';
17
17
 
18
18
  const jsxExample = {
19
19
  name: "HelloWorld.jsx",
@@ -1,14 +1,15 @@
1
- import vm from 'node:vm';
2
- import { pathToFileURL } from 'node:url';
3
1
  import fs from 'node:fs';
2
+ import { pathToFileURL } from 'node:url';
3
+ import vm from 'node:vm';
4
+ import { processError } from '@vitest/utils/error';
5
+ import { normalize as normalize$1, relative } from 'pathe';
4
6
  import { ViteNodeRunner, DEFAULT_REQUEST_STUBS } from 'vite-node/client';
5
7
  import { isInternalRequest, isNodeBuiltin as isNodeBuiltin$1, toFilePath, isPrimitive } from 'vite-node/utils';
6
- import { resolve as resolve$1, isAbsolute as isAbsolute$1, normalize as normalize$1, relative } from 'pathe';
7
- import { processError } from '@vitest/utils/error';
8
8
  import { distDir } from '../path.js';
9
- import { highlight } from '@vitest/utils';
9
+ import { resolve as resolve$1, isAbsolute as isAbsolute$1 } from 'node:path';
10
10
  import { MockerRegistry, mockObject, RedirectedModule, AutomockedModule } from '@vitest/mocker';
11
11
  import { builtinModules } from 'node:module';
12
+ import { highlight } from '@vitest/utils';
12
13
 
13
14
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
14
15
  function normalizeWindowsPath(input = "") {
@@ -548,6 +549,7 @@ function getMockType(factoryOrOptions) {
548
549
  return factoryOrOptions.spy ? "autospy" : "automock";
549
550
  }
550
551
 
552
+ const normalizedDistDir = normalize$1(distDir);
551
553
  const { readFileSync } = fs;
552
554
  async function createVitestExecutor(options) {
553
555
  const runner = new VitestExecutor(options);
@@ -606,7 +608,7 @@ async function startVitestExecutor(options) {
606
608
  if (externalizeMap.has(id)) {
607
609
  return { externalize: externalizeMap.get(id) };
608
610
  }
609
- if (id.includes(distDir)) {
611
+ if (id.includes(distDir) || id.includes(normalizedDistDir)) {
610
612
  const { path } = toFilePath(id, state().config.root);
611
613
  const externalize = pathToFileURL(path).toString();
612
614
  externalizeMap.set(id, externalize);
@@ -1,26 +1,21 @@
1
1
  import { g as globalApis } from './constants.fzPh7AOq.js';
2
- import { V as VitestIndex } from './index.-d_XpZEA.js';
2
+ import { V as VitestIndex } from './index.Dqe5k2Rk.js';
3
+ import './vi.JMQoNY_Z.js';
4
+ import '@vitest/expect';
3
5
  import '@vitest/runner';
4
- import './benchmark.C8CRJYG4.js';
5
6
  import '@vitest/runner/utils';
6
- import '@vitest/utils';
7
- import './index.CxRxs566.js';
8
- import 'pathe';
9
- import './utils.Ck2hJTRs.js';
10
- import './env.CmHVDJnw.js';
11
- import 'std-env';
12
- import './run-once.Sxe67Wng.js';
13
- import './vi.BskyZC5g.js';
14
7
  import 'chai';
8
+ import './utils.C8RiOc4B.js';
9
+ import '@vitest/utils';
15
10
  import './_commonjsHelpers.BFTU3MAI.js';
16
- import '@vitest/expect';
17
11
  import '@vitest/snapshot';
18
12
  import '@vitest/utils/error';
19
- import './tasks.BZnCS9aT.js';
20
13
  import '@vitest/utils/source-map';
21
- import './base.DwXGwWst.js';
22
14
  import './date.W2xKR2qe.js';
23
15
  import '@vitest/spy';
16
+ import './run-once.2ogXb3JV.js';
17
+ import './benchmark.Cdu9hjj4.js';
18
+ import 'expect-type';
24
19
 
25
20
  function registerApiGlobally() {
26
21
  globalApis.forEach((api) => {
@@ -9,18 +9,24 @@ function createBirpc(functions, options) {
9
9
  const {
10
10
  post,
11
11
  on,
12
+ off = () => {
13
+ },
12
14
  eventNames = [],
13
15
  serialize = defaultSerialize,
14
16
  deserialize = defaultDeserialize,
15
17
  resolver,
18
+ bind = "rpc",
16
19
  timeout = DEFAULT_TIMEOUT
17
20
  } = options;
18
21
  const rpcPromiseMap = /* @__PURE__ */ new Map();
19
22
  let _promise;
23
+ let closed = false;
20
24
  const rpc = new Proxy({}, {
21
25
  get(_, method) {
22
26
  if (method === "$functions")
23
27
  return functions;
28
+ if (method === "$close")
29
+ return close;
24
30
  if (method === "then" && !eventNames.includes("then") && !("then" in functions))
25
31
  return void 0;
26
32
  const sendEvent = (...args) => {
@@ -31,7 +37,15 @@ function createBirpc(functions, options) {
31
37
  return sendEvent;
32
38
  }
33
39
  const sendCall = async (...args) => {
34
- await _promise;
40
+ if (closed)
41
+ throw new Error(`[birpc] rpc is closed, cannot call "${method}"`);
42
+ if (_promise) {
43
+ try {
44
+ await _promise;
45
+ } finally {
46
+ _promise = void 0;
47
+ }
48
+ }
35
49
  return new Promise((resolve, reject) => {
36
50
  const id = nanoid();
37
51
  let timeoutId;
@@ -48,7 +62,7 @@ function createBirpc(functions, options) {
48
62
  if (typeof timeoutId === "object")
49
63
  timeoutId = timeoutId.unref?.();
50
64
  }
51
- rpcPromiseMap.set(id, { resolve, reject, timeoutId });
65
+ rpcPromiseMap.set(id, { resolve, reject, timeoutId, method });
52
66
  post(serialize({ m: method, a: args, i: id, t: "q" }));
53
67
  });
54
68
  };
@@ -56,7 +70,15 @@ function createBirpc(functions, options) {
56
70
  return sendCall;
57
71
  }
58
72
  });
59
- _promise = on(async (data, ...extra) => {
73
+ function close() {
74
+ closed = true;
75
+ rpcPromiseMap.forEach(({ reject, method }) => {
76
+ reject(new Error(`[birpc] rpc is closed, cannot call "${method}"`));
77
+ });
78
+ rpcPromiseMap.clear();
79
+ off(onMessage);
80
+ }
81
+ async function onMessage(data, ...extra) {
60
82
  const msg = deserialize(data);
61
83
  if (msg.t === "q") {
62
84
  const { m: method, a: args } = msg;
@@ -66,7 +88,7 @@ function createBirpc(functions, options) {
66
88
  error = new Error(`[birpc] function "${method}" not found`);
67
89
  } else {
68
90
  try {
69
- result = await fn.apply(rpc, args);
91
+ result = await fn.apply(bind === "rpc" ? rpc : functions, args);
70
92
  } catch (e) {
71
93
  error = e;
72
94
  }
@@ -88,7 +110,8 @@ function createBirpc(functions, options) {
88
110
  }
89
111
  rpcPromiseMap.delete(ack);
90
112
  }
91
- });
113
+ }
114
+ _promise = on(onMessage);
92
115
  return rpc;
93
116
  }
94
117
  const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
@@ -1,4 +1,4 @@
1
- import path from 'node:path';
1
+ import a from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import process$1 from 'node:process';
4
4
  import { promises } from 'node:fs';
@@ -237,7 +237,7 @@ async function locatePath(
237
237
 
238
238
  return pLocate(paths, async path_ => {
239
239
  try {
240
- const stat = await statFunction(path.resolve(cwd, path_));
240
+ const stat = await statFunction(a.resolve(cwd, path_));
241
241
  return matchType(type, stat);
242
242
  } catch {
243
243
  return false;
@@ -250,9 +250,9 @@ const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath)
250
250
  const findUpStop = Symbol('findUpStop');
251
251
 
252
252
  async function findUpMultiple(name, options = {}) {
253
- let directory = path.resolve(toPath(options.cwd) || '');
254
- const {root} = path.parse(directory);
255
- const stopAt = path.resolve(directory, options.stopAt || root);
253
+ let directory = a.resolve(toPath(options.cwd) || '');
254
+ const {root} = a.parse(directory);
255
+ const stopAt = a.resolve(directory, options.stopAt || root);
256
256
  const limit = options.limit || Number.POSITIVE_INFINITY;
257
257
  const paths = [name].flat();
258
258
 
@@ -280,14 +280,14 @@ async function findUpMultiple(name, options = {}) {
280
280
  }
281
281
 
282
282
  if (foundPath) {
283
- matches.push(path.resolve(directory, foundPath));
283
+ matches.push(a.resolve(directory, foundPath));
284
284
  }
285
285
 
286
286
  if (directory === stopAt || matches.length >= limit) {
287
287
  break;
288
288
  }
289
289
 
290
- directory = path.dirname(directory);
290
+ directory = a.dirname(directory);
291
291
  }
292
292
 
293
293
  return matches;