vitest 1.6.0 → 2.0.0-beta.2

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 +172 -0
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/browser.js +4 -4
  4. package/dist/chunks/{environments-node.vcoXCoKs.js → environments-node.39w4gmlF.js} +2 -2
  5. package/dist/chunks/{install-pkg.LE8oaA1t.js → install-pkg.DNUmWFkO.js} +2 -2
  6. package/dist/chunks/integrations-globals.B5Jl0grA.js +31 -0
  7. package/dist/chunks/{runtime-console.EO5ha7qv.js → runtime-console.CUES-L8X.js} +9 -9
  8. package/dist/chunks/{runtime-runBaseTests.oAvMKtQC.js → runtime-runBaseTests._dXkRAZc.js} +18 -18
  9. package/dist/cli.js +3 -3
  10. package/dist/config.cjs +2 -3
  11. package/dist/config.d.ts +1 -1
  12. package/dist/config.js +2 -3
  13. package/dist/coverage.d.ts +1 -1
  14. package/dist/coverage.js +2 -2
  15. package/dist/environments.d.ts +1 -1
  16. package/dist/environments.js +1 -1
  17. package/dist/execute.d.ts +2 -1
  18. package/dist/execute.js +2 -2
  19. package/dist/index.d.ts +769 -21
  20. package/dist/index.js +12 -12
  21. package/dist/node.d.ts +2 -2
  22. package/dist/node.js +20 -21
  23. package/dist/{reporters-yx5ZTtEV.d.ts → reporters-DFgqsvtL.d.ts} +29 -32
  24. package/dist/reporters.d.ts +1 -1
  25. package/dist/reporters.js +10 -11
  26. package/dist/runners.d.ts +1 -1
  27. package/dist/runners.js +17 -18
  28. package/dist/snapshot.js +3 -3
  29. package/dist/{suite-IbNSsUWN.d.ts → suite-C_sqQjdz.d.ts} +1 -1
  30. package/dist/suite.d.ts +2 -2
  31. package/dist/suite.js +4 -4
  32. package/dist/vendor/{base.Ybri3C14.js → base.VFkIJ66g.js} +3 -3
  33. package/dist/vendor/{base.5NT-gWu5.js → base._gnK9Slw.js} +1 -2
  34. package/dist/vendor/{benchmark.yGkUTKnC.js → benchmark.BNLebNi5.js} +1 -1
  35. package/dist/vendor/{cac.EdDItJD-.js → cac.CtP0aXu-.js} +5 -6
  36. package/dist/vendor/{cli-api.E07AF1Yq.js → cli-api.B2QW76dQ.js} +3061 -362
  37. package/dist/vendor/{execute.fL3szUAI.js → execute.CLLNVNnK.js} +1 -1
  38. package/dist/vendor/{index.DpVgvm2P.js → index.BfoZyXD1.js} +5 -5
  39. package/dist/vendor/{index.8bPxjt7g.js → index.BpSiYbpB.js} +5 -1
  40. package/dist/vendor/{index.Q04MCqDO.js → index.CRxYS9H3.js} +414 -113
  41. package/dist/vendor/{index.dI9lHwVn.js → index.CmILuxzC.js} +8 -6
  42. package/dist/vendor/{index.xL8XjTLv.js → index.DP-km6lF.js} +1 -1
  43. package/dist/vendor/{index.SMVOaj7F.js → index._7XLd8Kd.js} +2 -2
  44. package/dist/vendor/{rpc.joBhAkyK.js → rpc.DRDE9Pu1.js} +2 -2
  45. package/dist/vendor/{run-once.Olz_Zkd8.js → run-once.DLomgGUH.js} +1 -1
  46. package/dist/vendor/{setup-common.8nJLd4ay.js → setup-common.XeoZAW8t.js} +2 -2
  47. package/dist/vendor/{tasks.IknbGB2n.js → tasks.WC7M-K-v.js} +4 -1
  48. package/dist/vendor/{utils.dEtNIEgr.js → utils.D5gGkwyH.js} +1 -1
  49. package/dist/vendor/{vi.YFlodzP_.js → vi.ClD3hi7L.js} +23 -10
  50. package/dist/vendor/{vm.QEE48c0T.js → vm.Bi3bljci.js} +47 -59
  51. package/dist/worker.js +6 -6
  52. package/dist/workers/forks.js +5 -5
  53. package/dist/workers/runVmTests.js +17 -17
  54. package/dist/workers/threads.js +5 -5
  55. package/dist/workers/vmForks.js +8 -8
  56. package/dist/workers/vmThreads.js +8 -8
  57. package/dist/workers.d.ts +1 -1
  58. package/dist/workers.js +13 -13
  59. package/package.json +29 -29
  60. package/vitest.mjs +1 -1
  61. package/dist/chunks/integrations-globals.kw4co3rx.js +0 -31
  62. package/dist/cli-wrapper.js +0 -119
  63. /package/dist/chunks/{node-git.Hw101KjS.js → node-git.CCI8evVZ.js} +0 -0
  64. /package/dist/vendor/{_commonjsHelpers.jjO7Zipk.js → _commonjsHelpers.BFTU3MAI.js} +0 -0
  65. /package/dist/vendor/{constants.5J7I254_.js → constants.5SOfHUj0.js} +0 -0
  66. /package/dist/vendor/{coverage.E7sG1b3r.js → coverage.ChSqD-qS.js} +0 -0
  67. /package/dist/vendor/{date.Ns1pGd_X.js → date.BKM1wewY.js} +0 -0
  68. /package/dist/vendor/{env.AtSIuHFg.js → env.bmJgw1qP.js} +0 -0
  69. /package/dist/vendor/{global.CkGT_TMy.js → global.7bFbnyXl.js} +0 -0
  70. /package/dist/vendor/{index.GVFv9dZ0.js → index.DeR1hhfY.js} +0 -0
  71. /package/dist/vendor/{inspector.IgLX3ur5.js → inspector.hPQncR7V.js} +0 -0
  72. /package/dist/vendor/{utils.0uYuCbzo.js → utils.CUjzkRH7.js} +0 -0
