vitest 3.2.0-beta.2 → 3.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 (72) hide show
  1. package/LICENSE.md +29 -0
  2. package/dist/browser.d.ts +3 -3
  3. package/dist/browser.js +2 -2
  4. package/dist/chunks/{base.DwtwORaC.js → base.Cg0miDlQ.js} +11 -14
  5. package/dist/chunks/{benchmark.BoF7jW0Q.js → benchmark.CYdenmiT.js} +4 -6
  6. package/dist/chunks/{cac.I9MLYfT-.js → cac.6rXCxFY1.js} +76 -143
  7. package/dist/chunks/{cli-api.d6IK1pnk.js → cli-api.Cej3MBjA.js} +1460 -1344
  8. package/dist/chunks/{config.d.UqE-KR0o.d.ts → config.d.D2ROskhv.d.ts} +2 -0
  9. package/dist/chunks/{console.K1NMVOSc.js → console.CtFJOzRO.js} +25 -45
  10. package/dist/chunks/{constants.BZZyIeIE.js → constants.DnKduX2e.js} +1 -0
  11. package/dist/chunks/{coverage.0iPg4Wrz.js → coverage.DVF1vEu8.js} +4 -12
  12. package/dist/chunks/{coverage.OGU09Jbh.js → coverage.EIiagJJP.js} +578 -993
  13. package/dist/chunks/{creator.DGAdZ4Hj.js → creator.GK6I-cL4.js} +39 -83
  14. package/dist/chunks/date.Bq6ZW5rf.js +73 -0
  15. package/dist/chunks/{defaults.DSxsTG0h.js → defaults.B7q_naMc.js} +2 -1
  16. package/dist/chunks/{env.Dq0hM4Xv.js → env.D4Lgay0q.js} +1 -1
  17. package/dist/chunks/{environment.d.D8YDy2v5.d.ts → environment.d.cL3nLXbE.d.ts} +1 -0
  18. package/dist/chunks/{execute.JlGHLJZT.js → execute.B7h3T_Hc.js} +126 -217
  19. package/dist/chunks/{git.DXfdBEfR.js → git.BVQ8w_Sw.js} +1 -3
  20. package/dist/chunks/{global.d.BPa1eL3O.d.ts → global.d.MAmajcmJ.d.ts} +5 -1
  21. package/dist/chunks/{globals.CpxW8ccg.js → globals.DEHgCU4V.js} +7 -6
  22. package/dist/chunks/{index.CV36oG_L.js → index.BZ0g1JD2.js} +430 -625
  23. package/dist/chunks/{index.DswW_LEs.js → index.BbB8_kAK.js} +25 -24
  24. package/dist/chunks/{index.CmC5OK9L.js → index.CIyJn3t1.js} +38 -82
  25. package/dist/chunks/{index.CfXMNXHg.js → index.CdQS2e2Q.js} +4 -2
  26. package/dist/chunks/{index.DFXFpH3w.js → index.CmSc2RE5.js} +85 -105
  27. package/dist/chunks/index.D3XRDfWc.js +213 -0
  28. package/dist/chunks/{inspector.DbDkSkFn.js → inspector.C914Efll.js} +4 -1
  29. package/dist/chunks/{node.3xsWotC9.js → node.fjCdwEIl.js} +1 -1
  30. package/dist/chunks/{reporters.d.CLC9rhKy.d.ts → reporters.d.C1ogPriE.d.ts} +47 -9
  31. package/dist/chunks/{rpc.D9_013TY.js → rpc.Iovn4oWe.js} +10 -19
  32. package/dist/chunks/{runBaseTests.Dn2vyej_.js → runBaseTests.Dd85QTll.js} +27 -31
  33. package/dist/chunks/{setup-common.CYo3Y0dD.js → setup-common.Dd054P77.js} +16 -42
  34. package/dist/chunks/{typechecker.DnTrplSJ.js → typechecker.DRKU1-1g.js} +163 -186
  35. package/dist/chunks/{utils.BfxieIyZ.js → utils.CAioKnHs.js} +9 -14
  36. package/dist/chunks/{utils.CgTj3MsC.js → utils.XdZDrNZV.js} +6 -13
  37. package/dist/chunks/{vi.BFR5YIgu.js → vi.bdSIJ99Y.js} +137 -263
  38. package/dist/chunks/{vite.d.CBZ3M_ru.d.ts → vite.d.DqE4-hhK.d.ts} +3 -1
  39. package/dist/chunks/{vm.C1HHjtNS.js → vm.BThCzidc.js} +164 -212
  40. package/dist/chunks/{worker.d.D5Xdi-Zr.d.ts → worker.d.DvqK5Vmu.d.ts} +1 -1
  41. package/dist/chunks/{worker.d.CoCI7hzP.d.ts → worker.d.tQu2eJQy.d.ts} +5 -3
  42. package/dist/cli.js +5 -5
  43. package/dist/config.cjs +3 -1
  44. package/dist/config.d.ts +7 -6
  45. package/dist/config.js +3 -3
  46. package/dist/coverage.d.ts +4 -4
  47. package/dist/coverage.js +7 -7
  48. package/dist/environments.d.ts +6 -2
  49. package/dist/environments.js +1 -1
  50. package/dist/execute.d.ts +9 -3
  51. package/dist/execute.js +1 -1
  52. package/dist/index.d.ts +28 -15
  53. package/dist/index.js +5 -5
  54. package/dist/node.d.ts +18 -10
  55. package/dist/node.js +17 -17
  56. package/dist/reporters.d.ts +4 -4
  57. package/dist/reporters.js +4 -4
  58. package/dist/runners.d.ts +6 -3
  59. package/dist/runners.js +59 -80
  60. package/dist/snapshot.js +2 -2
  61. package/dist/suite.js +2 -2
  62. package/dist/worker.js +39 -41
  63. package/dist/workers/forks.js +6 -4
  64. package/dist/workers/runVmTests.js +20 -21
  65. package/dist/workers/threads.js +4 -4
  66. package/dist/workers/vmForks.js +6 -6
  67. package/dist/workers/vmThreads.js +6 -6
  68. package/dist/workers.d.ts +4 -4
  69. package/dist/workers.js +10 -10
  70. package/package.json +21 -19
  71. package/dist/chunks/date.CDOsz-HY.js +0 -53
  72. package/dist/chunks/index.CK1YOQaa.js +0 -143
