vitest 3.0.0-beta.2 → 3.0.0-beta.3
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/dist/browser.d.ts +2 -2
- package/dist/chunks/{RandomSequencer.gisBJ77r.js → RandomSequencer.C6x84bNN.js} +4 -3
- package/dist/chunks/{base.CUgXReRN.js → base.CQ2VEtuH.js} +1 -1
- package/dist/chunks/{cac.Xzv7eNWw.js → cac.e7qW4xLT.js} +19 -8
- package/dist/chunks/{cli-api.CETCDGgZ.js → cli-api.CWDlED-m.js} +244 -39
- package/dist/chunks/{creator.DcAcUhMD.js → creator.Ot9GlSGw.js} +16 -14
- package/dist/chunks/{index.DoV7W5gc.js → index.BBoOXW-l.js} +5 -0
- package/dist/chunks/{index.9ZEBV_TJ.js → index.CzkCSFCy.js} +37 -24
- package/dist/chunks/{reporters.DTtxC3KQ.d.ts → reporters.DCiyjXOg.d.ts} +131 -102
- package/dist/chunks/{resolveConfig.BA-_OKEx.js → resolveConfig.C1d7TK-U.js} +25 -3
- package/dist/chunks/{runBaseTests.D0dWpzZV.js → runBaseTests.qNWRkgHj.js} +1 -1
- package/dist/chunks/{utils.CMUTX-p8.js → utils.Coei4Wlj.js} +1 -1
- package/dist/chunks/{vite.CXaetSK3.d.ts → vite.CRSMFy31.d.ts} +1 -1
- package/dist/chunks/{worker.ClntunZp.d.ts → worker.R-PA7DpW.d.ts} +1 -1
- package/dist/chunks/{worker.o1PBoDdo.d.ts → worker.XbtCXEXv.d.ts} +1 -0
- package/dist/cli.js +1 -1
- package/dist/config.cjs +1 -0
- package/dist/config.d.ts +3 -3
- package/dist/config.js +1 -0
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.js +33 -8
- package/dist/execute.d.ts +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/node.d.ts +5 -5
- package/dist/node.js +10 -10
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +3 -3
- package/dist/runners.js +2 -2
- package/dist/workers/forks.js +1 -1
- package/dist/workers/runVmTests.js +1 -1
- package/dist/workers/threads.js +1 -1
- package/dist/workers.d.ts +2 -2
- package/dist/workers.js +1 -1
- package/package.json +13 -13
|
@@ -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
|
}
|
|
@@ -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();
|
|
@@ -3,13 +3,12 @@ import { getTests, getTestName, hasFailed, getFullName, getSuites, getTasks } fr
|
|
|
3
3
|
import * as pathe from 'pathe';
|
|
4
4
|
import { extname, relative, normalize, resolve, dirname } from 'pathe';
|
|
5
5
|
import c from 'tinyrainbow';
|
|
6
|
-
import { d as divider, F as F_POINTER, w as withLabel, f as formatProjectName, a as formatTimeString, g as getStateSymbol, t as taskFail, b as F_RIGHT, c as F_CHECK, r as renderSnapshotSummary, p as padSummaryTitle, e as getStateString$1, h as formatTime, i as countTestErrors, j as F_TREE_NODE_END, k as F_TREE_NODE_MIDDLE, l as getCols } from './utils.
|
|
6
|
+
import { d as divider, F as F_POINTER, w as withLabel, f as formatProjectName, a as formatTimeString, g as getStateSymbol, t as taskFail, b as F_RIGHT, c as F_CHECK, r as renderSnapshotSummary, p as padSummaryTitle, e as getStateString$1, h as formatTime, i as countTestErrors, j as F_TREE_NODE_END, k as F_TREE_NODE_MIDDLE, l as getCols } from './utils.Coei4Wlj.js';
|
|
7
7
|
import { stripVTControlCharacters } from 'node:util';
|
|
8
8
|
import { highlight, isPrimitive, inspect, positionToOffset, lineSplitRE, toArray, notNullish } from '@vitest/utils';
|
|
9
9
|
import { performance as performance$1 } from 'node:perf_hooks';
|
|
10
10
|
import { parseErrorStacktrace, parseStacktrace } from '@vitest/utils/source-map';
|
|
11
|
-
import { a as TypeCheckError, R as RandomSequencer, g as getOutputFile, b as
|
|
12
|
-
import { isCI } from 'std-env';
|
|
11
|
+
import { a as TypeCheckError, R as RandomSequencer, g as getOutputFile, b as isTTY } from './RandomSequencer.C6x84bNN.js';
|
|
13
12
|
import { mkdir, writeFile, readdir, stat, readFile } from 'node:fs/promises';
|
|
14
13
|
import { Writable } from 'node:stream';
|
|
15
14
|
import { Console } from 'node:console';
|
|
@@ -3005,7 +3004,7 @@ class BaseReporter {
|
|
|
3005
3004
|
_filesInWatchMode = /* @__PURE__ */ new Map();
|
|
3006
3005
|
_timeStart = formatTimeString(/* @__PURE__ */ new Date());
|
|
3007
3006
|
constructor(options = {}) {
|
|
3008
|
-
this.isTTY = options.isTTY ??
|
|
3007
|
+
this.isTTY = options.isTTY ?? isTTY;
|
|
3009
3008
|
}
|
|
3010
3009
|
onInit(ctx) {
|
|
3011
3010
|
this.ctx = ctx;
|
|
@@ -3034,7 +3033,7 @@ class BaseReporter {
|
|
|
3034
3033
|
}
|
|
3035
3034
|
}
|
|
3036
3035
|
printTask(task) {
|
|
3037
|
-
if (!("filepath" in task) || !task.result?.state || task.result?.state === "run") {
|
|
3036
|
+
if (!("filepath" in task) || !task.result?.state || task.result?.state === "run" || task.result?.state === "queued") {
|
|
3038
3037
|
return;
|
|
3039
3038
|
}
|
|
3040
3039
|
const tests = getTests(task);
|
|
@@ -3081,7 +3080,7 @@ class BaseReporter {
|
|
|
3081
3080
|
} else if (this.ctx.config.hideSkippedTests && (test.mode === "skip" || test.result?.state === "skip")) ; else if (test.result?.state === "skip" && test.result.note) {
|
|
3082
3081
|
this.log(` ${getStateSymbol(test)} ${getTestName(test)}${c.dim(c.gray(` [${test.result.note}]`))}`);
|
|
3083
3082
|
} else if (this.renderSucceed || anyFailed) {
|
|
3084
|
-
this.log(` ${
|
|
3083
|
+
this.log(` ${getStateSymbol(test)} ${getTestName(test, c.dim(" > "))}${suffix2}`);
|
|
3085
3084
|
}
|
|
3086
3085
|
}
|
|
3087
3086
|
}
|
|
@@ -3561,7 +3560,7 @@ class TaskParser {
|
|
|
3561
3560
|
for (const pack of packs) {
|
|
3562
3561
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
3563
3562
|
if (task?.type === "suite" && "filepath" in task && task.result?.state) {
|
|
3564
|
-
if (task?.result?.state === "run") {
|
|
3563
|
+
if (task?.result?.state === "run" || task?.result?.state === "queued") {
|
|
3565
3564
|
startingTestFiles.push(task);
|
|
3566
3565
|
} else {
|
|
3567
3566
|
for (const test of getTests(task)) {
|
|
@@ -3573,7 +3572,7 @@ class TaskParser {
|
|
|
3573
3572
|
}
|
|
3574
3573
|
}
|
|
3575
3574
|
if (task?.type === "test") {
|
|
3576
|
-
if (task.result?.state === "run") {
|
|
3575
|
+
if (task.result?.state === "run" || task.result?.state === "queued") {
|
|
3577
3576
|
startingTests.push(task);
|
|
3578
3577
|
} else if (task.result?.hooks?.afterEach !== "run") {
|
|
3579
3578
|
finishedTests.push(task);
|
|
@@ -3581,7 +3580,7 @@ class TaskParser {
|
|
|
3581
3580
|
}
|
|
3582
3581
|
if (task?.result?.hooks) {
|
|
3583
3582
|
for (const [hook, state] of Object.entries(task.result.hooks)) {
|
|
3584
|
-
if (state === "run") {
|
|
3583
|
+
if (state === "run" || state === "queued") {
|
|
3585
3584
|
startingHooks.push({ name: hook, file: task.file, id: task.id, type: task.type });
|
|
3586
3585
|
} else {
|
|
3587
3586
|
endingHooks.push({ name: hook, file: task.file, id: task.id, type: task.type });
|
|
@@ -3594,9 +3593,7 @@ class TaskParser {
|
|
|
3594
3593
|
finishedTestFiles.forEach((file) => this.onTestFileFinished(file));
|
|
3595
3594
|
startingTestFiles.forEach((file) => this.onTestFilePrepare(file));
|
|
3596
3595
|
startingTests.forEach((test) => this.onTestStart(test));
|
|
3597
|
-
startingHooks.forEach(
|
|
3598
|
-
(hook) => this.onHookStart(hook)
|
|
3599
|
-
);
|
|
3596
|
+
startingHooks.forEach((hook) => this.onHookStart(hook));
|
|
3600
3597
|
}
|
|
3601
3598
|
}
|
|
3602
3599
|
|
|
@@ -3634,6 +3631,9 @@ class SummaryReporter extends TaskParser {
|
|
|
3634
3631
|
this.renderer.stop();
|
|
3635
3632
|
});
|
|
3636
3633
|
}
|
|
3634
|
+
onTestModuleQueued(module) {
|
|
3635
|
+
this.onTestFilePrepare(module.task);
|
|
3636
|
+
}
|
|
3637
3637
|
onPathsCollected(paths) {
|
|
3638
3638
|
this.suites.total = (paths || []).length;
|
|
3639
3639
|
}
|
|
@@ -3654,7 +3654,16 @@ class SummaryReporter extends TaskParser {
|
|
|
3654
3654
|
clearInterval(this.durationInterval);
|
|
3655
3655
|
}
|
|
3656
3656
|
onTestFilePrepare(file) {
|
|
3657
|
-
if (this.
|
|
3657
|
+
if (this.runningTests.has(file.id)) {
|
|
3658
|
+
const stats = this.runningTests.get(file.id);
|
|
3659
|
+
if (!stats.total) {
|
|
3660
|
+
const total2 = getTests(file).length;
|
|
3661
|
+
this.tests.total += total2;
|
|
3662
|
+
stats.total = total2;
|
|
3663
|
+
}
|
|
3664
|
+
return;
|
|
3665
|
+
}
|
|
3666
|
+
if (this.allFinishedTests.has(file.id)) {
|
|
3658
3667
|
return;
|
|
3659
3668
|
}
|
|
3660
3669
|
const total = getTests(file).length;
|
|
@@ -3767,7 +3776,7 @@ class SummaryReporter extends TaskParser {
|
|
|
3767
3776
|
getTestStats(test) {
|
|
3768
3777
|
const file = test.file;
|
|
3769
3778
|
let stats = this.runningTests.get(file.id);
|
|
3770
|
-
if (!stats) {
|
|
3779
|
+
if (!stats || stats.total === 0) {
|
|
3771
3780
|
this.onTestFilePrepare(test.file);
|
|
3772
3781
|
stats = this.runningTests.get(file.id);
|
|
3773
3782
|
if (!stats) {
|
|
@@ -3790,7 +3799,7 @@ class SummaryReporter extends TaskParser {
|
|
|
3790
3799
|
const summary = [""];
|
|
3791
3800
|
for (const testFile of Array.from(this.runningTests.values()).sort(sortRunningTests)) {
|
|
3792
3801
|
summary.push(
|
|
3793
|
-
c.bold(c.yellow(` ${F_POINTER} `)) + formatProjectName(testFile.projectName) + testFile.filename + c.dim(` ${testFile.completed}/${testFile.total}`)
|
|
3802
|
+
c.bold(c.yellow(` ${F_POINTER} `)) + formatProjectName(testFile.projectName) + testFile.filename + c.dim(!testFile.completed && !testFile.total ? " [queued]" : ` ${testFile.completed}/${testFile.total}`)
|
|
3794
3803
|
);
|
|
3795
3804
|
const slowTasks = [
|
|
3796
3805
|
testFile.hook,
|
|
@@ -3874,6 +3883,9 @@ class DefaultReporter extends BaseReporter {
|
|
|
3874
3883
|
this.summary = new SummaryReporter();
|
|
3875
3884
|
}
|
|
3876
3885
|
}
|
|
3886
|
+
onTestModuleQueued(file) {
|
|
3887
|
+
this.summary?.onTestModuleQueued(file);
|
|
3888
|
+
}
|
|
3877
3889
|
onInit(ctx) {
|
|
3878
3890
|
super.onInit(ctx);
|
|
3879
3891
|
this.summary?.onInit(ctx, { verbose: this.verbose });
|
|
@@ -4119,7 +4131,8 @@ const StatusMap = {
|
|
|
4119
4131
|
pass: "passed",
|
|
4120
4132
|
run: "pending",
|
|
4121
4133
|
skip: "skipped",
|
|
4122
|
-
todo: "todo"
|
|
4134
|
+
todo: "todo",
|
|
4135
|
+
queued: "pending"
|
|
4123
4136
|
};
|
|
4124
4137
|
class JsonReporter {
|
|
4125
4138
|
start = 0;
|
|
@@ -4139,7 +4152,7 @@ class JsonReporter {
|
|
|
4139
4152
|
const numTotalTests = tests.length;
|
|
4140
4153
|
const numFailedTestSuites = suites.filter((s) => s.result?.state === "fail").length;
|
|
4141
4154
|
const numPendingTestSuites = suites.filter(
|
|
4142
|
-
(s) => s.result?.state === "run" || s.mode === "todo"
|
|
4155
|
+
(s) => s.result?.state === "run" || s.result?.state === "queued" || s.mode === "todo"
|
|
4143
4156
|
).length;
|
|
4144
4157
|
const numPassedTestSuites = numTotalTestSuites - numFailedTestSuites - numPendingTestSuites;
|
|
4145
4158
|
const numFailedTests = tests.filter(
|
|
@@ -4147,7 +4160,7 @@ class JsonReporter {
|
|
|
4147
4160
|
).length;
|
|
4148
4161
|
const numPassedTests = tests.filter((t) => t.result?.state === "pass").length;
|
|
4149
4162
|
const numPendingTests = tests.filter(
|
|
4150
|
-
(t) => t.result?.state === "run" || t.mode === "skip" || t.result?.state === "skip"
|
|
4163
|
+
(t) => t.result?.state === "run" || t.result?.state === "queued" || t.mode === "skip" || t.result?.state === "skip"
|
|
4151
4164
|
).length;
|
|
4152
4165
|
const numTodoTests = tests.filter((t) => t.mode === "todo").length;
|
|
4153
4166
|
const testResults = [];
|
|
@@ -4187,7 +4200,7 @@ class JsonReporter {
|
|
|
4187
4200
|
meta: t.meta
|
|
4188
4201
|
};
|
|
4189
4202
|
});
|
|
4190
|
-
if (tests2.some((t) => t.result?.state === "run")) {
|
|
4203
|
+
if (tests2.some((t) => t.result?.state === "run" || t.result?.state === "queued")) {
|
|
4191
4204
|
this.ctx.logger.warn(
|
|
4192
4205
|
"WARNING: Some tests are still running when generating the JSON report.This is likely an internal bug in Vitest.Please report it to https://github.com/vitest-dev/vitest/issues"
|
|
4193
4206
|
);
|
|
@@ -4620,7 +4633,7 @@ class TestCase extends ReportedTaskImplementation {
|
|
|
4620
4633
|
*/
|
|
4621
4634
|
result() {
|
|
4622
4635
|
const result = this.task.result;
|
|
4623
|
-
if (!result || result.state === "run") {
|
|
4636
|
+
if (!result || result.state === "run" || result.state === "queued") {
|
|
4624
4637
|
return void 0;
|
|
4625
4638
|
}
|
|
4626
4639
|
const state = result.state === "fail" ? "failed" : result.state === "pass" ? "passed" : "skipped";
|
|
@@ -4661,7 +4674,7 @@ class TestCase extends ReportedTaskImplementation {
|
|
|
4661
4674
|
*/
|
|
4662
4675
|
diagnostic() {
|
|
4663
4676
|
const result = this.task.result;
|
|
4664
|
-
if (!result || result.state === "run" || !result.startTime) {
|
|
4677
|
+
if (!result || result.state === "run" || result.state === "queued" || !result.startTime) {
|
|
4665
4678
|
return void 0;
|
|
4666
4679
|
}
|
|
4667
4680
|
const duration = result.duration || 0;
|
|
@@ -5019,7 +5032,7 @@ class VerboseReporter extends DefaultReporter {
|
|
|
5019
5032
|
}
|
|
5020
5033
|
for (const pack of packs) {
|
|
5021
5034
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
5022
|
-
if (task && task.type === "test" && task.result?.state && task.result?.state !== "run") {
|
|
5035
|
+
if (task && task.type === "test" && task.result?.state && task.result?.state !== "run" && task.result?.state !== "queued") {
|
|
5023
5036
|
let title = ` ${getStateSymbol(task)} `;
|
|
5024
5037
|
if (task.file.projectName) {
|
|
5025
5038
|
title += formatProjectName(task.file.projectName);
|
|
@@ -5323,9 +5336,9 @@ class TableReporter extends BaseReporter {
|
|
|
5323
5336
|
}
|
|
5324
5337
|
for (const pack of packs) {
|
|
5325
5338
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
5326
|
-
if (task && task.type === "suite" && task.result?.state && task.result?.state !== "run") {
|
|
5339
|
+
if (task && task.type === "suite" && task.result?.state && task.result?.state !== "run" && task.result?.state !== "queued") {
|
|
5327
5340
|
const benches = task.tasks.filter((t) => t.meta.benchmark);
|
|
5328
|
-
if (benches.length > 0 && benches.every((t) => t.result?.state !== "run")) {
|
|
5341
|
+
if (benches.length > 0 && benches.every((t) => t.result?.state !== "run" && t.result?.state !== "queued")) {
|
|
5329
5342
|
let title = ` ${getStateSymbol(task)} ${getFullName(
|
|
5330
5343
|
task,
|
|
5331
5344
|
c.dim(" > ")
|