vitest 2.1.0-beta.5 → 2.1.0-beta.6

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 (46) hide show
  1. package/LICENSE.md +29 -0
  2. package/dist/browser.d.ts +4 -3
  3. package/dist/browser.js +2 -2
  4. package/dist/chunks/{RandomSequencer.B4M2ux5b.js → RandomSequencer.CjkAy_bL.js} +67 -21
  5. package/dist/chunks/{base.BYvKfYzm.js → base.B-9RAXb6.js} +1 -1
  6. package/dist/chunks/{cac.DosbLiJg.js → cac.BZlOqtiQ.js} +5 -5
  7. package/dist/chunks/{cli-api.D8zgNrBU.js → cli-api.B-2f6g4d.js} +7525 -7355
  8. package/dist/chunks/{constants.CaAN7icJ.js → constants.fzPh7AOq.js} +1 -1
  9. package/dist/chunks/{coverage.CqfT4xaf.js → coverage.zlNdAMHK.js} +5 -3
  10. package/dist/chunks/{creator.COdKw_ZN.js → creator.D0TxjnLa.js} +5 -2
  11. package/dist/chunks/{environment.0M5R1SX_.d.ts → environment.C5eAp3K6.d.ts} +1 -1
  12. package/dist/chunks/{globals.DRPLtPOv.js → globals.Br36EZIp.js} +3 -3
  13. package/dist/chunks/{index.Dx3f477d.js → index.C4LZENmc.js} +4432 -4422
  14. package/dist/chunks/index.CWhwfxXK.js +835 -0
  15. package/dist/chunks/{index.CxWPpGJz.js → index.dWDhoZDV.js} +2 -2
  16. package/dist/chunks/{index.CNZXZ9PJ.js → index.m3Xip5Zz.js} +1 -1
  17. package/dist/chunks/{reporters.DbwOGCsU.d.ts → reporters.B0Ao6Zu1.d.ts} +134 -117
  18. package/dist/chunks/{resolveConfig.RHsAM2_Q.js → resolveConfig.C0vpvVRF.js} +42 -33
  19. package/dist/chunks/{runBaseTests.BAhL8UH_.js → runBaseTests.Cf8lGnUq.js} +5 -5
  20. package/dist/chunks/{setup-common.KBrCO5LJ.js → setup-common.B7uEQsGB.js} +1 -1
  21. package/dist/chunks/{vi.B6QZ938s.js → vi.DBepMgvg.js} +9 -0
  22. package/dist/chunks/vite.Bvz2vSw0.d.ts +11 -0
  23. package/dist/chunks/{worker.BANO5ak1.d.ts → worker.CTdJUeeB.d.ts} +3 -2
  24. package/dist/chunks/{worker.Cx2xE71X.d.ts → worker.DTM-0OlZ.d.ts} +1 -1
  25. package/dist/cli.js +2 -2
  26. package/dist/config.cjs +1 -0
  27. package/dist/config.d.ts +70 -2
  28. package/dist/config.js +1 -0
  29. package/dist/coverage.d.ts +4 -3
  30. package/dist/coverage.js +27 -3
  31. package/dist/environments.d.ts +2 -2
  32. package/dist/execute.d.ts +2 -2
  33. package/dist/index.d.ts +11 -6
  34. package/dist/index.js +3 -3
  35. package/dist/node.d.ts +17 -7
  36. package/dist/node.js +39 -36
  37. package/dist/reporters.d.ts +2 -2
  38. package/dist/reporters.js +5 -5
  39. package/dist/runners.js +1 -1
  40. package/dist/workers/forks.js +1 -1
  41. package/dist/workers/runVmTests.js +5 -5
  42. package/dist/workers/threads.js +1 -1
  43. package/dist/workers.d.ts +4 -16
  44. package/dist/workers.js +1 -1
  45. package/package.json +12 -12
  46. package/dist/chunks/index.DNUmWFkO.js +0 -319