package/dist/workers.js CHANGED
@@ -1,30 +1,30 @@
1
- export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './vendor/utils.0uYuCbzo.js';
2
- export { p as provideWorkerState } from './vendor/global.CkGT_TMy.js';
1
+ export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './vendor/utils.CUjzkRH7.js';
2
+ export { p as provideWorkerState } from './vendor/global.7bFbnyXl.js';
3
3
  export { run as runVitestWorker } from './worker.js';
4
- export { r as runVmTests } from './vendor/vm.QEE48c0T.js';
5
- export { r as runBaseTests } from './vendor/base.Ybri3C14.js';
4
+ export { r as runVmTests } from './vendor/vm.Bi3bljci.js';
5
+ export { r as runBaseTests } from './vendor/base.VFkIJ66g.js';
6
6
  import '@vitest/utils';
7
7
  import 'node:url';
8
8
  import 'tinypool';
9
9
  import 'vite-node/client';
10
10
  import 'node:fs';
11
11
  import 'pathe';
12
- import './vendor/index.GVFv9dZ0.js';
12
+ import './vendor/index.DeR1hhfY.js';
13
13
  import 'node:console';
14
- import './vendor/base.5NT-gWu5.js';
15
- import './vendor/inspector.IgLX3ur5.js';
14
+ import './vendor/base._gnK9Slw.js';
15
+ import './vendor/inspector.hPQncR7V.js';
16
16
  import 'node:module';
17
- import './vendor/rpc.joBhAkyK.js';
18
- import './vendor/index.8bPxjt7g.js';
17
+ import './vendor/rpc.DRDE9Pu1.js';
18
+ import './vendor/index.BpSiYbpB.js';
19
19
  import 'node:vm';