package/dist/workers.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { W as WorkerGlobalState, C as ContextRPC, B as BirpcOptions, R as RuntimeRPC } from './chunks/worker.d.CoCI7hzP.js';
1
+ import { W as WorkerGlobalState, C as ContextRPC, B as BirpcOptions, R as RuntimeRPC } from './chunks/worker.d.tQu2eJQy.js';
2
2
  import { Awaitable } from '@vitest/utils';
3
3
  import * as v8 from 'v8';
4
- import { a as SerializedConfig } from './chunks/config.d.UqE-KR0o.js';
5
- import { W as WorkerContext } from './chunks/worker.d.D5Xdi-Zr.js';
4
+ import { a as SerializedConfig } from './chunks/config.d.D2ROskhv.js';
5
+ import { W as WorkerContext } from './chunks/worker.d.DvqK5Vmu.js';
6
6
  import '@vitest/runner';
7
7
  import 'vite-node';
8
- import './chunks/environment.d.D8YDy2v5.js';
8
+ import './chunks/environment.d.cL3nLXbE.js';
9
9
  import 'vitest/optional-types.js';
10
10
  import '@vitest/snapshot';
11
11
  import '@vitest/pretty-format';
package/dist/workers.js CHANGED
@@ -1,8 +1,8 @@
1
- export { p as provideWorkerState } from './chunks/utils.CgTj3MsC.js';
1
+ export { p as provideWorkerState } from './chunks/utils.XdZDrNZV.js';
2
2
  export { collect as collectVitestWorkerTests, run as runVitestWorker } from './worker.js';
