vitest 2.1.0-beta.5 → 2.1.0-beta.7

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/LICENSE.md +59 -320
  2. package/dist/browser.d.ts +6 -3
  3. package/dist/browser.js +2 -2
  4. package/dist/chunks/{RandomSequencer.B4M2ux5b.js → RandomSequencer.Bh5-tlNJ.js} +77 -58
  5. package/dist/chunks/{base.BH-FAiX7.js → base.BlXpj3e_.js} +1 -29
  6. package/dist/chunks/{base.BYvKfYzm.js → base.CchlWrnV.js} +2 -4
  7. package/dist/chunks/{cac.DosbLiJg.js → cac.B5XYKv2_.js} +26 -17
  8. package/dist/chunks/{cli-api.D8zgNrBU.js → cli-api.ByZPnilx.js} +7419 -7959
  9. package/dist/chunks/{constants.CaAN7icJ.js → constants.fzPh7AOq.js} +1 -1
  10. package/dist/chunks/{coverage.CqfT4xaf.js → coverage.zlNdAMHK.js} +5 -3
  11. package/dist/chunks/{creator.COdKw_ZN.js → creator.zfBZSJzo.js} +9 -9
  12. package/dist/chunks/{environment.0M5R1SX_.d.ts → environment.C5eAp3K6.d.ts} +1 -1
  13. package/dist/chunks/{execute.DT9BA6zp.js → execute._eQQfgI8.js} +322 -232
  14. package/dist/chunks/{git.ZtkbKc8u.js → git.B5SDxu-n.js} +5 -5
  15. package/dist/chunks/{globals.DRPLtPOv.js → globals.jM7MxN2t.js} +4 -4
  16. package/dist/chunks/{index.CM5UI-4O.js → index.Bn75ITYg.js} +3 -3
  17. package/dist/chunks/index.CPD77dLA.js +133 -0
  18. package/dist/chunks/{index.CxWPpGJz.js → index.CSjyR2-v.js} +2 -2
  19. package/dist/chunks/{index.Dx3f477d.js → index.DpJO1tkB.js} +1110 -1104
  20. package/dist/chunks/{index.CNZXZ9PJ.js → index.xm8OIiKD.js} +1 -1
  21. package/dist/chunks/mocker.cRtM890J.d.ts +17 -0
  22. package/dist/chunks/{reporters.DbwOGCsU.d.ts → reporters.WnPwkmgA.d.ts} +154 -129
  23. package/dist/chunks/{resolveConfig.RHsAM2_Q.js → resolveConfig.-K5hHm0S.js} +56 -34
  24. package/dist/chunks/{runBaseTests.BAhL8UH_.js → runBaseTests.Cztfoflv.js} +7 -7
  25. package/dist/chunks/{setup-common.KBrCO5LJ.js → setup-common.fGBFoQKJ.js} +1 -1
  26. package/dist/chunks/{utils.C3_cBsyn.js → utils.Cn0zI1t3.js} +16 -3
  27. package/dist/chunks/{utils.DO38lwfj.js → utils.Dbnmsfq1.js} +1 -1
  28. package/dist/chunks/{vi.B6QZ938s.js → vi.DGgiNzJE.js} +46 -37
  29. package/dist/chunks/vite.D2yAwzwa.d.ts +11 -0
  30. package/dist/chunks/{vm.kl9T_5ai.js → vm.CPXwWp4C.js} +1 -2
  31. package/dist/chunks/{worker.Cx2xE71X.d.ts → worker.Bws9Zuxu.d.ts} +1 -1
  32. package/dist/chunks/{worker.BANO5ak1.d.ts → worker.CmPmTxgH.d.ts} +2 -14
  33. package/dist/cli.js +3 -3
  34. package/dist/config.cjs +1 -0
  35. package/dist/config.d.ts +70 -2
  36. package/dist/config.js +1 -0
  37. package/dist/coverage.d.ts +4 -3
  38. package/dist/coverage.js +29 -5
  39. package/dist/environments.d.ts +2 -2
  40. package/dist/execute.d.ts +13 -14
  41. package/dist/execute.js +3 -2
  42. package/dist/index.d.ts +23 -16
  43. package/dist/index.js +4 -4
  44. package/dist/mocker.d.ts +1 -0
  45. package/dist/mocker.js +1 -0
  46. package/dist/node.d.ts +27 -9
  47. package/dist/node.js +44 -39
  48. package/dist/reporters.d.ts +2 -2
  49. package/dist/reporters.js +8 -8
  50. package/dist/runners.js +2 -2
  51. package/dist/utils.d.ts +1 -0
  52. package/dist/worker.js +3 -2
  53. package/dist/workers/forks.js +5 -4
  54. package/dist/workers/runVmTests.js +6 -6
  55. package/dist/workers/threads.js +5 -4
  56. package/dist/workers/vmForks.js +4 -4
  57. package/dist/workers/vmThreads.js +4 -4
  58. package/dist/workers.d.ts +4 -16
  59. package/dist/workers.js +6 -5
  60. package/mocker.d.ts +1 -0
  61. package/package.json +22 -17
  62. package/dist/chunks/index.DNUmWFkO.js +0 -319
