vitest 2.1.3 → 2.1.5

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 (75) hide show
  1. package/LICENSE.md +1 -209
  2. package/dist/browser.d.ts +24 -24
  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.BZZh4cSm.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.DWAW3Uh5.js} +11 -10
  9. package/dist/chunks/{cli-api.btGgw3PC.js → cli-api.BtqJwSCh.js} +828 -644
  10. package/dist/chunks/{config.Crbj2GAb.d.ts → config.Cy0C388Z.d.ts} +0 -1
  11. package/dist/chunks/{console.CfT1Wjed.js → console.BYGVloWk.js} +2 -6
  12. package/dist/chunks/{coverage.zlNdAMHK.js → coverage.BoMDb1ip.js} +1 -1
  13. package/dist/chunks/{creator.CBPphXqR.js → creator.IIqd8RWT.js} +8 -8
  14. package/dist/chunks/{execute._eQQfgI8.js → execute.2pr0rHgK.js} +8 -6
  15. package/dist/chunks/{globals.Bdzt04Qm.js → globals.D8ZVAdXd.js} +8 -13
  16. package/dist/chunks/{index.BpSiYbpB.js → index.68735LiX.js} +28 -5
  17. package/dist/chunks/{index.X0nbfr6-.js → index.BJDntFik.js} +7 -7
  18. package/dist/chunks/{index.CPD77dLA.js → index.CqYx2Nsr.js} +7 -7
  19. package/dist/chunks/{index.Dz2opmmU.js → index.DsZFoqi9.js} +3711 -3788
  20. package/dist/chunks/{index.lVXYBqEP.js → index.K90BXFOx.js} +186 -186
  21. package/dist/chunks/index.ckWaX2gY.js +54 -0
  22. package/dist/chunks/{index.4GFF2h22.js → index.nEwtF0bu.js} +6 -6
  23. package/dist/chunks/{node.Bx4JZjMG.js → node.AKq966Jp.js} +1 -5
  24. package/dist/chunks/{reporters.C4ZHgdxQ.d.ts → reporters.D7Jzd9GS.d.ts} +1246 -1221
  25. package/dist/chunks/{resolveConfig.Dha6ilPI.js → resolveConfig.RxKrDli4.js} +3196 -3176
  26. package/dist/chunks/{rpc.B7Mfb-Yf.js → rpc.C3q9uwRX.js} +2 -2
  27. package/dist/chunks/{run-once.Sxe67Wng.js → run-once.2ogXb3JV.js} +1 -1
  28. package/dist/chunks/{runBaseTests.Cx4wXyTR.js → runBaseTests.3qpJUEJM.js} +21 -25
  29. package/dist/chunks/{setup-common.BKyF15v_.js → setup-common.Dj6BZI3u.js} +3 -3
  30. package/dist/chunks/{suite.BMWOKiTe.d.ts → suite.B2jumIFP.d.ts} +2 -2
  31. package/dist/chunks/utils.C8RiOc4B.js +77 -0
  32. package/dist/chunks/{utils.CY6Spixo.js → utils.DNoFbBUZ.js} +7 -3
  33. package/dist/chunks/{vi.BskyZC5g.js → vi.DgezovHB.js} +177 -142
  34. package/dist/chunks/{vite.YH7MrecS.d.ts → vite.C-N5BBZe.d.ts} +1 -1
  35. package/dist/chunks/{vm.DB_hLchi.js → vm.Zr4qWzDJ.js} +8 -8
  36. package/dist/chunks/{worker.CcJLfX8w.d.ts → worker.B9FxPCaC.d.ts} +1 -1
  37. package/dist/chunks/{worker.B6RjTtbk.d.ts → worker.tN5KGIih.d.ts} +14 -4
  38. package/dist/cli.js +3 -4
  39. package/dist/config.cjs +4 -4
  40. package/dist/config.d.ts +11 -11
  41. package/dist/config.js +4 -4
  42. package/dist/coverage.d.ts +10 -10
  43. package/dist/coverage.js +8 -11
  44. package/dist/environments.d.ts +2 -2
  45. package/dist/environments.js +1 -1
  46. package/dist/execute.d.ts +54 -54
  47. package/dist/execute.js +7 -6
  48. package/dist/index.d.ts +106 -1101
  49. package/dist/index.js +7 -18
  50. package/dist/node.d.ts +44 -42
  51. package/dist/node.js +23 -29
  52. package/dist/path.js +1 -1
  53. package/dist/reporters.d.ts +10 -10
  54. package/dist/reporters.js +12 -18
  55. package/dist/runners.d.ts +12 -19
  56. package/dist/runners.js +142 -148
  57. package/dist/snapshot.js +2 -6
  58. package/dist/suite.d.ts +2 -2
  59. package/dist/suite.js +2 -6
  60. package/dist/worker.js +10 -7
  61. package/dist/workers/forks.js +9 -8
  62. package/dist/workers/runVmTests.js +16 -20
  63. package/dist/workers/threads.js +9 -8
  64. package/dist/workers/vmForks.js +9 -12
  65. package/dist/workers/vmThreads.js +9 -12
  66. package/dist/workers.d.ts +14 -14
  67. package/dist/workers.js +15 -18
  68. package/package.json +27 -27
  69. package/dist/chunks/base.DwXGwWst.js +0 -89
  70. package/dist/chunks/env.CmHVDJnw.js +0 -7
  71. package/dist/chunks/index.-d_XpZEA.js +0 -140
  72. package/dist/chunks/index.CxRxs566.js +0 -23
  73. package/dist/chunks/tasks.BZnCS9aT.js +0 -18
  74. package/dist/chunks/utils.Ck2hJTRs.js +0 -23
  75. package/dist/chunks/{environment.CzISCQ7o.d.ts → environment.LoooBwUu.d.ts} +24 -24