3
- export { r as runBaseTests } from './chunks/base.DwtwORaC.js';
4
- export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './chunks/utils.BfxieIyZ.js';
5
- export { r as runVmTests } from './chunks/vm.C1HHjtNS.js';
3
+ export { r as runBaseTests } from './chunks/base.Cg0miDlQ.js';
4
+ export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './chunks/utils.CAioKnHs.js';
5
+ export { r as runVmTests } from './chunks/vm.BThCzidc.js';
6
6
  import '@vitest/utils';
7
7
  import 'node:url';
8
8
  import '@vitest/utils/source-map';
@@ -10,21 +10,21 @@ import 'tinypool';
10
10
  import 'vite-node/client';
11
11
  import 'node:fs';
12
12
  import 'pathe';
13
- import './chunks/index.DFXFpH3w.js';
13
+ import './chunks/index.CmSc2RE5.js';
14
14
  import 'node:console';
15
- import './chunks/inspector.DbDkSkFn.js';
15
+ import './chunks/inspector.C914Efll.js';
16
16
  import 'node:module';
17
- import './chunks/rpc.D9_013TY.js';
17
+ import './chunks/rpc.Iovn4oWe.js';
18
18
  import './chunks/index.CJ0plNrh.js';
19
- import './chunks/execute.JlGHLJZT.js';
19
+ import './chunks/execute.B7h3T_Hc.js';
20
20
  import 'node:vm';
21
21
  import '@vitest/utils/error';
22
22
  import 'vite-node/utils';
23
23
  import './path.js';
24
24
  import 'node:path';
25
25
  import '@vitest/mocker';
26
- import './chunks/console.K1NMVOSc.js';
26
+ import './chunks/console.CtFJOzRO.js';
27
27
  import 'node:stream';
28
28
  import 'tinyrainbow';
29
- import './chunks/date.CDOsz-HY.js';
29
+ import './chunks/date.Bq6ZW5rf.js';
30
30
  import 'vite-node/constants';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "3.2.0-beta.2",
4
+ "version": "3.2.0",
5
5
  "description": "Next generation testing framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -119,8 +119,8 @@
119
119
  "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
120
120
  "happy-dom": "*",
121
121
  "jsdom": "*",
122
- "@vitest/browser": "3.2.0-beta.2",
123
- "@vitest/ui": "3.2.0-beta.2"
122
+ "@vitest/ui": "3.2.0",
123
+ "@vitest/browser": "3.2.0"
124
124
  },