@@ -1,4 +1,4 @@
1
- import { r as runBaseTests } from '../chunks/base.BYvKfYzm.js';
1
+ import { r as runBaseTests } from '../chunks/base.B-9RAXb6.js';
2
2
  import { a as createThreadsRpcOptions } from '../chunks/utils.C3_cBsyn.js';
3
3
  import 'vite-node/client';
4
4
  import '../chunks/utils.Ck2hJTRs.js';
package/dist/workers.d.ts CHANGED
@@ -1,27 +1,15 @@
1
1
  import * as v8 from 'v8';
2
2
  import { S as SerializedConfig } from './chunks/config.CHuotKvS.js';
3
- import './chunks/reporters.DbwOGCsU.js';
4
- import { W as WorkerContext } from './chunks/worker.Cx2xE71X.js';
5
- import { B as BirpcOptions, R as RuntimeRPC, C as ContextRPC, W as WorkerGlobalState } from './chunks/worker.BANO5ak1.js';
3
+ import { W as WorkerContext } from './chunks/worker.DTM-0OlZ.js';
4
+ import { B as BirpcOptions, R as RuntimeRPC, C as ContextRPC, W as WorkerGlobalState } from './chunks/worker.CTdJUeeB.js';
6
5
  import { Awaitable } from '@vitest/utils';
7
6
  import '@vitest/pretty-format';
8
7
  import '@vitest/runner';
9
8
  import '@vitest/snapshot';
10
9
  import '@vitest/snapshot/environment';
11
- import 'vite';
12
- import 'vite-node';
13
- import './chunks/environment.0M5R1SX_.js';
14
- import 'node:stream';
15
- import 'vite-node/client';
16
- import '@vitest/snapshot/manager';
17
- import 'vite-node/server';
18
- import '@vitest/utils/source-map';
19
- import 'node:fs';
20
- import 'chai';
21
- import './chunks/benchmark.puBFxyfE.js';
22
- import '@vitest/runner/utils';
23
- import 'tinybench';
24
10
  import 'node:worker_threads';
11
+ import 'vite-node';
12
+ import './chunks/environment.C5eAp3K6.js';
25
13
 
26
14
  type WorkerRpcOptions = Pick<BirpcOptions<RuntimeRPC>, 'on' | 'post' | 'serialize' | 'deserialize'>;
27
15
  interface VitestWorker {
package/dist/workers.js CHANGED
@@ -2,7 +2,7 @@ export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSe
2
2
  export { p as provideWorkerState } from './chunks/utils.Ck2hJTRs.js';
3
3
  export { collect as collectVitestWorkerTests, run as runVitestWorker } from './worker.js';
4
4
  export { r as runVmTests } from './chunks/vm.kl9T_5ai.js';
5
- export { r as runBaseTests } from './chunks/base.BYvKfYzm.js';
5
+ export { r as runBaseTests } from './chunks/base.B-9RAXb6.js';
6
6
  import '@vitest/utils';
7
7
  import 'node:url';
8
8
  import 'tinypool';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "2.1.0-beta.5",
4
+ "version": "2.1.0-beta.6",
5
5
  "description": "Next generation testing framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -118,8 +118,8 @@
118
118
  "@types/node": "^18.0.0 || >=20.0.0",
119
119
  "happy-dom": "*",
120
120
  "jsdom": "*",
121
- "@vitest/ui": "2.1.0-beta.5",
122
- "@vitest/browser": "2.1.0-beta.5"
121
+ "@vitest/browser": "2.1.0-beta.6",
122
+ "@vitest/ui": "2.1.0-beta.6"
123
123
  },