@@ -200,7 +200,6 @@ interface SerializedCoverageConfig {
200
200
  }
201
201
  type RuntimeConfig = Pick<SerializedConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency' | 'expect' | 'printConsoleTrace'> & {
202
202
  sequence?: {
203
- concurrent?: boolean;
204
203
  hooks?: SequenceHooks;
205
204
  };
206
205
  };
@@ -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.ckWaX2gY.js';
3
+ import './vi.DgezovHB.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;
@@ -1,7 +1,7 @@
1
1
  import process$1 from 'process';
2
2
  import fs from 'node:fs';
3
3
  import fsp from 'node:fs/promises';
4
- import path from 'node:path';
4
+ import a from 'node:path';
5
5
  import process from 'node:process';
6
6
  import { existsSync } from 'fs';
7
7
  import { resolve } from 'path';
@@ -26,27 +26,27 @@ const LOCKS = {
26
26
  async function detect({ cwd, onUnknown } = {}) {
27
27
  for (const directory of lookup(cwd)) {
28
28
  for (const lock of Object.keys(LOCKS)) {
29
- if (await fileExists(path.join(directory, lock))) {
29
+ if (await fileExists(a.join(directory, lock))) {
30
30
  const name = LOCKS[lock];
31
- const result2 = await parsePackageJson(path.join(directory, "package.json"), onUnknown);
31
+ const result2 = await parsePackageJson(a.join(directory, "package.json"), onUnknown);
32
32
  if (result2)
33
33
  return result2;
34
34
  else
35
35
  return { name, agent: name };
36
36
  }
37
37
  }
38
- const result = await parsePackageJson(path.join(directory, "package.json"), onUnknown);
38
+ const result = await parsePackageJson(a.join(directory, "package.json"), onUnknown);
39
39
  if (result)
40
40
  return result;
41
41
  }
42
42
  return null;
43
43
  }
44
44
  function* lookup(cwd = process.cwd()) {
45
- let directory = path.resolve(cwd);
46
- const { root } = path.parse(directory);
45
+ let directory = a.resolve(cwd);
46
+ const { root } = a.parse(directory);
47
47
  while (directory && directory !== root) {
48
48
  yield directory;
49
- directory = path.dirname(directory);
49
+ directory = a.dirname(directory);
50
50
  }
51
51
  }
52
52
  async function parsePackageJson(filepath, onUnknown) {