20
- import './chunks/runtime-console.EO5ha7qv.js';
20
+ import './chunks/runtime-console.CUES-L8X.js';
21
21
  import 'node:stream';
22
22
  import 'node:path';
23
- import './vendor/date.Ns1pGd_X.js';
23
+ import './vendor/date.BKM1wewY.js';
24
24
  import '@vitest/runner/utils';
25
- import './vendor/env.AtSIuHFg.js';
25
+ import './vendor/env.bmJgw1qP.js';
26
26
  import 'std-env';
27
- import './vendor/execute.fL3szUAI.js';
27
+ import './vendor/execute.CLLNVNnK.js';
28
28
  import 'vite-node/utils';
29
29
  import '@vitest/utils/error';
30
30
  import './path.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "1.6.0",
4
+ "version": "2.0.0-beta.2",
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",
120
120
  "happy-dom": "*",
121
121
  "jsdom": "*",
122
- "@vitest/browser": "1.6.0",
123
- "@vitest/ui": "1.6.0"
122
+ "@vitest/ui": "2.0.0-beta.2",
123
+ "@vitest/browser": "2.0.0-beta.2"
124
124
  },
125
125
  "peerDependenciesMeta": {
126
126
  "@edge-runtime/vm": {
@@ -143,58 +143,58 @@
143
143
  }
144
144
  },
145
145
  "dependencies": {
146
- "acorn-walk": "^8.3.2",
147
- "chai": "^4.3.10",
146
+ "chai": "^5.1.1",
148
147
  "debug": "^4.3.4",
149
148
  "execa": "^8.0.1",
150
- "local-pkg": "^0.5.0",
151
- "magic-string": "^0.30.5",
152
- "pathe": "^1.1.1",
149
+ "magic-string": "^0.30.10",
150
+ "pathe": "^1.1.2",
153
151
  "picocolors": "^1.0.0",
154
- "std-env": "^3.5.0",
155
- "strip-literal": "^2.0.0",
156
- "tinybench": "^2.5.1",
157
- "tinypool": "^0.8.3",
152
+ "std-env": "^3.7.0",
153
+ "tinybench": "^2.8.0",
154
+ "tinypool": "^0.8.4",
158
155
  "vite": "^5.0.0",
159
156
  "why-is-node-running": "^2.2.2",
160
- "@vitest/expect": "1.6.0",
161
- "@vitest/runner": "1.6.0",
162
- "@vitest/snapshot": "1.6.0",
163
- "@vitest/spy": "1.6.0",
164
- "vite-node": "1.6.0",
165
- "@vitest/utils": "1.6.0"
157
+ "@vitest/expect": "2.0.0-beta.2",
158
+ "@vitest/runner": "2.0.0-beta.2",
159
+ "@vitest/spy": "2.0.0-beta.2",
160
+ "@vitest/snapshot": "2.0.0-beta.2",
161
+ "@vitest/utils": "2.0.0-beta.2",
162
+ "vite-node": "2.0.0-beta.2"
166
163
  },