124
124
  "peerDependenciesMeta": {
125
125
  "@edge-runtime/vm": {
@@ -154,16 +154,16 @@
154
154
  "tinyrainbow": "^1.2.0",
155
155
  "vite": "^5.0.0",
156
156
  "why-is-node-running": "^2.3.0",
157
- "@vitest/expect": "2.1.0-beta.5",
158
- "@vitest/runner": "2.1.0-beta.5",
159
- "@vitest/spy": "2.1.0-beta.5",
160
- "@vitest/utils": "2.1.0-beta.5",
161
- "@vitest/pretty-format": "^2.1.0-beta.5",
162
- "vite-node": "2.1.0-beta.5",
163
- "@vitest/snapshot": "2.1.0-beta.5"
157
+ "@vitest/pretty-format": "^2.1.0-beta.6",
158
+ "@vitest/runner": "2.1.0-beta.6",
159
+ "@vitest/expect": "2.1.0-beta.6",
160
+ "@vitest/spy": "2.1.0-beta.6",
161
+ "@vitest/utils": "2.1.0-beta.6",
162
+ "@vitest/snapshot": "2.1.0-beta.6",
163
+ "vite-node": "2.1.0-beta.6"
164
164
  },
165
165
  "devDependencies": {
166
- "@antfu/install-pkg": "0.3.1",
166
+ "@antfu/install-pkg": "^0.3.4",
167
167
  "@edge-runtime/vm": "^4.0.1",
168
168
  "@sinonjs/fake-timers": "11.1.0",
169
169
  "@types/debug": "^4.1.12",
@@ -172,7 +172,7 @@
172
172
  "@types/istanbul-reports": "^3.0.4",
173
173
  "@types/jsdom": "^21.1.7",
174
174
  "@types/micromatch": "^4.0.9",
175
- "@types/node": "^20.14.14",
175
+ "@types/node": "^20.14.15",
176
176
  "@types/prompts": "^2.4.9",
177
177
  "@types/sinonjs__fake-timers": "^8.1.5",
178
178
  "acorn-walk": "^8.3.3",
@@ -1,319 +0,0 @@
1
- import require$$0, { promises } from 'fs';
2
- import p from 'path';
3
- import process from 'process';
4
- import { fileURLToPath } from 'url';
5
- import { execa } from 'execa';
6
-
7
- var __defProp = Object.defineProperty;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __publicField = (obj, key, value) => {
10
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
11
- return value;
12
- };
13
- var __accessCheck = (obj, member, msg) => {
14
- if (!member.has(obj))
15
- throw TypeError("Cannot " + msg);
16
- };
17
- var __privateGet = (obj, member, getter) => {
18
- __accessCheck(obj, member, "read from private field");
19
- return getter ? getter.call(obj) : member.get(obj);
20
- };
21
- var __privateAdd = (obj, member, value) => {
22
- if (member.has(obj))
23
- throw TypeError("Cannot add the same private member more than once");
24
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
25
- };
26
- var __privateSet = (obj, member, value, setter) => {
27
- __accessCheck(obj, member, "write to private field");
28
- member.set(obj, value);
29
- return value;
30
- };
31
- var __privateWrapper = (obj, member, setter, getter) => ({
32
- set _(value) {
33
- __privateSet(obj, member, value);
34
- },
35
- get _() {
36
- return __privateGet(obj, member, getter);
37
- }
38
- });
39
-
40
- // node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
41
- var Node = class {
42
- constructor(value) {
43
- __publicField(this, "value");
44
- __publicField(this, "next");
45
- this.value = value;
46
- }
47
- };
48
- var _head, _tail, _size;
49
- var Queue = class {
50
- constructor() {
51
- __privateAdd(this, _head, void 0);
52
- __privateAdd(this, _tail, void 0);
53
- __privateAdd(this, _size, void 0);
54
- this.clear();
55
- }
56
- enqueue(value) {
57
- const node = new Node(value);
58
- if (__privateGet(this, _head)) {
59
- __privateGet(this, _tail).next = node;
60
- __privateSet(this, _tail, node);
61
- } else {
62
- __privateSet(this, _head, node);
63
- __privateSet(this, _tail, node);
64
- }
65
- __privateWrapper(this, _size)._++;
66
- }
67
- dequeue() {
68
- const current = __privateGet(this, _head);
69
- if (!current) {
70
- return;
71
- }
72
- __privateSet(this, _head, __privateGet(this, _head).next);
73
- __privateWrapper(this, _size)._--;
74
- return current.value;
75
- }
76
- clear() {
77
- __privateSet(this, _head, void 0);
78
- __privateSet(this, _tail, void 0);
79
- __privateSet(this, _size, 0);
80
- }
81
- get size() {
82
- return __privateGet(this, _size);
83
- }
84
- *[Symbol.iterator]() {
85
- let current = __privateGet(this, _head);
86
- while (current) {
87
- yield current.value;
88
- current = current.next;
89
- }
90
- }
91
- };
92
- _head = new WeakMap();
93
- _tail = new WeakMap();
94
- _size = new WeakMap();
95
-
96
- // node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
97
- function pLimit(concurrency) {
98
- if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
99
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
100
- }
101
- const queue = new Queue();
102
- let activeCount = 0;
103
- const next = () => {
104
- activeCount--;
105
- if (queue.size > 0) {
106
- queue.dequeue()();
107
- }
108
- };
109
- const run = async (fn, resolve, args) => {
110
- activeCount++;
111
- const result = (async () => fn(...args))();
112
- resolve(result);
113
- try {
114
- await result;
115
- } catch {
116
- }
117
- next();
118
- };
119
- const enqueue = (fn, resolve, args) => {
120
- queue.enqueue(run.bind(void 0, fn, resolve, args));
121
- (async () => {
122
- await Promise.resolve();
123
- if (activeCount < concurrency && queue.size > 0) {
124
- queue.dequeue()();
125
- }
126
- })();
127
- };
128
- const generator = (fn, ...args) => new Promise((resolve) => {
129
- enqueue(fn, resolve, args);
130
- });
131
- Object.defineProperties(generator, {
132
- activeCount: {
133
- get: () => activeCount
134
- },
135
- pendingCount: {
136
- get: () => queue.size
137
- },
138
- clearQueue: {
139
- value: () => {
140
- queue.clear();
141
- }
142
- }
143
- });
144
- return generator;
145
- }
146
-
147
- // node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
148
- var EndError = class extends Error {
149
- constructor(value) {
150
- super();
151
- this.value = value;
152
- }
153
- };
154
- var testElement = async (element, tester) => tester(await element);
155
- var finder = async (element) => {
156
- const values = await Promise.all(element);
157
- if (values[1] === true) {
158
- throw new EndError(values[0]);
159
- }
160
- return false;
161
- };
162
- async function pLocate(iterable, tester, {
163
- concurrency = Number.POSITIVE_INFINITY,
164
- preserveOrder = true
165
- } = {}) {
166
- const limit = pLimit(concurrency);
167
- const items = [...iterable].map((element) => [element, limit(testElement, element, tester)]);
168
- const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
169
- try {
170
- await Promise.all(items.map((element) => checkLimit(finder, element)));
171
- } catch (error) {
172
- if (error instanceof EndError) {
173
- return error.value;
174
- }
175
- throw error;
176
- }
177
- }
178
-
179
- // node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
180
- var typeMappings = {
181
- directory: "isDirectory",
182
- file: "isFile"
183
- };
184
- function checkType(type) {
185
- if (Object.hasOwnProperty.call(typeMappings, type)) {
186
- return;
187
- }
188
- throw new Error(`Invalid type specified: ${type}`);
189
- }
190
- var matchType = (type, stat) => stat[typeMappings[type]]();
191
- var toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
192
- async function locatePath(paths, {
193
- cwd = process.cwd(),
194
- type = "file",
195
- allowSymlinks = true,
196
- concurrency,
197
- preserveOrder
198
- } = {}) {
199
- checkType(type);
200
- cwd = toPath(cwd);
201
- const statFunction = allowSymlinks ? promises.stat : promises.lstat;
202
- return pLocate(paths, async (path_) => {
203
- try {
204
- const stat = await statFunction(p.resolve(cwd, path_));
205
- return matchType(type, stat);
206
- } catch {
207
- return false;
208
- }
209
- }, { concurrency, preserveOrder });
210
- }
211
- function toPath2(urlOrPath) {
212
- return urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
213
- }
214
-
215
- // node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
216
- var findUpStop = Symbol("findUpStop");
217
- async function findUpMultiple(name, options = {}) {
218
- let directory = p.resolve(toPath2(options.cwd) ?? "");
219
- const { root } = p.parse(directory);
220
- const stopAt = p.resolve(directory, toPath2(options.stopAt ?? root));
221
- const limit = options.limit ?? Number.POSITIVE_INFINITY;
222
- const paths = [name].flat();
223
- const runMatcher = async (locateOptions) => {
224
- if (typeof name !== "function") {
225
- return locatePath(paths, locateOptions);
226
- }
227
- const foundPath = await name(locateOptions.cwd);
228
- if (typeof foundPath === "string") {
229
- return locatePath([foundPath], locateOptions);
230
- }
231
- return foundPath;
232
- };
233
- const matches = [];
234
- while (true) {
235
- const foundPath = await runMatcher({ ...options, cwd: directory });
236
- if (foundPath === findUpStop) {
237
- break;
238
- }
239
- if (foundPath) {
240
- matches.push(p.resolve(directory, foundPath));
241
- }
242
- if (directory === stopAt || matches.length >= limit) {
243
- break;
244
- }
245
- directory = p.dirname(directory);
246
- }
247
- return matches;
248
- }
249
- async function findUp(name, options = {}) {
250
- const matches = await findUpMultiple(name, { ...options, limit: 1 });
251
- return matches[0];
252
- }
253
-
254
- // src/detect.ts
255
- var AGENTS = ["pnpm", "yarn", "npm", "pnpm@6", "yarn@berry", "bun"];
256
- var LOCKS = {
257
- "bun.lockb": "bun",
258
- "pnpm-lock.yaml": "pnpm",
259
- "yarn.lock": "yarn",
260
- "package-lock.json": "npm",
261
- "npm-shrinkwrap.json": "npm"
262
- };
263
- async function detectPackageManager(cwd = process.cwd()) {
264
- let agent = null;
265
- const lockPath = await findUp(Object.keys(LOCKS), { cwd });
266
- let packageJsonPath;
267
- if (lockPath)
268
- packageJsonPath = p.resolve(lockPath, "../package.json");
269
- else
270
- packageJsonPath = await findUp("package.json", { cwd });
271
- if (packageJsonPath && require$$0.existsSync(packageJsonPath)) {
272
- try {
273
- const pkg = JSON.parse(require$$0.readFileSync(packageJsonPath, "utf8"));
274
- if (typeof pkg.packageManager === "string") {
275
- const [name, version] = pkg.packageManager.split("@");
276
- if (name === "yarn" && Number.parseInt(version) > 1)
277
- agent = "yarn@berry";
278
- else if (name === "pnpm" && Number.parseInt(version) < 7)
279
- agent = "pnpm@6";
280
- else if (AGENTS.includes(name))
281
- agent = name;
282
- else
283
- console.warn("[ni] Unknown packageManager:", pkg.packageManager);
284
- }
285
- } catch {
286
- }
287
- }
288
- if (!agent && lockPath)
289
- agent = LOCKS[p.basename(lockPath)];
290
- return agent;
291
- }
292
- async function installPackage(names, options = {}) {
293
- const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
294
- const [agent] = detectedAgent.split("@");
295
- if (!Array.isArray(names))
296
- names = [names];
297
- const args = options.additionalArgs || [];
298
- if (options.preferOffline) {
299
- if (detectedAgent === "yarn@berry")
300
- args.unshift("--cached");
301
- else
302
- args.unshift("--prefer-offline");
303
- }
304
- return execa(
305
- agent,
306
- [
307
- agent === "yarn" ? "add" : "install",
308
- options.dev ? "-D" : "",
309
- ...args,
310
- ...names
311
- ].filter(Boolean),
312
- {
313
- stdio: options.silent ? "ignore" : "inherit",
314
- cwd: options.cwd
315
- }
316
- );
317
- }
318
-
319
- export { detectPackageManager, installPackage };