125
125
  "peerDependenciesMeta": {
126
126
  "@edge-runtime/vm": {
@@ -148,7 +148,7 @@
148
148
  "dependencies": {
149
149
  "@types/chai": "^5.2.2",
150
150
  "chai": "^5.2.0",
151
- "debug": "^4.4.0",
151
+ "debug": "^4.4.1",
152
152
  "expect-type": "^1.2.1",
153
153
  "magic-string": "^0.30.17",
154
154
  "pathe": "^2.0.3",
@@ -156,23 +156,23 @@
156
156
  "std-env": "^3.9.0",
157
157
  "tinybench": "^2.9.0",
158
158
  "tinyexec": "^0.3.2",
159
- "tinyglobby": "^0.2.13",
160
- "tinypool": "^1.0.2",
159
+ "tinyglobby": "^0.2.14",
160
+ "tinypool": "^1.1.0",
161
161
  "tinyrainbow": "^2.0.0",
162
- "vite": "^5.0.0 || ^6.0.0",
162
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0",
163
163
  "why-is-node-running": "^2.3.0",
164
- "@vitest/mocker": "3.2.0-beta.2",
165
- "@vitest/pretty-format": "^3.2.0-beta.2",
166
- "@vitest/expect": "3.2.0-beta.2",
167
- "@vitest/runner": "3.2.0-beta.2",
168
- "@vitest/spy": "3.2.0-beta.2",
169
- "vite-node": "3.2.0-beta.2",
170
- "@vitest/utils": "3.2.0-beta.2",
171
- "@vitest/snapshot": "3.2.0-beta.2"
164
+ "@vitest/expect": "3.2.0",
165
+ "@vitest/pretty-format": "^3.2.0",
166
+ "@vitest/runner": "3.2.0",
167
+ "@vitest/snapshot": "3.2.0",
168
+ "@vitest/spy": "3.2.0",
169
+ "@vitest/utils": "3.2.0",
170
+ "@vitest/mocker": "3.2.0",
171
+ "vite-node": "3.2.0"
172
172
  },
173
173
  "devDependencies": {
174
174
  "@ampproject/remapping": "^2.3.0",
175
- "@antfu/install-pkg": "^1.0.0",
175
+ "@antfu/install-pkg": "^1.1.0",
176
176
  "@edge-runtime/vm": "^5.0.0",
177
177
  "@sinonjs/fake-timers": "14.0.0",
178
178
  "@types/debug": "^4.1.12",
@@ -180,7 +180,8 @@
180
180
  "@types/istanbul-lib-coverage": "^2.0.6",
181
181
  "@types/istanbul-reports": "^3.0.4",
182
182
  "@types/jsdom": "^21.1.7",
183
- "@types/node": "^22.14.1",
183
+ "@types/mime": "^4.0.0",
184
+ "@types/node": "^22.15.29",
184
185
  "@types/picomatch": "^4.0.0",
185
186
  "@types/prompts": "^2.4.9",
186
187
  "@types/sinonjs__fake-timers": "^8.1.5",
@@ -190,13 +191,14 @@
190
191
  "chai-subset": "^1.6.0",
191
192
  "find-up": "^6.3.0",
192
193
  "flatted": "^3.3.3",
193
- "happy-dom": "^17.4.4",
194
+ "happy-dom": "^17.5.6",
194
195
  "jsdom": "^26.1.0",
195
196
  "local-pkg": "^1.1.1",
197
+ "mime": "^4.0.7",
196
198
  "pretty-format": "^29.7.0",
197
199
  "prompts": "^2.4.2",
198
200
  "strip-literal": "^3.0.0",
199
- "ws": "^8.18.1"
201
+ "ws": "^8.18.2"
200
202
  },
201
203
  "scripts": {
202
204
  "build": "rimraf dist && rollup -c",
@@ -1,53 +0,0 @@
1
- const RealDate = Date;
2
- let now = null;
3
- class MockDate extends RealDate {
4
- constructor(y, m, d, h, M, s, ms) {
5
- super();
6
- let date;
7
- switch (arguments.length) {
8
- case 0:
9
- if (now !== null) {
10
- date = new RealDate(now.valueOf());
11
- } else {
12
- date = new RealDate();
13
- }
14
- break;
15
- case 1:
16
- date = new RealDate(y);
17
- break;
18
- default:
19
- d = typeof d === "undefined" ? 1 : d;
20
- h = h || 0;
21
- M = M || 0;
22
- s = s || 0;
23
- ms = ms || 0;
24
- date = new RealDate(y, m, d, h, M, s, ms);
25
- break;
26
- }
27
- Object.setPrototypeOf(date, MockDate.prototype);
28
- return date;
29
- }
30
- }
31
- MockDate.UTC = RealDate.UTC;
32
- MockDate.now = function() {
33
- return new MockDate().valueOf();
34
- };
35
- MockDate.parse = function(dateString) {
36
- return RealDate.parse(dateString);
37
- };
38
- MockDate.toString = function() {
39
- return RealDate.toString();
40
- };
41
- function mockDate(date) {
42
- const dateObj = new RealDate(date.valueOf());
43
- if (Number.isNaN(dateObj.getTime())) {
44
- throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
45
- }
46
- globalThis.Date = MockDate;
47
- now = dateObj.valueOf();
48
- }
49
- function resetDate() {
50
- globalThis.Date = RealDate;
51
- }
52
-
53
- export { RealDate as R, mockDate as m, resetDate as r };
@@ -1,143 +0,0 @@
1
- import process from 'node:process';
2
- import fs, { existsSync } from 'node:fs';
3
- import fsPromises from 'node:fs/promises';
4
- import path, { resolve } from 'node:path';
5
- import { x } from 'tinyexec';
6
-
7
- const AGENTS = [
8
- "npm",
9
- "yarn",
10
- "yarn@berry",
11
- "pnpm",
12
- "pnpm@6",
13
- "bun",
14
- "deno"
15
- ];
16
- const LOCKS = {
17
- "bun.lock": "bun",
18
- "bun.lockb": "bun",
19
- "deno.lock": "deno",
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(options = {}) {
27
- const { cwd, onUnknown } = options;
28
- for (const directory of lookup(cwd)) {
29
- for (const lock of Object.keys(LOCKS)) {
30
- if (await fileExists(path.join(directory, lock))) {
31
- const name = LOCKS[lock];
32
- const result2 = await parsePackageJson(path.join(directory, "package.json"), onUnknown);
33
- if (result2)
34
- return result2;
35
- else
36
- return { name, agent: name };
37
- }
38
- }
39
- const result = await parsePackageJson(path.join(directory, "package.json"), onUnknown);
40
- if (result)
41
- return result;
42
- }
43
- return null;
44
- }
45
- function* lookup(cwd = process.cwd()) {
46
- let directory = path.resolve(cwd);
47
- const { root } = path.parse(directory);
48
- while (directory && directory !== root) {
49
- yield directory;
50
- directory = path.dirname(directory);
51
- }
52
- }
53
- async function parsePackageJson(filepath, onUnknown) {
54
- return !filepath || !await fileExists(filepath) ? null : handlePackageManager(filepath, onUnknown);
55
- }
56
- function handlePackageManager(filepath, onUnknown) {
57
- try {
58
- const pkg = JSON.parse(fs.readFileSync(filepath, "utf8"));
59
- let agent;
60
- if (typeof pkg.packageManager === "string") {
61
- const [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
62
- let version = ver;
63
- if (name === "yarn" && Number.parseInt(ver) > 1) {
64
- agent = "yarn@berry";
65
- version = "berry";
66
- return { name, agent, version };
67
- } else if (name === "pnpm" && Number.parseInt(ver) < 7) {
68
- agent = "pnpm@6";
69
- return { name, agent, version };
70
- } else if (AGENTS.includes(name)) {
71
- agent = name;
72
- return { name, agent, version };
73
- } else {
74
- return onUnknown?.(pkg.packageManager) ?? null;
75
- }
76
- }
77
- } catch {
78
- }
79
- return null;
80
- }
81
- async function fileExists(filePath) {
82
- try {
83
- const stats = await fsPromises.stat(filePath);
84
- if (stats.isFile()) {
85
- return true;
86
- }
87
- } catch {
88
- }
89
- return false;
90
- }
91
-
92
- // src/detect.ts
93
- async function detectPackageManager(cwd = process.cwd()) {
94
- const result = await detect({
95
- cwd,
96
- onUnknown(packageManager) {
97
- console.warn("[@antfu/install-pkg] Unknown packageManager:", packageManager);
98
- return void 0;
99
- }
100
- });
101
- return result?.agent || null;
102
- }
103
- async function installPackage(names, options = {}) {
104
- const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
105
- const [agent] = detectedAgent.split("@");
106
- if (!Array.isArray(names))
107
- names = [names];
108
- const args = (typeof options.additionalArgs === "function" ? options.additionalArgs(agent, detectedAgent) : options.additionalArgs) || [];
109
- if (options.preferOffline) {
110
- if (detectedAgent === "yarn@berry")
111
- args.unshift("--cached");
112
- else
113
- args.unshift("--prefer-offline");
114
- }
115
- if (agent === "pnpm" && existsSync(resolve(options.cwd ?? process.cwd(), "pnpm-workspace.yaml"))) {
116
- args.unshift(
117
- "-w",
118
- /**
119
- * Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production`
120
- * @see https://pnpm.io/cli/install#--prod--p
121
- */
122
- "--prod=false"
123
- );
124
- }
125
- return x(
126
- agent,
127
- [
128
- agent === "yarn" ? "add" : "install",
129
- options.dev ? "-D" : "",
130
- ...args,
131
- ...names
132
- ].filter(Boolean),
133
- {
134
- nodeOptions: {
135
- stdio: options.silent ? "ignore" : "inherit",
136
- cwd: options.cwd
137
- },
138
- throwOnError: true
139
- }
140
- );
141
- }
142
-
143
- export { detectPackageManager, installPackage };