167
164
  "devDependencies": {
168
- "@ampproject/remapping": "^2.2.1",
169
- "@antfu/install-pkg": "^0.3.1",
170
- "@edge-runtime/vm": "^3.1.8",
165
+ "@ampproject/remapping": "^2.3.0",
166
+ "@antfu/install-pkg": "0.3.1",
167
+ "@edge-runtime/vm": "^3.2.0",
171
168
  "@sinonjs/fake-timers": "11.1.0",
172
169
  "@types/estree": "^1.0.5",
173
170
  "@types/istanbul-lib-coverage": "^2.0.6",
174
171
  "@types/istanbul-reports": "^3.0.4",
175
172
  "@types/jsdom": "^21.1.6",
176
- "@types/micromatch": "^4.0.6",
177
- "@types/node": "^20.11.5",
173
+ "@types/micromatch": "^4.0.7",
174
+ "@types/node": "^20.12.11",
178
175
  "@types/prompts": "^2.4.9",
179
176
  "@types/sinonjs__fake-timers": "^8.1.5",
180
- "birpc": "0.2.15",
177
+ "acorn-walk": "^8.3.2",
178
+ "birpc": "0.2.17",
181
179
  "cac": "^6.7.14",
182
180
  "chai-subset": "^1.6.0",
183
181
  "cli-truncate": "^4.0.0",
184
- "expect-type": "^0.17.3",
182
+ "expect-type": "^0.19.0",
185
183
  "fast-glob": "^3.3.2",
186
184
  "find-up": "^6.3.0",
187
- "flatted": "^3.2.9",
188
- "get-tsconfig": "^4.7.3",
189
- "happy-dom": "^14.3.10",
185
+ "flatted": "^3.3.1",
186
+ "get-tsconfig": "^4.7.4",
187
+ "happy-dom": "^14.10.1",
190
188
  "jsdom": "^24.0.0",
189
+ "local-pkg": "^0.5.0",
191
190
  "log-update": "^5.0.1",
192
191
  "micromatch": "^4.0.5",
193
192
  "p-limit": "^5.0.0",
194
193
  "pretty-format": "^29.7.0",
195
194
  "prompts": "^2.4.2",
196
195
  "strip-ansi": "^7.1.0",
197
- "ws": "^8.14.2"
196
+ "strip-literal": "^2.1.0",
197
+ "ws": "^8.17.0"
198
198
  },