@@ -1,5 +1,5 @@
1
1
  import { resolve } from 'pathe';
2
- import { execa } from 'execa';
2
+ import { x } from 'tinyexec';
3
3
 
4
4
  class VitestGit {
5
5
  constructor(cwd) {
@@ -9,7 +9,7 @@ class VitestGit {
9
9
  async resolveFilesWithGitCommand(args) {
10
10
  let result;
11
11
  try {
12
- result = await execa("git", args, { cwd: this.root });
12
+ result = await x("git", args, { nodeOptions: { cwd: this.root } });
13
13
  } catch (e) {
14
14
  e.message = e.stderr;
15
15
  throw e;
@@ -56,10 +56,10 @@ class VitestGit {
56
56
  ]);
57
57
  }
58
58
  async getRoot(cwd) {
59
- const options = ["rev-parse", "--show-cdup"];
59
+ const args = ["rev-parse", "--show-cdup"];
60
60
  try {
61
- const result = await execa("git", options, { cwd });
62
- return resolve(cwd, result.stdout);
61
+ const result = await x("git", args, { nodeOptions: { cwd } });
62
+ return resolve(cwd, result.stdout.trim());
63
63
  } catch {
64
64
  return null;
65
65
  }
@@ -1,5 +1,5 @@
1
- import { g as globalApis } from './constants.CaAN7icJ.js';
2
- import { V as VitestIndex } from './index.CNZXZ9PJ.js';
1
+ import { g as globalApis } from './constants.fzPh7AOq.js';
2
+ import { V as VitestIndex } from './index.xm8OIiKD.js';
3
3
  import '@vitest/runner';
4
4
  import './benchmark.C8CRJYG4.js';
5
5
  import '@vitest/runner/utils';
@@ -10,7 +10,7 @@ import './utils.Ck2hJTRs.js';
10
10
  import './env.CmHVDJnw.js';
11
11
  import 'std-env';
12
12
  import './run-once.Sxe67Wng.js';
13
- import './vi.B6QZ938s.js';
13
+ import './vi.DGgiNzJE.js';
14
14
  import 'chai';
15
15
  import './_commonjsHelpers.BFTU3MAI.js';
16
16
  import '@vitest/expect';
@@ -18,7 +18,7 @@ import '@vitest/snapshot';
18
18
  import '@vitest/utils/error';
19
19
  import './tasks.BZnCS9aT.js';
20
20
  import '@vitest/utils/source-map';
21
- import './base.BH-FAiX7.js';
21
+ import './base.BlXpj3e_.js';
22
22
  import './date.W2xKR2qe.js';
23
23
  import '@vitest/spy';
24
24
 
@@ -4,7 +4,7 @@ import process$1 from 'node:process';
4
4
  import { promises } from 'node:fs';
5
5
  import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
6
6
  import require$$0 from 'readline';
7
- import require$$0$1 from 'events';
7
+ import require$$2 from 'events';
8
8
 
9
9
  function _mergeNamespaces(n, m) {
10
10
  m.forEach(function (e) {
@@ -795,7 +795,7 @@ function requirePrompt$1 () {
795
795
  const _require = requireUtil$1(),
796
796
  action = _require.action;
797
797
 
798
- const EventEmitter = require$$0$1;
798
+ const EventEmitter = require$$2;
799
799
 
800
800
  const _require2 = requireSrc(),
801
801
  beep = _require2.beep,
@@ -3957,7 +3957,7 @@ function requirePrompt () {
3957
3957
 
3958
3958
  const readline = require$$0;
3959
3959
  const { action } = requireUtil();
3960
- const EventEmitter = require$$0$1;
3960
+ const EventEmitter = require$$2;
3961
3961
  const { beep, cursor } = requireSrc();
3962
3962
  const color = requireKleur();
3963
3963
 
@@ -0,0 +1,133 @@
1
+ import process$1 from 'process';
2
+ import fs from 'node:fs';
3
+ import fsp from 'node:fs/promises';
4
+ import path from 'node:path';
5
+ import process from 'node:process';
6
+ import { existsSync } from 'fs';
7
+ import { resolve } from 'path';
8
+ import { x } from 'tinyexec';
9
+
10
+ const AGENTS = [
11
+ "npm",
12
+ "yarn",
13
+ "yarn@berry",
14
+ "pnpm",
15
+ "pnpm@6",
16
+ "bun"
17
+ ];
18
+ const LOCKS = {
19
+ "bun.lockb": "bun",
20
+ "pnpm-lock.yaml": "pnpm",
21
+ "yarn.lock": "yarn",
22
+ "package-lock.json": "npm",
23
+ "npm-shrinkwrap.json": "npm"
24
+ };
25
+
26
+ async function detect({ cwd, onUnknown } = {}) {
27
+ for (const directory of lookup(cwd)) {
28
+ for (const lock of Object.keys(LOCKS)) {
29
+ if (await fileExists(path.join(directory, lock))) {
30
+ const name = LOCKS[lock];
31
+ const result2 = await parsePackageJson(path.join(directory, "package.json"), onUnknown);
32
+ if (result2)
33
+ return result2;
34
+ else
35
+ return { name, agent: name };
36
+ }
37
+ }
38
+ const result = await parsePackageJson(path.join(directory, "package.json"), onUnknown);
39
+ if (result)
40
+ return result;
41
+ }
42
+ return null;
43
+ }
44
+ function* lookup(cwd = process.cwd()) {
45
+ let directory = path.resolve(cwd);
46
+ const { root } = path.parse(directory);
47
+ while (directory && directory !== root) {
48
+ yield directory;
49
+ directory = path.dirname(directory);
50
+ }
51
+ }
52
+ async function parsePackageJson(filepath, onUnknown) {
53
+ if (!filepath || !await fileExists(filepath))
54
+ return null;
55
+ try {
56
+ const pkg = JSON.parse(fs.readFileSync(filepath, "utf8"));
57
+ let agent;
58
+ if (typeof pkg.packageManager === "string") {
59
+ const [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
60
+ let version = ver;
61
+ if (name === "yarn" && Number.parseInt(ver) > 1) {
62
+ agent = "yarn@berry";
63
+ version = "berry";
64
+ return { name, agent, version };
65
+ } else if (name === "pnpm" && Number.parseInt(ver) < 7) {
66
+ agent = "pnpm@6";
67
+ return { name, agent, version };
68
+ } else if (AGENTS.includes(name)) {
69
+ agent = name;
70
+ return { name, agent, version };
71
+ } else {
72
+ return onUnknown?.(pkg.packageManager) ?? null;
73
+ }
74
+ }
75
+ } catch {
76
+ }
77
+ return null;
78
+ }
79
+ async function fileExists(filePath) {
80
+ try {
81
+ const stats = await fsp.stat(filePath);
82
+ if (stats.isFile()) {
83
+ return true;
84
+ }
85
+ } catch {
86
+ }
87
+ return false;
88
+ }
89
+
90
+ // src/detect.ts
91
+ async function detectPackageManager(cwd = process$1.cwd()) {
92
+ const result = await detect({
93
+ cwd,
94
+ onUnknown(packageManager) {
95
+ console.warn("[@antfu/install-pkg] Unknown packageManager:", packageManager);
96
+ return void 0;
97
+ }
98
+ });
99
+ return result?.agent || null;
100
+ }
101
+ async function installPackage(names, options = {}) {
102
+ const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
103
+ const [agent] = detectedAgent.split("@");
104
+ if (!Array.isArray(names))
105
+ names = [names];
106
+ const args = options.additionalArgs || [];
107
+ if (options.preferOffline) {
108
+ if (detectedAgent === "yarn@berry")
109
+ args.unshift("--cached");
110
+ else
111
+ args.unshift("--prefer-offline");
112
+ }
113
+ if (agent === "pnpm" && existsSync(resolve(options.cwd ?? process$1.cwd(), "pnpm-workspace.yaml")))
114
+ args.unshift("-w");
115
+ return x(
116
+ agent,
117
+ [
118
+ agent === "yarn" ? "add" : "install",
119
+ options.dev ? "-D" : "",
120
+ ...args,
121
+ ...names
122
+ ].filter(Boolean),
123
+ {
124
+ nodeOptions: {
125
+ stdio: options.silent ? "ignore" : "inherit",
126
+ cwd: options.cwd
127
+ },
128
+ throwOnError: true
129
+ }
130
+ );
131
+ }
132
+
133
+ export { detectPackageManager, installPackage };
@@ -3,8 +3,8 @@ import { resolve } from 'pathe';
3
3
  import { distDir } from '../path.js';
4
4
  import { g as getWorkerState } from './utils.Ck2hJTRs.js';
5
5
  import { r as rpc } from './rpc.B7Mfb-Yf.js';
6
- import { t as takeCoverageInsideWorker } from './coverage.CqfT4xaf.js';
7
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.KBrCO5LJ.js';
6
+ import { t as takeCoverageInsideWorker } from './coverage.zlNdAMHK.js';
7
+ import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.fGBFoQKJ.js';
8
8
 
9
9
  function setupChaiConfig(config) {
10
10
  Object.assign(chai.config, config);