vitest 3.0.5 → 3.0.7
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 +20 -304
- package/dist/browser.d.ts +8 -14
- package/dist/browser.js +2 -2
- package/dist/chunks/{base.wKnmhRYd.js → base.BgUWWWYp.js} +5 -3
- package/dist/chunks/{cac.B_eDEFh6.js → cac.87F_onld.js} +24 -24
- package/dist/chunks/{cli-api.az_rB_xZ.js → cli-api.BZbq1zTX.js} +3273 -3050
- package/dist/chunks/{console.BxE0RUCr.js → console.CN7AiMGV.js} +3 -3
- package/dist/chunks/{coverage.BWeNbfBa.js → coverage.DnNIv-kJ.js} +1 -1
- package/dist/chunks/{creator.fUJbheb8.js → creator.2CFRE1Yx.js} +5 -5
- package/dist/chunks/{execute.PoofJYS5.js → execute.Bhwls1-Z.js} +17 -5
- package/dist/chunks/{globals.BSNBk3vE.js → globals.BCtI_nQG.js} +2 -2
- package/dist/chunks/{index.TH3f4LSA.js → index.68735LiX.js} +2 -2
- package/dist/chunks/{index.Bf4FgyZN.js → index.B8haHJlQ.js} +1 -1
- package/dist/chunks/{index.C2XSkjNu.js → index.BmFFzXX_.js} +3 -3
- package/dist/chunks/{index.NxxmQyK2.js → index.Bw6JxgX8.js} +3 -3
- package/dist/chunks/{index.vId0fl99.js → index.C1f-_gvH.js} +86 -45
- package/dist/chunks/{index.B57_6XMC.js → index.DBIGubLC.js} +8 -8
- package/dist/chunks/{index.cYxyd29h.js → index.K90BXFOx.js} +12 -12
- package/dist/chunks/{inspector.CU9GlB9I.js → inspector.DKLceBVD.js} +1 -1
- package/dist/chunks/{reporters.6vxQttCV.d.ts → reporters.QZ837uWx.d.ts} +75 -61
- package/dist/chunks/{resolveConfig.BT-MMQUD.js → resolveConfig.BbcK25zb.js} +20 -22
- package/dist/chunks/{rpc.Bf456uf4.js → rpc.TVf73xOu.js} +1 -1
- package/dist/chunks/{runBaseTests.Ba8jtu6O.js → runBaseTests.9XCQcSZC.js} +9 -9
- package/dist/chunks/{setup-common.jLbIuaww.js → setup-common.wObu9a36.js} +1 -1
- package/dist/chunks/{suite.BJU7kdY9.d.ts → suite.qtkXWc6R.d.ts} +1 -1
- package/dist/chunks/{typechecker.CdcjdhoT.js → typechecker.cZ0LjdSi.js} +7 -7
- package/dist/chunks/{utils.DJWL04yX.js → utils.bLM2atbD.js} +3 -3
- package/dist/chunks/{vi.CjhMlMwf.js → vi.DT3m61kS.js} +29 -23
- package/dist/chunks/{vite.Cu7NWuBa.d.ts → vite.vM3UZq1q.d.ts} +1 -1
- package/dist/chunks/{vm.DXDoSHPT.js → vm.6kNys9FN.js} +7 -5
- package/dist/chunks/{worker.B1y96qmv.d.ts → worker.B2JXutr8.d.ts} +1 -1
- package/dist/chunks/{worker.CIpff8Eg.d.ts → worker.DaAIyCKm.d.ts} +2 -1
- package/dist/cli.js +1 -1
- package/dist/config.cjs +3 -4
- package/dist/config.d.ts +23 -26
- package/dist/config.js +3 -4
- package/dist/coverage.d.ts +3 -3
- package/dist/coverage.js +9 -9
- package/dist/environments.d.ts +2 -2
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +6 -6
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +2 -2
- package/dist/node.d.ts +13 -13
- package/dist/node.js +15 -16
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +3 -3
- package/dist/runners.js +4 -4
- package/dist/suite.d.ts +1 -1
- package/dist/worker.js +6 -5
- package/dist/workers/forks.js +4 -4
- package/dist/workers/runVmTests.js +8 -8
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +5 -5
- package/dist/workers/vmThreads.js +5 -5
- package/dist/workers.d.ts +2 -2
- package/dist/workers.js +8 -8
- package/package.json +20 -20
|
@@ -121,7 +121,7 @@ function createCustomConsole(defaultState) {
|
|
|
121
121
|
Error.stackTraceLimit = limit;
|
|
122
122
|
buffer.push([data, trace]);
|
|
123
123
|
} else {
|
|
124
|
-
buffer.push([data,
|
|
124
|
+
buffer.push([data, void 0]);
|
|
125
125
|
}
|
|
126
126
|
schedule(id);
|
|
127
127
|
callback();
|
|
@@ -155,14 +155,14 @@ function createCustomConsole(defaultState) {
|
|
|
155
155
|
(line) => line.includes("at Console.trace")
|
|
156
156
|
);
|
|
157
157
|
if (isTrace) {
|
|
158
|
-
buffer.push([data,
|
|
158
|
+
buffer.push([data, void 0]);
|
|
159
159
|
} else {
|
|
160
160
|
const trace = stack?.slice(7).join("\n");
|
|
161
161
|
Error.stackTraceLimit = limit;
|
|
162
162
|
buffer.push([data, trace]);
|
|
163
163
|
}
|
|
164
164
|
} else {
|
|
165
|
-
buffer.push([data,
|
|
165
|
+
buffer.push([data, void 0]);
|
|
166
166
|
}
|
|
167
167
|
schedule(id);
|
|
168
168
|
callback();
|
|
@@ -53,7 +53,7 @@ async function startCoverageInsideWorker(options, loader, runtimeOptions) {
|
|
|
53
53
|
async function takeCoverageInsideWorker(options, loader) {
|
|
54
54
|
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
55
55
|
if (coverageModule) {
|
|
56
|
-
return coverageModule.takeCoverage?.();
|
|
56
|
+
return coverageModule.takeCoverage?.({ moduleExecutionInfo: loader.moduleExecutionInfo });
|
|
57
57
|
}
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync, writeFileSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { resolve, dirname, relative } from 'node:path';
|
|
4
|
-
import { detectPackageManager, installPackage } from './index.
|
|
5
|
-
import { p as prompt, f as findUp } from './index.
|
|
4
|
+
import { detectPackageManager, installPackage } from './index.Bw6JxgX8.js';
|
|
5
|
+
import { p as prompt, f as findUp } from './index.DBIGubLC.js';
|
|
6
6
|
import { x } from 'tinyexec';
|
|
7
7
|
import c from 'tinyrainbow';
|
|
8
8
|
import { c as configFiles } from './constants.fzPh7AOq.js';
|
|
@@ -373,7 +373,7 @@ async function installPackages(pkgManager, packages) {
|
|
|
373
373
|
log(c.cyan("\u25FC"), c.bold("Installing packages..."));
|
|
374
374
|
log(c.cyan("\u25FC"), packages.join(", "));
|
|
375
375
|
log();
|
|
376
|
-
await installPackage(packages, { dev: true, packageManager: pkgManager ??
|
|
376
|
+
await installPackage(packages, { dev: true, packageManager: pkgManager ?? void 0 });
|
|
377
377
|
}
|
|
378
378
|
function readPkgJson(path) {
|
|
379
379
|
if (!existsSync(path)) {
|
|
@@ -452,7 +452,7 @@ async function generateWorkspaceFile(options) {
|
|
|
452
452
|
` enabled: true,`,
|
|
453
453
|
` provider: '${options.provider}',`,
|
|
454
454
|
options.provider !== "preview" && ` // ${getProviderDocsLink(options.provider)}`,
|
|
455
|
-
`
|
|
455
|
+
` instances: [`,
|
|
456
456
|
...options.browsers.map((browser) => ` { browser: '${browser}' },`),
|
|
457
457
|
` ],`,
|
|
458
458
|
` },`,
|
|
@@ -476,7 +476,7 @@ async function generateFrameworkConfigFile(options) {
|
|
|
476
476
|
` enabled: true,`,
|
|
477
477
|
` provider: '${options.provider}',`,
|
|
478
478
|
options.provider !== "preview" && ` // ${getProviderDocsLink(options.provider)}`,
|
|
479
|
-
`
|
|
479
|
+
` instances: [`,
|
|
480
480
|
...options.browsers.map((browser) => ` { browser: '${browser}' },`),
|
|
481
481
|
` ],`,
|
|
482
482
|
` },`,
|
|
@@ -4,7 +4,7 @@ import vm from 'node:vm';
|
|
|
4
4
|
import { processError } from '@vitest/utils/error';
|
|
5
5
|
import { normalize as normalize$1, relative } from 'pathe';
|
|
6
6
|
import { ViteNodeRunner, DEFAULT_REQUEST_STUBS } from 'vite-node/client';
|
|
7
|
-
import { isInternalRequest, isNodeBuiltin as isNodeBuiltin$1,
|
|
7
|
+
import { isInternalRequest, isNodeBuiltin as isNodeBuiltin$1, isPrimitive, toFilePath } from 'vite-node/utils';
|
|
8
8
|
import { distDir } from '../path.js';
|
|
9
9
|
import { resolve as resolve$1, isAbsolute as isAbsolute$1 } from 'node:path';
|
|
10
10
|
import { MockerRegistry, mockObject, RedirectedModule, AutomockedModule } from '@vitest/mocker';
|
|
@@ -235,7 +235,12 @@ const builtins = /* @__PURE__ */ new Set([
|
|
|
235
235
|
"util/types",
|
|
236
236
|
"wasi"
|
|
237
237
|
]);
|
|
238
|
-
const prefixedBuiltins = /* @__PURE__ */ new Set([
|
|
238
|
+
const prefixedBuiltins = /* @__PURE__ */ new Set([
|
|
239
|
+
"node:sea",
|
|
240
|
+
"node:sqlite",
|
|
241
|
+
"node:test",
|
|
242
|
+
"node:test/reporters"
|
|
243
|
+
]);
|
|
239
244
|
const NODE_BUILTIN_NAMESPACE = "node:";
|
|
240
245
|
function isNodeBuiltin(id) {
|
|
241
246
|
if (prefixedBuiltins.has(id)) {
|
|
@@ -395,7 +400,7 @@ class VitestMocker {
|
|
|
395
400
|
}
|
|
396
401
|
} else if (!(prop in target)) {
|
|
397
402
|
if (this.filterPublicKeys.includes(prop)) {
|
|
398
|
-
return
|
|
403
|
+
return void 0;
|
|
399
404
|
}
|
|
400
405
|
throw this.createError(
|
|
401
406
|
`[vitest] No "${String(prop)}" export is defined on the "${mock.raw}" mock. Did you forget to return it from "vi.mock"?
|
|
@@ -538,7 +543,7 @@ If you need to partially mock a module, you can use "importOriginal" helper insi
|
|
|
538
543
|
action: "mock",
|
|
539
544
|
id,
|
|
540
545
|
importer,
|
|
541
|
-
factory: typeof factoryOrOptions === "function" ? factoryOrOptions :
|
|
546
|
+
factory: typeof factoryOrOptions === "function" ? factoryOrOptions : void 0,
|
|
542
547
|
type: mockType
|
|
543
548
|
});
|
|
544
549
|
}
|
|
@@ -642,6 +647,9 @@ async function startVitestExecutor(options) {
|
|
|
642
647
|
get moduleCache() {
|
|
643
648
|
return state().moduleCache;
|
|
644
649
|
},
|
|
650
|
+
get moduleExecutionInfo() {
|
|
651
|
+
return state().moduleExecutionInfo;
|
|
652
|
+
},
|
|
645
653
|
get interopDefault() {
|
|
646
654
|
return state().config.deps.interopDefault;
|
|
647
655
|
},
|
|
@@ -740,6 +748,9 @@ class VitestExecutor extends ViteNodeRunner {
|
|
|
740
748
|
get state() {
|
|
741
749
|
return globalThis.__vitest_worker__ || this.options.state;
|
|
742
750
|
}
|
|
751
|
+
get moduleExecutionInfo() {
|
|
752
|
+
return this.options.moduleExecutionInfo;
|
|
753
|
+
}
|
|
743
754
|
shouldResolveId(id, _importee) {
|
|
744
755
|
if (isInternalRequest(id) || id.startsWith("data:")) {
|
|
745
756
|
return false;
|
|
@@ -764,7 +775,7 @@ class VitestExecutor extends ViteNodeRunner {
|
|
|
764
775
|
const { id: id2 } = error[Symbol.for("vitest.error.not_found.data")];
|
|
765
776
|
const path = this.mocker.normalizePath(id2);
|
|
766
777
|
const mock = this.mocker.getDependencyMock(path);
|
|
767
|
-
if (mock !==
|
|
778
|
+
if (mock !== void 0) {
|
|
768
779
|
return [id2, id2];
|
|
769
780
|
}
|
|
770
781
|
}
|
|
@@ -786,6 +797,7 @@ class VitestExecutor extends ViteNodeRunner {
|
|
|
786
797
|
lineOffset: 0,
|
|
787
798
|
columnOffset: -codeDefinition.length
|
|
788
799
|
};
|
|
800
|
+
this.options.moduleExecutionInfo?.set(options.filename, { startOffset: codeDefinition.length });
|
|
789
801
|
const fn = vm.runInContext(code, vmContext, {
|
|
790
802
|
...options,
|
|
791
803
|
// if we encountered an import, it's not inlined
|
|
@@ -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.B8haHJlQ.js';
|
|
3
|
+
import './vi.DT3m61kS.js';
|
|
4
4
|
import '@vitest/expect';
|
|
5
5
|
import '@vitest/runner';
|
|
6
6
|
import '@vitest/runner/utils';
|
|
@@ -28,7 +28,7 @@ function createBirpc(functions, options) {
|
|
|
28
28
|
if (method === "$close")
|
|
29
29
|
return close;
|
|
30
30
|
if (method === "then" && !eventNames.includes("then") && !("then" in functions))
|
|
31
|
-
return
|
|
31
|
+
return void 0;
|
|
32
32
|
const sendEvent = (...args) => {
|
|
33
33
|
post(serialize({ m: method, a: args, t: "q" }));
|
|
34
34
|
};
|
|
@@ -43,7 +43,7 @@ function createBirpc(functions, options) {
|
|
|
43
43
|
try {
|
|
44
44
|
await _promise;
|
|
45
45
|
} finally {
|
|
46
|
-
_promise =
|
|
46
|
+
_promise = void 0;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
return new Promise((resolve, reject) => {
|
|
@@ -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.DT3m61kS.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';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as chai from 'chai';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
-
import { t as takeCoverageInsideWorker } from './coverage.
|
|
3
|
+
import { t as takeCoverageInsideWorker } from './coverage.DnNIv-kJ.js';
|
|
4
4
|
import { distDir } from '../path.js';
|
|
5
|
-
import { r as rpc } from './rpc.
|
|
6
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.
|
|
5
|
+
import { r as rpc } from './rpc.TVf73xOu.js';
|
|
6
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.wObu9a36.js';
|
|
7
7
|
import { g as getWorkerState } from './utils.C8RiOc4B.js';
|
|
8
8
|
|
|
9
9
|
function setupChaiConfig(config) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import fs, { existsSync } from 'node:fs';
|
|
3
|
-
import
|
|
3
|
+
import fsPromises from 'node:fs/promises';
|
|
4
4
|
import p, { resolve } from 'node:path';
|
|
5
5
|
import { x } from 'tinyexec';
|
|
6
6
|
|
|
@@ -80,7 +80,7 @@ function handlePackageManager(filepath, onUnknown) {
|
|
|
80
80
|
}
|
|
81
81
|
async function fileExists(filePath) {
|
|
82
82
|
try {
|
|
83
|
-
const stats = await
|
|
83
|
+
const stats = await fsPromises.stat(filePath);
|
|
84
84
|
if (stats.isFile()) {
|
|
85
85
|
return true;
|
|
86
86
|
}
|
|
@@ -95,7 +95,7 @@ async function detectPackageManager(cwd = process.cwd()) {
|
|
|
95
95
|
cwd,
|
|
96
96
|
onUnknown(packageManager) {
|
|
97
97
|
console.warn("[@antfu/install-pkg] Unknown packageManager:", packageManager);
|
|
98
|
-
return
|
|
98
|
+
return void 0;
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
101
|
return result?.agent || null;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import fs, { existsSync, readFileSync, promises } from 'node:fs';
|
|
2
|
-
import { getTests, getTestName, hasFailed, getFullName,
|
|
2
|
+
import { getSuites, getTests, getTestName, hasFailed, getFullName, getTasks } from '@vitest/runner/utils';
|
|
3
3
|
import * as pathe from 'pathe';
|
|
4
4
|
import { relative, normalize, resolve, dirname } from 'pathe';
|
|
5
5
|
import c from 'tinyrainbow';
|
|
6
|
-
import {
|
|
6
|
+
import { t as truncateString, d as divider, F as F_POINTER, f as formatTimeString, g as getStateSymbol, a as formatProjectName, b as taskFail, c as F_CHECK, e as F_RIGHT, w as withLabel, r as renderSnapshotSummary, p as padSummaryTitle, h as getStateString$1, i as formatTime, j as countTestErrors, k as F_TREE_NODE_END, l as F_TREE_NODE_MIDDLE } from './utils.bLM2atbD.js';
|
|
7
7
|
import { stripVTControlCharacters } from 'node:util';
|
|
8
|
-
import {
|
|
8
|
+
import { positionToOffset, lineSplitRE, isPrimitive, inspect, 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 { T as TypeCheckError, g as getOutputFile, i as isTTY, h as hasFailedSnapshot } from './typechecker.
|
|
11
|
+
import { T as TypeCheckError, g as getOutputFile, i as isTTY, h as hasFailedSnapshot } from './typechecker.cZ0LjdSi.js';
|
|
12
12
|
import { mkdir, writeFile, readdir, stat, readFile } from 'node:fs/promises';
|
|
13
13
|
import { Console } from 'node:console';
|
|
14
14
|
import { Writable } from 'node:stream';
|
|
@@ -94,7 +94,7 @@ const parse = (text, reviver) => {
|
|
|
94
94
|
*/
|
|
95
95
|
const stringify = (value, replacer, space) => {
|
|
96
96
|
const $ = replacer && typeof replacer === object ?
|
|
97
|
-
(k, v) => (k === '' || -1 < replacer.indexOf(k) ? v :
|
|
97
|
+
(k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
|
|
98
98
|
(replacer || noop);
|
|
99
99
|
const known = new Map;
|
|
100
100
|
const input = [];
|
|
@@ -152,12 +152,12 @@ function printError(error, ctx, logger, options) {
|
|
|
152
152
|
parseErrorStacktrace(error2) {
|
|
153
153
|
if (options.task?.file.pool === "browser" && project.browser) {
|
|
154
154
|
return project.browser.parseErrorStacktrace(error2, {
|
|
155
|
-
ignoreStackEntries: options.fullStack ? [] :
|
|
155
|
+
ignoreStackEntries: options.fullStack ? [] : void 0
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
return parseErrorStacktrace(error2, {
|
|
159
159
|
frameFilter: project.config.onStackTrace,
|
|
160
|
-
ignoreStackEntries: options.fullStack ? [] :
|
|
160
|
+
ignoreStackEntries: options.fullStack ? [] : void 0
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
});
|
|
@@ -596,7 +596,7 @@ class BaseReporter {
|
|
|
596
596
|
watchFilters;
|
|
597
597
|
failedUnwatchedFiles = [];
|
|
598
598
|
isTTY;
|
|
599
|
-
ctx =
|
|
599
|
+
ctx = void 0;
|
|
600
600
|
renderSucceed = false;
|
|
601
601
|
verbose = false;
|
|
602
602
|
_filesInWatchMode = /* @__PURE__ */ new Map();
|
|
@@ -641,10 +641,11 @@ class BaseReporter {
|
|
|
641
641
|
if (!("filepath" in task) || !task.result?.state || task.result?.state === "run" || task.result?.state === "queued") {
|
|
642
642
|
return;
|
|
643
643
|
}
|
|
644
|
-
const
|
|
645
|
-
const
|
|
646
|
-
const
|
|
647
|
-
|
|
644
|
+
const suites = getSuites(task);
|
|
645
|
+
const allTests = getTests(task);
|
|
646
|
+
const failed = allTests.filter((t) => t.result?.state === "fail");
|
|
647
|
+
const skipped = allTests.filter((t) => t.mode === "skip" || t.mode === "todo");
|
|
648
|
+
let state = c.dim(`${allTests.length} test${allTests.length > 1 ? "s" : ""}`);
|
|
648
649
|
if (failed.length) {
|
|
649
650
|
state += c.dim(" | ") + c.red(`${failed.length} failed`);
|
|
650
651
|
}
|
|
@@ -663,32 +664,52 @@ class BaseReporter {
|
|
|
663
664
|
title += ` ${formatProjectName(task.projectName, "")}`;
|
|
664
665
|
}
|
|
665
666
|
this.log(` ${title} ${task.name} ${suffix}`);
|
|
666
|
-
const
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
if (retryCount != null && retryCount > 0) {
|
|
671
|
-
suffix2 += c.yellow(` (retry x${retryCount})`);
|
|
672
|
-
}
|
|
673
|
-
if (repeatCount != null && repeatCount > 0) {
|
|
674
|
-
suffix2 += c.yellow(` (repeat x${repeatCount})`);
|
|
667
|
+
for (const suite of suites) {
|
|
668
|
+
const tests = suite.tasks.filter((task2) => task2.type === "test");
|
|
669
|
+
if (!("filepath" in suite)) {
|
|
670
|
+
this.printSuite(suite);
|
|
675
671
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
672
|
+
for (const test of tests) {
|
|
673
|
+
const { duration, retryCount, repeatCount } = test.result || {};
|
|
674
|
+
const padding = this.getTestIndentation(test);
|
|
675
|
+
let suffix2 = "";
|
|
676
|
+
if (retryCount != null && retryCount > 0) {
|
|
677
|
+
suffix2 += c.yellow(` (retry x${retryCount})`);
|
|
678
|
+
}
|
|
679
|
+
if (repeatCount != null && repeatCount > 0) {
|
|
680
|
+
suffix2 += c.yellow(` (repeat x${repeatCount})`);
|
|
681
|
+
}
|
|
682
|
+
if (test.result?.state === "fail") {
|
|
683
|
+
this.log(c.red(` ${padding}${taskFail} ${this.getTestName(test, c.dim(" > "))}${this.getDurationPrefix(test)}`) + suffix2);
|
|
684
|
+
test.result?.errors?.forEach((error) => {
|
|
685
|
+
const message = this.formatShortError(error);
|
|
686
|
+
if (message) {
|
|
687
|
+
this.log(c.red(` ${padding}${message}`));
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
} else if (duration && duration > this.ctx.config.slowTestThreshold) {
|
|
691
|
+
this.log(
|
|
692
|
+
` ${padding}${c.yellow(c.dim(F_CHECK))} ${this.getTestName(test, c.dim(" > "))} ${c.yellow(Math.round(duration) + c.dim("ms"))}${suffix2}`
|
|
693
|
+
);
|
|
694
|
+
} else if (this.ctx.config.hideSkippedTests && (test.mode === "skip" || test.result?.state === "skip")) ; else if (test.result?.state === "skip" && test.result.note) {
|
|
695
|
+
this.log(` ${padding}${getStateSymbol(test)} ${this.getTestName(test)}${c.dim(c.gray(` [${test.result.note}]`))}`);
|
|
696
|
+
} else if (this.renderSucceed || failed.length > 0) {
|
|
697
|
+
this.log(` ${padding}${getStateSymbol(test)} ${this.getTestName(test, c.dim(" > "))}${suffix2}`);
|
|
698
|
+
}
|
|
689
699
|
}
|
|
690
700
|
}
|
|
691
701
|
}
|
|
702
|
+
printSuite(_task) {
|
|
703
|
+
}
|
|
704
|
+
getTestName(test, separator) {
|
|
705
|
+
return getTestName(test, separator);
|
|
706
|
+
}
|
|
707
|
+
formatShortError(error) {
|
|
708
|
+
return `${F_RIGHT} ${error.message}`;
|
|
709
|
+
}
|
|
710
|
+
getTestIndentation(_test) {
|
|
711
|
+
return " ";
|
|
712
|
+
}
|
|
692
713
|
getDurationPrefix(task) {
|
|
693
714
|
if (!task.result?.duration) {
|
|
694
715
|
return "";
|
|
@@ -752,7 +773,7 @@ class BaseReporter {
|
|
|
752
773
|
const output = log.type === "stdout" ? this.ctx.logger.outputStream : this.ctx.logger.errorStream;
|
|
753
774
|
const write = (msg) => output.write(msg);
|
|
754
775
|
let headerText = "unknown test";
|
|
755
|
-
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) :
|
|
776
|
+
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
|
|
756
777
|
if (task) {
|
|
757
778
|
headerText = getFullName(task, c.dim(" > "));
|
|
758
779
|
} else if (log.taskId && log.taskId !== "__vitest__unknown_test__") {
|
|
@@ -872,7 +893,7 @@ class BaseReporter {
|
|
|
872
893
|
const failedTests = tests.filter((i) => i.result?.state === "fail");
|
|
873
894
|
const failedTotal = countTestErrors(failedSuites) + countTestErrors(failedTests);
|
|
874
895
|
let current = 1;
|
|
875
|
-
const errorDivider = () => this.error(`${c.red(c.dim(divider(`[${current++}/${failedTotal}]`,
|
|
896
|
+
const errorDivider = () => this.error(`${c.red(c.dim(divider(`[${current++}/${failedTotal}]`, void 0, 1)))}
|
|
876
897
|
`);
|
|
877
898
|
if (failedSuites.length) {
|
|
878
899
|
this.error(`
|
|
@@ -994,7 +1015,7 @@ class WindowRenderer {
|
|
|
994
1015
|
options;
|
|
995
1016
|
streams;
|
|
996
1017
|
buffer = [];
|
|
997
|
-
renderInterval =
|
|
1018
|
+
renderInterval = void 0;
|
|
998
1019
|
renderScheduled = false;
|
|
999
1020
|
windowHeight = 0;
|
|
1000
1021
|
finished = false;
|
|
@@ -1146,7 +1167,7 @@ class SummaryReporter {
|
|
|
1146
1167
|
startTime = "";
|
|
1147
1168
|
currentTime = 0;
|
|
1148
1169
|
duration = 0;
|
|
1149
|
-
durationInterval =
|
|
1170
|
+
durationInterval = void 0;
|
|
1150
1171
|
onInit(ctx, options = {}) {
|
|
1151
1172
|
this.ctx = ctx;
|
|
1152
1173
|
this.options = {
|
|
@@ -1428,7 +1449,7 @@ class DefaultReporter extends BaseReporter {
|
|
|
1428
1449
|
}
|
|
1429
1450
|
onPathsCollected(paths = []) {
|
|
1430
1451
|
if (this.isTTY) {
|
|
1431
|
-
if (this.renderSucceed ===
|
|
1452
|
+
if (this.renderSucceed === void 0) {
|
|
1432
1453
|
this.renderSucceed = !!this.renderSucceed;
|
|
1433
1454
|
}
|
|
1434
1455
|
if (this.renderSucceed !== true) {
|
|
@@ -1557,7 +1578,7 @@ function formatTests(states) {
|
|
|
1557
1578
|
}
|
|
1558
1579
|
|
|
1559
1580
|
class GithubActionsReporter {
|
|
1560
|
-
ctx =
|
|
1581
|
+
ctx = void 0;
|
|
1561
1582
|
onInit(ctx) {
|
|
1562
1583
|
this.ctx = ctx;
|
|
1563
1584
|
}
|
|
@@ -1863,7 +1884,7 @@ class JUnitReporter {
|
|
|
1863
1884
|
const pairs = [];
|
|
1864
1885
|
for (const key in attrs) {
|
|
1865
1886
|
const attr = attrs[key];
|
|
1866
|
-
if (attr ===
|
|
1887
|
+
if (attr === void 0) {
|
|
1867
1888
|
continue;
|
|
1868
1889
|
}
|
|
1869
1890
|
pairs.push(`${key}="${escapeXML(attr)}"`);
|
|
@@ -1909,7 +1930,7 @@ class JUnitReporter {
|
|
|
1909
1930
|
"testcase",
|
|
1910
1931
|
{
|
|
1911
1932
|
classname,
|
|
1912
|
-
file: this.options.addFileAttribute ? filename :
|
|
1933
|
+
file: this.options.addFileAttribute ? filename : void 0,
|
|
1913
1934
|
name: task.name,
|
|
1914
1935
|
time: getDuration(task)
|
|
1915
1936
|
},
|
|
@@ -2038,7 +2059,7 @@ class JUnitReporter {
|
|
|
2038
2059
|
this.ctx.logger.log(`JUNIT report written to ${this.reportFile}`);
|
|
2039
2060
|
}
|
|
2040
2061
|
await this.fileFd?.close();
|
|
2041
|
-
this.fileFd =
|
|
2062
|
+
this.fileFd = void 0;
|
|
2042
2063
|
}
|
|
2043
2064
|
}
|
|
2044
2065
|
|
|
@@ -2183,6 +2204,27 @@ class VerboseReporter extends DefaultReporter {
|
|
|
2183
2204
|
task.result.errors?.forEach((error) => this.log(c.red(` ${F_RIGHT} ${error?.message}`)));
|
|
2184
2205
|
}
|
|
2185
2206
|
}
|
|
2207
|
+
printSuite(task) {
|
|
2208
|
+
const indentation = " ".repeat(getIndentation(task));
|
|
2209
|
+
const tests = getTests(task);
|
|
2210
|
+
const state = getStateSymbol(task);
|
|
2211
|
+
this.log(` ${indentation}${state} ${task.name} ${c.dim(`(${tests.length})`)}`);
|
|
2212
|
+
}
|
|
2213
|
+
getTestName(test) {
|
|
2214
|
+
return test.name;
|
|
2215
|
+
}
|
|
2216
|
+
getTestIndentation(test) {
|
|
2217
|
+
return " ".repeat(getIndentation(test));
|
|
2218
|
+
}
|
|
2219
|
+
formatShortError() {
|
|
2220
|
+
return "";
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
function getIndentation(suite, level = 1) {
|
|
2224
|
+
if (suite.suite && !("filepath" in suite.suite)) {
|
|
2225
|
+
return getIndentation(suite.suite, level + 1);
|
|
2226
|
+
}
|
|
2227
|
+
return level;
|
|
2186
2228
|
}
|
|
2187
2229
|
|
|
2188
2230
|
function createBenchmarkJsonReport(files) {
|
|
@@ -2372,7 +2414,7 @@ ${padding}`;
|
|
|
2372
2414
|
if (typeof data === "string") {
|
|
2373
2415
|
data = stripVTControlCharacters(data.trim().split("\n").filter(Boolean).pop());
|
|
2374
2416
|
if (data === "") {
|
|
2375
|
-
data =
|
|
2417
|
+
data = void 0;
|
|
2376
2418
|
}
|
|
2377
2419
|
}
|
|
2378
2420
|
if (data != null) {
|
|
@@ -2430,7 +2472,6 @@ class BenchmarkReporter extends DefaultReporter {
|
|
|
2430
2472
|
this.log(renderTable({
|
|
2431
2473
|
tasks: benches,
|
|
2432
2474
|
level: 1,
|
|
2433
|
-
shallow: true,
|
|
2434
2475
|
columns: this.ctx.logger.getColumns(),
|
|
2435
2476
|
compare: this.compare,
|
|
2436
2477
|
showHeap: this.ctx.config.logHeapUsage,
|
|
@@ -400,11 +400,11 @@ function requireKleur () {
|
|
|
400
400
|
rgx: new RegExp(`\\x1b\\[${close}m`, 'g')
|
|
401
401
|
};
|
|
402
402
|
return function (txt) {
|
|
403
|
-
if (this !==
|
|
403
|
+
if (this !== void 0 && this.has !== void 0) {
|
|
404
404
|
this.has.includes(open) || (this.has.push(open),this.keys.push(blk));
|
|
405
|
-
return txt ===
|
|
405
|
+
return txt === void 0 ? this : $.enabled ? run(this.keys, txt+'') : txt+'';
|
|
406
406
|
}
|
|
407
|
-
return txt ===
|
|
407
|
+
return txt === void 0 ? chain([open], [blk]) : $.enabled ? run([blk], txt+'') : txt+'';
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
410
|
|
|
@@ -816,7 +816,7 @@ function requirePrompt$1 () {
|
|
|
816
816
|
this.in = opts.stdin || process.stdin;
|
|
817
817
|
this.out = opts.stdout || process.stdout;
|
|
818
818
|
|
|
819
|
-
this.onRender = (opts.onRender || (() =>
|
|
819
|
+
this.onRender = (opts.onRender || (() => void 0)).bind(this);
|
|
820
820
|
|
|
821
821
|
const rl = readline.createInterface({
|
|
822
822
|
input: this.in,
|
|
@@ -2760,7 +2760,7 @@ function requireAutocomplete$1 () {
|
|
|
2760
2760
|
reset() {
|
|
2761
2761
|
this.input = '';
|
|
2762
2762
|
this.complete(() => {
|
|
2763
|
-
this.moveSelect(this.initial !==
|
|
2763
|
+
this.moveSelect(this.initial !== void 0 ? this.initial : 0);
|
|
2764
2764
|
this.render();
|
|
2765
2765
|
});
|
|
2766
2766
|
this.render();
|
|
@@ -3973,7 +3973,7 @@ function requirePrompt () {
|
|
|
3973
3973
|
this.firstRender = true;
|
|
3974
3974
|
this.in = opts.stdin || process.stdin;
|
|
3975
3975
|
this.out = opts.stdout || process.stdout;
|
|
3976
|
-
this.onRender = (opts.onRender || (() =>
|
|
3976
|
+
this.onRender = (opts.onRender || (() => void 0)).bind(this);
|
|
3977
3977
|
const rl = readline.createInterface({ input:this.in, escapeCodeTimeout:50 });
|
|
3978
3978
|
readline.emitKeypressEvents(this.in, rl);
|
|
3979
3979
|
|
|
@@ -5735,7 +5735,7 @@ function requireAutocomplete () {
|
|
|
5735
5735
|
reset() {
|
|
5736
5736
|
this.input = '';
|
|
5737
5737
|
this.complete(() => {
|
|
5738
|
-
this.moveSelect(this.initial !==
|
|
5738
|
+
this.moveSelect(this.initial !== void 0 ? this.initial : 0);
|
|
5739
5739
|
this.render();
|
|
5740
5740
|
});
|
|
5741
5741
|
this.render();
|
|
@@ -6502,7 +6502,7 @@ function requireLib () {
|
|
|
6502
6502
|
// update vars in case they changed
|
|
6503
6503
|
({ name, type } = question);
|
|
6504
6504
|
|
|
6505
|
-
if (prompts[type] ===
|
|
6505
|
+
if (prompts[type] === void 0) {
|
|
6506
6506
|
throw new Error(`prompt type (${type}) is not defined`);
|
|
6507
6507
|
}
|
|
6508
6508
|
|
|
@@ -373,7 +373,7 @@ var happy = {
|
|
|
373
373
|
const { Window } = await import('happy-dom');
|
|
374
374
|
let win = new Window({
|
|
375
375
|
...happyDOM,
|
|
376
|
-
console: console && globalThis.console ? globalThis.console :
|
|
376
|
+
console: console && globalThis.console ? globalThis.console : void 0,
|
|
377
377
|
url: happyDOM.url || "http://localhost:3000",
|
|
378
378
|
settings: {
|
|
379
379
|
...happyDOM.settings,
|
|
@@ -390,7 +390,7 @@ var happy = {
|
|
|
390
390
|
},
|
|
391
391
|
async teardown() {
|
|
392
392
|
await teardownWindow(win);
|
|
393
|
-
win =
|
|
393
|
+
win = void 0;
|
|
394
394
|
}
|
|
395
395
|
};
|
|
396
396
|
},
|
|
@@ -398,7 +398,7 @@ var happy = {
|
|
|
398
398
|
const { Window, GlobalWindow } = await import('happy-dom');
|
|
399
399
|
const win = new (GlobalWindow || Window)({
|
|
400
400
|
...happyDOM,
|
|
401
|
-
console: console && global.console ? global.console :
|
|
401
|
+
console: console && global.console ? global.console : void 0,
|
|
402
402
|
url: happyDOM.url || "http://localhost:3000",
|
|
403
403
|
settings: {
|
|
404
404
|
...happyDOM.settings,
|
|
@@ -466,11 +466,11 @@ var jsdom = {
|
|
|
466
466
|
} = jsdom;
|
|
467
467
|
let dom = new JSDOM(html, {
|
|
468
468
|
pretendToBeVisual,
|
|
469
|
-
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) :
|
|
469
|
+
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
|
|
470
470
|
runScripts,
|
|
471
471
|
url,
|
|
472
|
-
virtualConsole: console && globalThis.console ? new VirtualConsole().sendTo(globalThis.console) :
|
|
473
|
-
cookieJar: cookieJar ? new CookieJar() :
|
|
472
|
+
virtualConsole: console && globalThis.console ? new VirtualConsole().sendTo(globalThis.console) : void 0,
|
|
473
|
+
cookieJar: cookieJar ? new CookieJar() : void 0,
|
|
474
474
|
includeNodeLocations,
|
|
475
475
|
contentType,
|
|
476
476
|
userAgent,
|
|
@@ -503,7 +503,7 @@ var jsdom = {
|
|
|
503
503
|
teardown() {
|
|
504
504
|
clearWindowErrors();
|
|
505
505
|
dom.window.close();
|
|
506
|
-
dom =
|
|
506
|
+
dom = void 0;
|
|
507
507
|
}
|
|
508
508
|
};
|
|
509
509
|
},
|
|
@@ -524,11 +524,11 @@ var jsdom = {
|
|
|
524
524
|
} = jsdom;
|
|
525
525
|
const dom = new JSDOM(html, {
|
|
526
526
|
pretendToBeVisual,
|
|
527
|
-
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) :
|
|
527
|
+
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
|
|
528
528
|
runScripts,
|
|
529
529
|
url,
|
|
530
|
-
virtualConsole: console && global.console ? new VirtualConsole().sendTo(global.console) :
|
|
531
|
-
cookieJar: cookieJar ? new CookieJar() :
|
|
530
|
+
virtualConsole: console && global.console ? new VirtualConsole().sendTo(global.console) : void 0,
|
|
531
|
+
cookieJar: cookieJar ? new CookieJar() : void 0,
|
|
532
532
|
includeNodeLocations,
|
|
533
533
|
contentType,
|
|
534
534
|
userAgent,
|
|
@@ -633,8 +633,8 @@ var node = {
|
|
|
633
633
|
return context;
|
|
634
634
|
},
|
|
635
635
|
teardown() {
|
|
636
|
-
context =
|
|
637
|
-
global =
|
|
636
|
+
context = void 0;
|
|
637
|
+
global = void 0;
|
|
638
638
|
}
|
|
639
639
|
};
|
|
640
640
|
},
|
|
@@ -9,7 +9,7 @@ function setupInspect(ctx) {
|
|
|
9
9
|
const isEnabled = config.inspector.enabled;
|
|
10
10
|
if (isEnabled) {
|
|
11
11
|
inspector = __require("node:inspector");
|
|
12
|
-
const isOpen = inspector.url() !==
|
|
12
|
+
const isOpen = inspector.url() !== void 0;
|
|
13
13
|
if (!isOpen) {
|
|
14
14
|
inspector.open(
|
|
15
15
|
config.inspector.port,
|