199
199
  "scripts": {
200
200
  "build": "rimraf dist && rollup -c",
package/vitest.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import './dist/cli-wrapper.js'
2
+ import './dist/cli.js'
@@ -1,31 +0,0 @@
1
- import { g as globalApis } from '../vendor/constants.5J7I254_.js';
2
- import { V as VitestIndex } from '../vendor/index.dI9lHwVn.js';
3
- import '@vitest/runner';
4
- import '../vendor/benchmark.yGkUTKnC.js';
5
- import '@vitest/runner/utils';
6
- import '@vitest/utils';
7
- import '../vendor/index.SMVOaj7F.js';
8
- import 'pathe';
9
- import '../vendor/global.CkGT_TMy.js';
10
- import '../vendor/env.AtSIuHFg.js';
11
- import 'std-env';
12
- import '../vendor/run-once.Olz_Zkd8.js';
13
- import '../vendor/vi.YFlodzP_.js';
14
- import 'chai';
15
- import '../vendor/_commonjsHelpers.jjO7Zipk.js';
16
- import '@vitest/expect';
17
- import '@vitest/snapshot';
18
- import '@vitest/utils/error';
19
- import '../vendor/tasks.IknbGB2n.js';
20
- import '@vitest/utils/source-map';
21
- import '../vendor/base.5NT-gWu5.js';
22
- import '../vendor/date.Ns1pGd_X.js';
23
- import '@vitest/spy';
24
-
25
- function registerApiGlobally() {
26
- globalApis.forEach((api) => {
27
- globalThis[api] = VitestIndex[api];
28
- });
29
- }
30
-
31
- export { registerApiGlobally };
@@ -1,119 +0,0 @@
1
- import { fileURLToPath } from 'node:url';
2
- import c from 'picocolors';
3
- import { execa } from 'execa';
4
- import { E as EXIT_CODE_RESTART } from './vendor/constants.5J7I254_.js';
5
-
6
- const ENTRY = new URL("./cli.js", import.meta.url);
7
- const NODE_ARGS = [
8
- "--trace-deprecation",
9
- "--experimental-wasm-threads",
10
- "--wasm-atomics-on-non-shared-memory"
11
- ];
12
- const SegfaultErrors = [
13
- {
14
- trigger: "Check failed: result.second.",
15
- url: "https://github.com/nodejs/node/issues/43617"
16
- },
17
- {
18
- trigger: "FATAL ERROR: v8::FromJust Maybe value is Nothing.",
19
- url: "https://github.com/vitest-dev/vitest/issues/1191"
20
- },
21
- {
22
- trigger: "FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.",
23
- url: "https://github.com/nodejs/node/issues/42407"
24
- }
25
- ];
26
- main();
27
- async function main() {
28
- var _a;
29
- let retries = 0;
30
- const args = process.argv.slice(2);
31
- if (process.env.VITEST_SEGFAULT_RETRY) {
32
- retries = +process.env.VITEST_SEGFAULT_RETRY;
33
- } else {
34
- for (let i = 0; i < args.length; i++) {
35
- if (args[i].startsWith("--segfault-retry=") || args[i].startsWith("--segfaultRetry=")) {
36
- retries = +args[i].split("=")[1];
37
- break;
38
- } else if ((args[i] === "--segfault-retry" || args[i] === "--segfaultRetry") && ((_a = args[i + 1]) == null ? void 0 : _a.match(/^\d+$/))) {
39
- retries = +args[i + 1];
40
- break;
41
- }
42
- }
43
- }
44
- if (retries <= 0) {
45
- await import('./cli.js');
46
- return;
47
- }
48
- const nodeArgs = [];
49
- const vitestArgs = [];
50
- for (let i = 0; i < args.length; i++) {
51
- let matched = false;
52
- for (const nodeArg of NODE_ARGS) {
53
- if (args[i] === nodeArg || args[i].startsWith(`${nodeArg}=`)) {
54
- matched = true;
55
- nodeArgs.push(args[i]);
56
- break;
57
- }
58
- }
59
- if (!matched)
60
- vitestArgs.push(args[i]);
61
- }
62
- retries = Math.max(1, retries || 1);
63
- for (let i = 1; i <= retries; i++) {
64
- const result = await start(nodeArgs, vitestArgs);
65
- if (result === "restart") {
66
- i -= 1;
67
- continue;
68
- }
69
- if (i === 1 && retries === 1) {
70
- console.log(c.yellow(`It seems to be an upstream bug of Node.js. To improve the test stability,
71
- you could pass ${c.bold(c.green("--segfault-retry=3"))} or set env ${c.bold(c.green("VITEST_SEGFAULT_RETRY=3"))} to
72
- have Vitest auto retries on flaky segfaults.
73
- `));
74
- }
75
- if (i !== retries)
76
- console.log(`${c.inverse(c.bold(c.magenta(" Retrying ")))} vitest ${args.join(" ")} ${c.gray(`(${i + 1} of ${retries})`)}`);
77
- }
78
- process.exit(1);
79
- }
80
- async function start(preArgs, postArgs) {
81
- var _a;
82
- const child = execa(
83
- "node",
84
- [
85
- ...preArgs,
86
- fileURLToPath(ENTRY),
87
- ...postArgs
88
- ],
89
- {
90
- reject: false,
91
- stderr: "pipe",
92
- stdout: "inherit",
93
- stdin: "inherit",
94
- env: {
95
- ...process.env,
96
- VITEST_CLI_WRAPPER: "true"
97
- }
98
- }
99
- );
100
- (_a = child.stderr) == null ? void 0 : _a.pipe(process.stderr);
101
- const { stderr = "" } = await child;
102
- if (child.exitCode === EXIT_CODE_RESTART)
103
- return "restart";
104
- for (const error of SegfaultErrors) {
105
- if (stderr.includes(error.trigger)) {
106
- if (process.env.GITHUB_ACTIONS)
107
- console.log(`::warning:: Segmentfault Error Detected: ${error.trigger}
108
- Refer to ${error.url}`);
109
- const RED_BLOCK = c.inverse(c.red(" "));
110
- console.log(`
111
- ${c.inverse(c.bold(c.red(" Segmentfault Error Detected ")))}
112
- ${RED_BLOCK} ${c.red(error.trigger)}
113
- ${RED_BLOCK} ${c.red(`Refer to ${error.url}`)}
114
- `);
115
- return "error";
116
- }
117
- }
118
- process.exit(child.exitCode);
119
- }