vitest 3.0.0-beta.2 → 3.0.0-beta.4
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.
- package/LICENSE.md +1 -315
- package/config.d.ts +2 -0
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +1 -1
- package/dist/chunks/{RandomSequencer.gisBJ77r.js → RandomSequencer.DB__To1b.js} +38 -8
- package/dist/chunks/{base.CUgXReRN.js → base.BJ8KO-VX.js} +2 -2
- package/dist/chunks/{cac.Xzv7eNWw.js → cac.BAYqQ2aM.js} +21 -10
- package/dist/chunks/{cli-api.CETCDGgZ.js → cli-api.Dhl34Trr.js} +263 -58
- package/dist/chunks/{config.BTPBhmK5.d.ts → config.BRtC-JeT.d.ts} +6 -0
- package/dist/chunks/{console.BYGVloWk.js → console.CN7AiMGV.js} +16 -7
- package/dist/chunks/{creator.DcAcUhMD.js → creator.Ot9GlSGw.js} +16 -14
- package/dist/chunks/{execute.2pr0rHgK.js → execute.BMOaRArH.js} +27 -16
- package/dist/chunks/{globals.BFncSRNA.js → globals.C5RQxaV3.js} +2 -2
- package/dist/chunks/{index.DoV7W5gc.js → index.B2M9nD1V.js} +6 -1
- package/dist/chunks/{index.CkWmZCXU.js → index.BQbxGbG9.js} +1 -1
- package/dist/chunks/index.CAueP3cK.js +3205 -0
- package/dist/chunks/{reporters.DTtxC3KQ.d.ts → reporters.Dcdq51WE.d.ts} +211 -257
- package/dist/chunks/{resolveConfig.BA-_OKEx.js → resolveConfig.kZFMjKCQ.js} +28 -6
- package/dist/chunks/{runBaseTests.D0dWpzZV.js → runBaseTests.URiUrnWK.js} +8 -6
- package/dist/chunks/{setup-common.Cp_bu5q3.js → setup-common.D0zLenuv.js} +1 -1
- package/dist/chunks/{utils.CMUTX-p8.js → utils.yHKcm4dz.js} +10 -21
- package/dist/chunks/{vi.S4Fq8wSo.js → vi.Da_PT3Vw.js} +554 -272
- package/dist/chunks/{vite.CXaetSK3.d.ts → vite.DzluO1Kj.d.ts} +1 -1
- package/dist/chunks/{vm.DGhTouO3.js → vm.DrFVeTXo.js} +4 -4
- package/dist/chunks/{worker.ClntunZp.d.ts → worker.BIVMnzXw.d.ts} +1 -1
- package/dist/chunks/{worker.o1PBoDdo.d.ts → worker.Hz_LAzfd.d.ts} +2 -1
- package/dist/cli.js +1 -1
- package/dist/config.cjs +1 -0
- package/dist/config.d.ts +4 -4
- package/dist/config.js +1 -0
- package/dist/coverage.d.ts +2 -2
- package/dist/coverage.js +33 -8
- package/dist/execute.d.ts +3 -3
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +2 -2
- package/dist/node.d.ts +6 -6
- package/dist/node.js +10 -11
- package/dist/reporters.d.ts +2 -2
- package/dist/reporters.js +3 -7
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +5 -12
- package/dist/workers/forks.js +2 -2
- package/dist/workers/runVmTests.js +7 -5
- package/dist/workers/threads.js +2 -2
- package/dist/workers/vmForks.js +3 -3
- package/dist/workers/vmThreads.js +3 -3
- package/dist/workers.d.ts +3 -3
- package/dist/workers.js +4 -4
- package/package.json +17 -19
- package/dist/chunks/index.9ZEBV_TJ.js +0 -5442
|
@@ -27,13 +27,24 @@ function createCustomConsole(defaultState) {
|
|
|
27
27
|
const stdoutBuffer = /* @__PURE__ */ new Map();
|
|
28
28
|
const stderrBuffer = /* @__PURE__ */ new Map();
|
|
29
29
|
const timers = /* @__PURE__ */ new Map();
|
|
30
|
-
const {
|
|
30
|
+
const { queueMicrotask } = getSafeTimers();
|
|
31
|
+
function queueCancelableMicrotask(callback) {
|
|
32
|
+
let canceled = false;
|
|
33
|
+
queueMicrotask(() => {
|
|
34
|
+
if (!canceled) {
|
|
35
|
+
callback();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return () => {
|
|
39
|
+
canceled = true;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
31
42
|
const state = () => defaultState || getWorkerState();
|
|
32
43
|
function schedule(taskId) {
|
|
33
44
|
const timer = timers.get(taskId);
|
|
34
45
|
const { stdoutTime, stderrTime } = timer;
|
|
35
|
-
|
|
36
|
-
timer.
|
|
46
|
+
timer.cancel?.();
|
|
47
|
+
timer.cancel = queueCancelableMicrotask(() => {
|
|
37
48
|
if (stderrTime < stdoutTime) {
|
|
38
49
|
sendStderr(taskId);
|
|
39
50
|
sendStdout(taskId);
|
|
@@ -93,8 +104,7 @@ function createCustomConsole(defaultState) {
|
|
|
93
104
|
} else {
|
|
94
105
|
timer = {
|
|
95
106
|
stdoutTime: RealDate.now(),
|
|
96
|
-
stderrTime: RealDate.now()
|
|
97
|
-
timer: 0
|
|
107
|
+
stderrTime: RealDate.now()
|
|
98
108
|
};
|
|
99
109
|
timers.set(id, timer);
|
|
100
110
|
}
|
|
@@ -127,8 +137,7 @@ function createCustomConsole(defaultState) {
|
|
|
127
137
|
} else {
|
|
128
138
|
timer = {
|
|
129
139
|
stderrTime: RealDate.now(),
|
|
130
|
-
stdoutTime: RealDate.now()
|
|
131
|
-
timer: 0
|
|
140
|
+
stdoutTime: RealDate.now()
|
|
132
141
|
};
|
|
133
142
|
timers.set(id, timer);
|
|
134
143
|
}
|
|
@@ -421,9 +421,9 @@ function getPossibleProvider(dependencies) {
|
|
|
421
421
|
function getProviderDocsLink(provider) {
|
|
422
422
|
switch (provider) {
|
|
423
423
|
case "playwright":
|
|
424
|
-
return "https://
|
|
424
|
+
return "https://vitest.dev/guide/browser/playwright";
|
|
425
425
|
case "webdriverio":
|
|
426
|
-
return "https://
|
|
426
|
+
return "https://vitest.dev/guide/browser/webdriverio";
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
429
|
function sort(choices, value) {
|
|
@@ -450,10 +450,11 @@ async function generateWorkspaceFile(options) {
|
|
|
450
450
|
` test: {`,
|
|
451
451
|
` browser: {`,
|
|
452
452
|
` enabled: true,`,
|
|
453
|
-
` name: '${options.browser}',`,
|
|
454
453
|
` provider: '${options.provider}',`,
|
|
455
454
|
options.provider !== "preview" && ` // ${getProviderDocsLink(options.provider)}`,
|
|
456
|
-
|
|
455
|
+
` configs: [`,
|
|
456
|
+
...options.browsers.map((browser) => ` { browser: '${browser}' },`),
|
|
457
|
+
` ],`,
|
|
457
458
|
` },`,
|
|
458
459
|
` },`,
|
|
459
460
|
` },`,
|
|
@@ -473,10 +474,11 @@ async function generateFrameworkConfigFile(options) {
|
|
|
473
474
|
` test: {`,
|
|
474
475
|
` browser: {`,
|
|
475
476
|
` enabled: true,`,
|
|
476
|
-
` name: '${options.browser}',`,
|
|
477
477
|
` provider: '${options.provider}',`,
|
|
478
478
|
options.provider !== "preview" && ` // ${getProviderDocsLink(options.provider)}`,
|
|
479
|
-
|
|
479
|
+
` configs: [`,
|
|
480
|
+
...options.browsers.map((browser) => ` { browser: '${browser}' },`),
|
|
481
|
+
` ],`,
|
|
480
482
|
` },`,
|
|
481
483
|
` },`,
|
|
482
484
|
`})`,
|
|
@@ -557,13 +559,13 @@ async function create() {
|
|
|
557
559
|
if (!provider) {
|
|
558
560
|
return fail();
|
|
559
561
|
}
|
|
560
|
-
const {
|
|
561
|
-
type: "
|
|
562
|
-
name: "
|
|
562
|
+
const { browsers } = await prompt({
|
|
563
|
+
type: "multiselect",
|
|
564
|
+
name: "browsers",
|
|
563
565
|
message: "Choose a browser",
|
|
564
|
-
choices: getBrowserNames(provider).map((
|
|
565
|
-
title:
|
|
566
|
-
value:
|
|
566
|
+
choices: getBrowserNames(provider).map((browser) => ({
|
|
567
|
+
title: browser,
|
|
568
|
+
value: browser
|
|
567
569
|
}))
|
|
568
570
|
});
|
|
569
571
|
if (!provider) {
|
|
@@ -626,7 +628,7 @@ async function create() {
|
|
|
626
628
|
configPath: browserWorkspaceFile,
|
|
627
629
|
rootConfig,
|
|
628
630
|
provider,
|
|
629
|
-
|
|
631
|
+
browsers
|
|
630
632
|
});
|
|
631
633
|
log(c.green("\u2714"), "Created a workspace file for browser tests:", c.bold(relative(process.cwd(), browserWorkspaceFile)));
|
|
632
634
|
} else {
|
|
@@ -636,7 +638,7 @@ async function create() {
|
|
|
636
638
|
framework,
|
|
637
639
|
frameworkPlugin,
|
|
638
640
|
provider,
|
|
639
|
-
|
|
641
|
+
browsers
|
|
640
642
|
});
|
|
641
643
|
log(c.green("\u2714"), "Created a config file for browser tests", c.bold(relative(process.cwd(), configPath)));
|
|
642
644
|
}
|
|
@@ -21,6 +21,8 @@ function normalizeWindowsPath(input = "") {
|
|
|
21
21
|
const _UNC_REGEX = /^[/\\]{2}/;
|
|
22
22
|
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
23
23
|
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
24
|
+
const _EXTNAME_RE = /.(\.[^./]+)$/;
|
|
25
|
+
globalThis.process?.platform === "win32" ? ";" : ":";
|
|
24
26
|
const normalize = function(path) {
|
|
25
27
|
if (path.length === 0) {
|
|
26
28
|
return ".";
|
|
@@ -50,24 +52,26 @@ const normalize = function(path) {
|
|
|
50
52
|
}
|
|
51
53
|
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
52
54
|
};
|
|
53
|
-
const join = function(...
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
const join = function(...segments) {
|
|
56
|
+
let path = "";
|
|
57
|
+
for (const seg of segments) {
|
|
58
|
+
if (!seg) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (path.length > 0) {
|
|
62
|
+
const pathTrailing = path[path.length - 1] === "/";
|
|
63
|
+
const segLeading = seg[0] === "/";
|
|
64
|
+
const both = pathTrailing && segLeading;
|
|
65
|
+
if (both) {
|
|
66
|
+
path += seg.slice(1);
|
|
62
67
|
} else {
|
|
63
|
-
|
|
68
|
+
path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
64
69
|
}
|
|
70
|
+
} else {
|
|
71
|
+
path += seg;
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
|
-
|
|
68
|
-
return ".";
|
|
69
|
-
}
|
|
70
|
-
return normalize(joined.replace(/\/\/+/g, "/"));
|
|
74
|
+
return normalize(path);
|
|
71
75
|
};
|
|
72
76
|
function cwd() {
|
|
73
77
|
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
@@ -156,7 +160,6 @@ function normalizeString(path, allowAboveRoot) {
|
|
|
156
160
|
const isAbsolute = function(p) {
|
|
157
161
|
return _IS_ABSOLUTE_RE.test(p);
|
|
158
162
|
};
|
|
159
|
-
const _EXTNAME_RE = /.(\.[^./]+)$/;
|
|
160
163
|
const extname = function(p) {
|
|
161
164
|
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
162
165
|
return match && match[1] || "";
|
|
@@ -169,7 +172,15 @@ const dirname = function(p) {
|
|
|
169
172
|
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
170
173
|
};
|
|
171
174
|
const basename = function(p, extension) {
|
|
172
|
-
const
|
|
175
|
+
const segments = normalizeWindowsPath(p).split("/");
|
|
176
|
+
let lastSegment = "";
|
|
177
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
178
|
+
const val = segments[i];
|
|
179
|
+
if (val) {
|
|
180
|
+
lastSegment = val;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
173
184
|
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
174
185
|
};
|
|
175
186
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as globalApis } from './constants.fzPh7AOq.js';
|
|
2
|
-
import { V as VitestIndex } from './index.
|
|
3
|
-
import './vi.
|
|
2
|
+
import { V as VitestIndex } from './index.BQbxGbG9.js';
|
|
3
|
+
import './vi.Da_PT3Vw.js';
|
|
4
4
|
import '@vitest/expect';
|
|
5
5
|
import '@vitest/runner';
|
|
6
6
|
import '@vitest/runner/utils';
|
|
@@ -3,7 +3,7 @@ import { resolve } from 'node:path';
|
|
|
3
3
|
import { t as takeCoverageInsideWorker } from './coverage.BWeNbfBa.js';
|
|
4
4
|
import { distDir } from '../path.js';
|
|
5
5
|
import { r as rpc } from './rpc.C3q9uwRX.js';
|
|
6
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.
|
|
6
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.D0zLenuv.js';
|
|
7
7
|
import { g as getWorkerState } from './utils.C8RiOc4B.js';
|
|
8
8
|
|
|
9
9
|
function setupChaiConfig(config) {
|
|
@@ -63,6 +63,11 @@ async function resolveTestRunner(config, executor) {
|
|
|
63
63
|
await originalOnTaskUpdate?.call(testRunner, task);
|
|
64
64
|
return p;
|
|
65
65
|
};
|
|
66
|
+
const originalOnCollectStart = testRunner.onCollectStart;
|
|
67
|
+
testRunner.onCollectStart = async (file) => {
|
|
68
|
+
await rpc().onQueued(file);
|
|
69
|
+
await originalOnCollectStart?.call(testRunner, file);
|
|
70
|
+
};
|
|
66
71
|
const originalOnCollected = testRunner.onCollected;
|
|
67
72
|
testRunner.onCollected = async (files) => {
|
|
68
73
|
const state = getWorkerState();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as createExpect, a as globalExpect, i as inject, v as vi, b as vitest } from './vi.
|
|
1
|
+
import { c as createExpect, a as globalExpect, i as inject, v as vi, b as vitest } from './vi.Da_PT3Vw.js';
|
|
2
2
|
import { i as isFirstRun, a as runOnce } from './run-once.2ogXb3JV.js';
|
|
3
3
|
import { b as bench } from './benchmark.Cdu9hjj4.js';
|
|
4
4
|
import { expectTypeOf } from 'expect-type';
|