vitest 2.1.0-beta.6 → 2.1.0-beta.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 +52 -342
- package/dist/browser.d.ts +4 -2
- package/dist/browser.js +1 -1
- package/dist/chunks/{RandomSequencer.CjkAy_bL.js → RandomSequencer.Bh5-tlNJ.js} +10 -37
- package/dist/chunks/{base.BH-FAiX7.js → base.BlXpj3e_.js} +1 -29
- package/dist/chunks/{base.B-9RAXb6.js → base.CchlWrnV.js} +2 -4
- package/dist/chunks/{cac.BZlOqtiQ.js → cac.B5XYKv2_.js} +25 -16
- package/dist/chunks/{cli-api.B-2f6g4d.js → cli-api.ByZPnilx.js} +2778 -3488
- package/dist/chunks/{creator.D0TxjnLa.js → creator.zfBZSJzo.js} +8 -11
- package/dist/chunks/{execute.DT9BA6zp.js → execute._eQQfgI8.js} +322 -232
- package/dist/chunks/{git.ZtkbKc8u.js → git.B5SDxu-n.js} +5 -5
- package/dist/chunks/{globals.Br36EZIp.js → globals.jM7MxN2t.js} +3 -3
- package/dist/chunks/{index.CM5UI-4O.js → index.Bn75ITYg.js} +3 -3
- package/dist/chunks/index.CPD77dLA.js +133 -0
- package/dist/chunks/{index.dWDhoZDV.js → index.CSjyR2-v.js} +1 -1
- package/dist/chunks/{index.C4LZENmc.js → index.DpJO1tkB.js} +40 -44
- package/dist/chunks/{index.m3Xip5Zz.js → index.xm8OIiKD.js} +1 -1
- package/dist/chunks/mocker.cRtM890J.d.ts +17 -0
- package/dist/chunks/{reporters.B0Ao6Zu1.d.ts → reporters.WnPwkmgA.d.ts} +30 -22
- package/dist/chunks/{resolveConfig.C0vpvVRF.js → resolveConfig.-K5hHm0S.js} +19 -6
- package/dist/chunks/{runBaseTests.Cf8lGnUq.js → runBaseTests.Cztfoflv.js} +6 -6
- package/dist/chunks/{setup-common.B7uEQsGB.js → setup-common.fGBFoQKJ.js} +1 -1
- package/dist/chunks/{utils.C3_cBsyn.js → utils.Cn0zI1t3.js} +16 -3
- package/dist/chunks/{utils.DO38lwfj.js → utils.Dbnmsfq1.js} +1 -1
- package/dist/chunks/{vi.DBepMgvg.js → vi.DGgiNzJE.js} +37 -37
- package/dist/chunks/{vite.Bvz2vSw0.d.ts → vite.D2yAwzwa.d.ts} +1 -1
- package/dist/chunks/{vm.kl9T_5ai.js → vm.CPXwWp4C.js} +1 -2
- package/dist/chunks/{worker.DTM-0OlZ.d.ts → worker.Bws9Zuxu.d.ts} +1 -1
- package/dist/chunks/{worker.CTdJUeeB.d.ts → worker.CmPmTxgH.d.ts} +1 -14
- package/dist/cli.js +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.js +4 -4
- package/dist/execute.d.ts +12 -13
- package/dist/execute.js +3 -2
- package/dist/index.d.ts +17 -15
- package/dist/index.js +4 -4
- package/dist/mocker.d.ts +1 -0
- package/dist/mocker.js +1 -0
- package/dist/node.d.ts +15 -7
- package/dist/node.js +18 -16
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +5 -5
- package/dist/runners.js +2 -2
- package/dist/utils.d.ts +1 -0
- package/dist/worker.js +3 -2
- package/dist/workers/forks.js +5 -4
- package/dist/workers/runVmTests.js +5 -5
- package/dist/workers/threads.js +5 -4
- package/dist/workers/vmForks.js +4 -4
- package/dist/workers/vmThreads.js +4 -4
- package/dist/workers.d.ts +2 -2
- package/dist/workers.js +6 -5
- package/mocker.d.ts +1 -0
- package/package.json +22 -17
- package/dist/chunks/index.CWhwfxXK.js +0 -835
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve } from 'pathe';
|
|
2
|
-
import {
|
|
2
|
+
import { x } from 'tinyexec';
|
|
3
3
|
|
|
4
4
|
class VitestGit {
|
|
5
5
|
constructor(cwd) {
|
|
@@ -9,7 +9,7 @@ class VitestGit {
|
|
|
9
9
|
async resolveFilesWithGitCommand(args) {
|
|
10
10
|
let result;
|
|
11
11
|
try {
|
|
12
|
-
result = await
|
|
12
|
+
result = await x("git", args, { nodeOptions: { cwd: this.root } });
|
|
13
13
|
} catch (e) {
|
|
14
14
|
e.message = e.stderr;
|
|
15
15
|
throw e;
|
|
@@ -56,10 +56,10 @@ class VitestGit {
|
|
|
56
56
|
]);
|
|
57
57
|
}
|
|
58
58
|
async getRoot(cwd) {
|
|
59
|
-
const
|
|
59
|
+
const args = ["rev-parse", "--show-cdup"];
|
|
60
60
|
try {
|
|
61
|
-
const result = await
|
|
62
|
-
return resolve(cwd, result.stdout);
|
|
61
|
+
const result = await x("git", args, { nodeOptions: { cwd } });
|
|
62
|
+
return resolve(cwd, result.stdout.trim());
|
|
63
63
|
} catch {
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as globalApis } from './constants.fzPh7AOq.js';
|
|
2
|
-
import { V as VitestIndex } from './index.
|
|
2
|
+
import { V as VitestIndex } from './index.xm8OIiKD.js';
|
|
3
3
|
import '@vitest/runner';
|
|
4
4
|
import './benchmark.C8CRJYG4.js';
|
|
5
5
|
import '@vitest/runner/utils';
|
|
@@ -10,7 +10,7 @@ import './utils.Ck2hJTRs.js';
|
|
|
10
10
|
import './env.CmHVDJnw.js';
|
|
11
11
|
import 'std-env';
|
|
12
12
|
import './run-once.Sxe67Wng.js';
|
|
13
|
-
import './vi.
|
|
13
|
+
import './vi.DGgiNzJE.js';
|
|
14
14
|
import 'chai';
|
|
15
15
|
import './_commonjsHelpers.BFTU3MAI.js';
|
|
16
16
|
import '@vitest/expect';
|
|
@@ -18,7 +18,7 @@ import '@vitest/snapshot';
|
|
|
18
18
|
import '@vitest/utils/error';
|
|
19
19
|
import './tasks.BZnCS9aT.js';
|
|
20
20
|
import '@vitest/utils/source-map';
|
|
21
|
-
import './base.
|
|
21
|
+
import './base.BlXpj3e_.js';
|
|
22
22
|
import './date.W2xKR2qe.js';
|
|
23
23
|
import '@vitest/spy';
|
|
24
24
|
|
|
@@ -4,7 +4,7 @@ import process$1 from 'node:process';
|
|
|
4
4
|
import { promises } from 'node:fs';
|
|
5
5
|
import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
|
|
6
6
|
import require$$0 from 'readline';
|
|
7
|
-
import require$$
|
|
7
|
+
import require$$2 from 'events';
|
|
8
8
|
|
|
9
9
|
function _mergeNamespaces(n, m) {
|
|
10
10
|
m.forEach(function (e) {
|
|
@@ -795,7 +795,7 @@ function requirePrompt$1 () {
|
|
|
795
795
|
const _require = requireUtil$1(),
|
|
796
796
|
action = _require.action;
|
|
797
797
|
|
|
798
|
-
const EventEmitter = require$$
|
|
798
|
+
const EventEmitter = require$$2;
|
|
799
799
|
|
|
800
800
|
const _require2 = requireSrc(),
|
|
801
801
|
beep = _require2.beep,
|
|
@@ -3957,7 +3957,7 @@ function requirePrompt () {
|
|
|
3957
3957
|
|
|
3958
3958
|
const readline = require$$0;
|
|
3959
3959
|
const { action } = requireUtil();
|
|
3960
|
-
const EventEmitter = require$$
|
|
3960
|
+
const EventEmitter = require$$2;
|
|
3961
3961
|
const { beep, cursor } = requireSrc();
|
|
3962
3962
|
const color = requireKleur();
|
|
3963
3963
|
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import process$1 from 'process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import fsp from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import process from 'node:process';
|
|
6
|
+
import { existsSync } from 'fs';
|
|
7
|
+
import { resolve } from 'path';
|
|
8
|
+
import { x } from 'tinyexec';
|
|
9
|
+
|
|
10
|
+
const AGENTS = [
|
|
11
|
+
"npm",
|
|
12
|
+
"yarn",
|
|
13
|
+
"yarn@berry",
|
|
14
|
+
"pnpm",
|
|
15
|
+
"pnpm@6",
|
|
16
|
+
"bun"
|
|
17
|
+
];
|
|
18
|
+
const LOCKS = {
|
|
19
|
+
"bun.lockb": "bun",
|
|
20
|
+
"pnpm-lock.yaml": "pnpm",
|
|
21
|
+
"yarn.lock": "yarn",
|
|
22
|
+
"package-lock.json": "npm",
|
|
23
|
+
"npm-shrinkwrap.json": "npm"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
async function detect({ cwd, onUnknown } = {}) {
|
|
27
|
+
for (const directory of lookup(cwd)) {
|
|
28
|
+
for (const lock of Object.keys(LOCKS)) {
|
|
29
|
+
if (await fileExists(path.join(directory, lock))) {
|
|
30
|
+
const name = LOCKS[lock];
|
|
31
|
+
const result2 = await parsePackageJson(path.join(directory, "package.json"), onUnknown);
|
|
32
|
+
if (result2)
|
|
33
|
+
return result2;
|
|
34
|
+
else
|
|
35
|
+
return { name, agent: name };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const result = await parsePackageJson(path.join(directory, "package.json"), onUnknown);
|
|
39
|
+
if (result)
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
function* lookup(cwd = process.cwd()) {
|
|
45
|
+
let directory = path.resolve(cwd);
|
|
46
|
+
const { root } = path.parse(directory);
|
|
47
|
+
while (directory && directory !== root) {
|
|
48
|
+
yield directory;
|
|
49
|
+
directory = path.dirname(directory);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function parsePackageJson(filepath, onUnknown) {
|
|
53
|
+
if (!filepath || !await fileExists(filepath))
|
|
54
|
+
return null;
|
|
55
|
+
try {
|
|
56
|
+
const pkg = JSON.parse(fs.readFileSync(filepath, "utf8"));
|
|
57
|
+
let agent;
|
|
58
|
+
if (typeof pkg.packageManager === "string") {
|
|
59
|
+
const [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
|
|
60
|
+
let version = ver;
|
|
61
|
+
if (name === "yarn" && Number.parseInt(ver) > 1) {
|
|
62
|
+
agent = "yarn@berry";
|
|
63
|
+
version = "berry";
|
|
64
|
+
return { name, agent, version };
|
|
65
|
+
} else if (name === "pnpm" && Number.parseInt(ver) < 7) {
|
|
66
|
+
agent = "pnpm@6";
|
|
67
|
+
return { name, agent, version };
|
|
68
|
+
} else if (AGENTS.includes(name)) {
|
|
69
|
+
agent = name;
|
|
70
|
+
return { name, agent, version };
|
|
71
|
+
} else {
|
|
72
|
+
return onUnknown?.(pkg.packageManager) ?? null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} catch {
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
async function fileExists(filePath) {
|
|
80
|
+
try {
|
|
81
|
+
const stats = await fsp.stat(filePath);
|
|
82
|
+
if (stats.isFile()) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/detect.ts
|
|
91
|
+
async function detectPackageManager(cwd = process$1.cwd()) {
|
|
92
|
+
const result = await detect({
|
|
93
|
+
cwd,
|
|
94
|
+
onUnknown(packageManager) {
|
|
95
|
+
console.warn("[@antfu/install-pkg] Unknown packageManager:", packageManager);
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return result?.agent || null;
|
|
100
|
+
}
|
|
101
|
+
async function installPackage(names, options = {}) {
|
|
102
|
+
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
|
103
|
+
const [agent] = detectedAgent.split("@");
|
|
104
|
+
if (!Array.isArray(names))
|
|
105
|
+
names = [names];
|
|
106
|
+
const args = options.additionalArgs || [];
|
|
107
|
+
if (options.preferOffline) {
|
|
108
|
+
if (detectedAgent === "yarn@berry")
|
|
109
|
+
args.unshift("--cached");
|
|
110
|
+
else
|
|
111
|
+
args.unshift("--prefer-offline");
|
|
112
|
+
}
|
|
113
|
+
if (agent === "pnpm" && existsSync(resolve(options.cwd ?? process$1.cwd(), "pnpm-workspace.yaml")))
|
|
114
|
+
args.unshift("-w");
|
|
115
|
+
return x(
|
|
116
|
+
agent,
|
|
117
|
+
[
|
|
118
|
+
agent === "yarn" ? "add" : "install",
|
|
119
|
+
options.dev ? "-D" : "",
|
|
120
|
+
...args,
|
|
121
|
+
...names
|
|
122
|
+
].filter(Boolean),
|
|
123
|
+
{
|
|
124
|
+
nodeOptions: {
|
|
125
|
+
stdio: options.silent ? "ignore" : "inherit",
|
|
126
|
+
cwd: options.cwd
|
|
127
|
+
},
|
|
128
|
+
throwOnError: true
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export { detectPackageManager, installPackage };
|
|
@@ -4,7 +4,7 @@ import { distDir } from '../path.js';
|
|
|
4
4
|
import { g as getWorkerState } from './utils.Ck2hJTRs.js';
|
|
5
5
|
import { r as rpc } from './rpc.B7Mfb-Yf.js';
|
|
6
6
|
import { t as takeCoverageInsideWorker } from './coverage.zlNdAMHK.js';
|
|
7
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.
|
|
7
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.fGBFoQKJ.js';
|
|
8
8
|
|
|
9
9
|
function setupChaiConfig(config) {
|
|
10
10
|
Object.assign(chai.config, config);
|
|
@@ -5,24 +5,23 @@ import { relative, resolve, dirname, extname, normalize } from 'pathe';
|
|
|
5
5
|
import { g as getTestName, h as hasFailedSnapshot, a as getFullName } from './tasks.BZnCS9aT.js';
|
|
6
6
|
import { notNullish, highlight, inspect, positionToOffset, lineSplitRE } from '@vitest/utils';
|
|
7
7
|
import { a as isNode, b as isDeno } from './env.CmHVDJnw.js';
|
|
8
|
-
import { g as getStateSymbol, f as formatProjectName, t as taskFail, F as F_RIGHT, a as F_POINTER, r as renderSnapshotSummary, b as getStateString, c as formatTimeString, d as countTestErrors, e as divider, s as stripAnsi, h as getCols, i as getHookStateSymbol } from './utils.
|
|
8
|
+
import { g as getStateSymbol, f as formatProjectName, t as taskFail, F as F_RIGHT, a as F_POINTER, r as renderSnapshotSummary, b as getStateString, c as formatTimeString, d as countTestErrors, e as divider, s as stripAnsi, h as getCols, i as getHookStateSymbol } from './utils.Dbnmsfq1.js';
|
|
9
9
|
import { getTests, hasFailed, getSuites, getTasks } from '@vitest/runner/utils';
|
|
10
10
|
import { performance } from 'node:perf_hooks';
|
|
11
11
|
import { parseStacktrace, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
12
12
|
import { r as relativePath } from './index.CxRxs566.js';
|
|
13
|
-
import { t as toArray,
|
|
13
|
+
import { t as toArray, b as isPrimitive } from './base.BlXpj3e_.js';
|
|
14
14
|
import { isCI } from 'std-env';
|
|
15
|
-
import { g as getOutputFile, R as RandomSequencer, a as TypeCheckError } from './RandomSequencer.
|
|
15
|
+
import { g as getOutputFile, R as RandomSequencer, a as TypeCheckError } from './RandomSequencer.Bh5-tlNJ.js';
|
|
16
16
|
import { hostname } from 'node:os';
|
|
17
17
|
import { Writable } from 'node:stream';
|
|
18
18
|
import { Console } from 'node:console';
|
|
19
19
|
import process$2 from 'node:process';
|
|
20
20
|
import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHelpers.BFTU3MAI.js';
|
|
21
|
-
import require$$0
|
|
22
|
-
import require$$
|
|
21
|
+
import require$$0 from 'assert';
|
|
22
|
+
import require$$2 from 'events';
|
|
23
23
|
import { createRequire } from 'node:module';
|
|
24
24
|
import { mkdir, writeFile, readdir, stat, readFile } from 'node:fs/promises';
|
|
25
|
-
import { cleanUrl } from 'vite-node/utils';
|
|
26
25
|
|
|
27
26
|
class TestProject {
|
|
28
27
|
/**
|
|
@@ -811,13 +810,6 @@ ${log.content}`);
|
|
|
811
810
|
0
|
|
812
811
|
);
|
|
813
812
|
const threadTime = collectTime + testsTime + setupTime;
|
|
814
|
-
const padTitle = (str) => c.dim(`${str.padStart(11)} `);
|
|
815
|
-
const time = (time2) => {
|
|
816
|
-
if (time2 > 1e3) {
|
|
817
|
-
return `${(time2 / 1e3).toFixed(2)}s`;
|
|
818
|
-
}
|
|
819
|
-
return `${Math.round(time2)}ms`;
|
|
820
|
-
};
|
|
821
813
|
const snapshotOutput = renderSnapshotSummary(
|
|
822
814
|
this.ctx.config.root,
|
|
823
815
|
this.ctx.snapshot.summary
|
|
@@ -1001,6 +993,15 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1001
993
|
};
|
|
1002
994
|
}
|
|
1003
995
|
}
|
|
996
|
+
function padTitle(str) {
|
|
997
|
+
return c.dim(`${str.padStart(11)} `);
|
|
998
|
+
}
|
|
999
|
+
function time(time2) {
|
|
1000
|
+
if (time2 > 1e3) {
|
|
1001
|
+
return `${(time2 / 1e3).toFixed(2)}s`;
|
|
1002
|
+
}
|
|
1003
|
+
return `${Math.round(time2)}ms`;
|
|
1004
|
+
}
|
|
1004
1005
|
|
|
1005
1006
|
class BasicReporter extends BaseReporter {
|
|
1006
1007
|
constructor() {
|
|
@@ -2904,11 +2905,11 @@ if (!processOk(process$1)) {
|
|
|
2904
2905
|
return function () {}
|
|
2905
2906
|
};
|
|
2906
2907
|
} else {
|
|
2907
|
-
var assert = require$$0
|
|
2908
|
+
var assert = require$$0;
|
|
2908
2909
|
var signals = requireSignals();
|
|
2909
2910
|
var isWin = /^win/i.test(process$1.platform);
|
|
2910
2911
|
|
|
2911
|
-
var EE = require$$
|
|
2912
|
+
var EE = require$$2;
|
|
2912
2913
|
/* istanbul ignore if */
|
|
2913
2914
|
if (typeof EE !== 'function') {
|
|
2914
2915
|
EE = EE.EventEmitter;
|
|
@@ -4318,9 +4319,6 @@ function generateCodeFrame(source, indent = 0, loc, range = 2) {
|
|
|
4318
4319
|
let count = 0;
|
|
4319
4320
|
let res = [];
|
|
4320
4321
|
const columns = process.stdout?.columns || 80;
|
|
4321
|
-
function lineNo(no = "") {
|
|
4322
|
-
return c.gray(`${String(no).padStart(3, " ")}| `);
|
|
4323
|
-
}
|
|
4324
4322
|
for (let i = 0; i < lines.length; i++) {
|
|
4325
4323
|
count += lines[i].length + nl;
|
|
4326
4324
|
if (count >= start) {
|
|
@@ -4358,6 +4356,9 @@ function generateCodeFrame(source, indent = 0, loc, range = 2) {
|
|
|
4358
4356
|
}
|
|
4359
4357
|
return res.join("\n");
|
|
4360
4358
|
}
|
|
4359
|
+
function lineNo(no = "") {
|
|
4360
|
+
return c.gray(`${String(no).padStart(3, " ")}| `);
|
|
4361
|
+
}
|
|
4361
4362
|
|
|
4362
4363
|
function flattenTasks$1(task, baseName = "") {
|
|
4363
4364
|
const base = baseName ? `${baseName} > ` : "";
|
|
@@ -4736,11 +4737,16 @@ class BlobReporter {
|
|
|
4736
4737
|
const shard = this.ctx.config.shard;
|
|
4737
4738
|
outputFile = shard ? `.vitest-reports/blob-${shard.index}-${shard.count}.json` : ".vitest-reports/blob.json";
|
|
4738
4739
|
}
|
|
4739
|
-
const
|
|
4740
|
+
const modules = this.ctx.projects.map(
|
|
4740
4741
|
(project) => {
|
|
4741
4742
|
return [
|
|
4742
4743
|
project.getName(),
|
|
4743
|
-
[...project.server.moduleGraph.idToModuleMap.
|
|
4744
|
+
[...project.server.moduleGraph.idToModuleMap.entries()].map((mod) => {
|
|
4745
|
+
if (!mod[1].file) {
|
|
4746
|
+
return null;
|
|
4747
|
+
}
|
|
4748
|
+
return [mod[0], mod[1].file, mod[1].url];
|
|
4749
|
+
}).filter((x) => x != null)
|
|
4744
4750
|
];
|
|
4745
4751
|
}
|
|
4746
4752
|
);
|
|
@@ -4748,7 +4754,7 @@ class BlobReporter {
|
|
|
4748
4754
|
this.ctx.version,
|
|
4749
4755
|
files,
|
|
4750
4756
|
errors,
|
|
4751
|
-
|
|
4757
|
+
modules,
|
|
4752
4758
|
coverage
|
|
4753
4759
|
]);
|
|
4754
4760
|
const reportFile = resolve(this.ctx.config.root, outputFile);
|
|
@@ -4760,7 +4766,7 @@ class BlobReporter {
|
|
|
4760
4766
|
this.ctx.logger.log("blob report written to", reportFile);
|
|
4761
4767
|
}
|
|
4762
4768
|
}
|
|
4763
|
-
async function readBlobs(blobsDirectory, projectsArray) {
|
|
4769
|
+
async function readBlobs(currentVersion, blobsDirectory, projectsArray) {
|
|
4764
4770
|
const resolvedDir = resolve(process.cwd(), blobsDirectory);
|
|
4765
4771
|
const blobsFiles = await readdir(resolvedDir);
|
|
4766
4772
|
const promises = blobsFiles.map(async (filename) => {
|
|
@@ -4796,6 +4802,11 @@ async function readBlobs(blobsDirectory, projectsArray) {
|
|
|
4796
4802
|
${blobs.map((b) => `- "${b.file}" uses v${b.version}`).join("\n")}`
|
|
4797
4803
|
);
|
|
4798
4804
|
}
|
|
4805
|
+
if (!versions.has(currentVersion)) {
|
|
4806
|
+
throw new Error(
|
|
4807
|
+
`the blobs in "${blobsDirectory}" were generated by a different version of Vitest. Expected v${currentVersion}, but received v${blobs[0].version}`
|
|
4808
|
+
);
|
|
4809
|
+
}
|
|
4799
4810
|
const projects = Object.fromEntries(
|
|
4800
4811
|
projectsArray.map((p) => [p.getName(), p])
|
|
4801
4812
|
);
|
|
@@ -4805,26 +4816,11 @@ ${blobs.map((b) => `- "${b.file}" uses v${b.version}`).join("\n")}`
|
|
|
4805
4816
|
if (!project) {
|
|
4806
4817
|
return;
|
|
4807
4818
|
}
|
|
4808
|
-
moduleIds.forEach((moduleId) => {
|
|
4809
|
-
project.server.moduleGraph.
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
ssrTransformResult: null,
|
|
4814
|
-
transformResult: null,
|
|
4815
|
-
importedBindings: null,
|
|
4816
|
-
importedModules: /* @__PURE__ */ new Set(),
|
|
4817
|
-
importers: /* @__PURE__ */ new Set(),
|
|
4818
|
-
type: "js",
|
|
4819
|
-
clientImportedModules: /* @__PURE__ */ new Set(),
|
|
4820
|
-
ssrError: null,
|
|
4821
|
-
ssrImportedModules: /* @__PURE__ */ new Set(),
|
|
4822
|
-
ssrModule: null,
|
|
4823
|
-
acceptedHmrDeps: /* @__PURE__ */ new Set(),
|
|
4824
|
-
acceptedHmrExports: null,
|
|
4825
|
-
lastHMRTimestamp: 0,
|
|
4826
|
-
lastInvalidationTimestamp: 0
|
|
4827
|
-
});
|
|
4819
|
+
moduleIds.forEach(([moduleId, file, url]) => {
|
|
4820
|
+
const moduleNode = project.server.moduleGraph.createFileOnlyEntry(file);
|
|
4821
|
+
moduleNode.url = url;
|
|
4822
|
+
moduleNode.id = moduleId;
|
|
4823
|
+
project.server.moduleGraph.idToModuleMap.set(moduleId, moduleNode);
|
|
4828
4824
|
});
|
|
4829
4825
|
});
|
|
4830
4826
|
});
|
|
@@ -4937,7 +4933,7 @@ function renderTree(tasks, options, level = 0, shallow = false) {
|
|
|
4937
4933
|
if (baseline) {
|
|
4938
4934
|
benchMap[t.id].baseline = {
|
|
4939
4935
|
...baseline,
|
|
4940
|
-
samples: Array(baseline.sampleCount)
|
|
4936
|
+
samples: Array.from({ length: baseline.sampleCount })
|
|
4941
4937
|
};
|
|
4942
4938
|
}
|
|
4943
4939
|
}
|
|
@@ -5241,4 +5237,4 @@ const ReportersMap = {
|
|
|
5241
5237
|
"github-actions": GithubActionsReporter
|
|
5242
5238
|
};
|
|
5243
5239
|
|
|
5244
|
-
export { BasicReporter as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter as J, Logger as L, ReportersMap as R, TapReporter as T, VerboseReporter as V, DotReporter as a, JUnitReporter as b, TapFlatReporter as c, TestFile as d, TestCase as e, TestModule as f, TestSuite as g, BenchmarkReportsMap as h, TestProject as i, generateCodeFrame as j,
|
|
5240
|
+
export { BasicReporter as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter as J, Logger as L, ReportersMap as R, TapReporter as T, VerboseReporter as V, DotReporter as a, JUnitReporter as b, TapFlatReporter as c, TestFile as d, TestCase as e, TestModule as f, TestSuite as g, BenchmarkReportsMap as h, TestProject as i, generateCodeFrame as j, BlobReporter as k, parse as p, readBlobs as r, stringify as s };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
2
2
|
import { b as bench } from './benchmark.C8CRJYG4.js';
|
|
3
3
|
import { i as isFirstRun, a as runOnce } from './run-once.Sxe67Wng.js';
|
|
4
|
-
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.
|
|
4
|
+
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.DGgiNzJE.js';
|
|
5
5
|
import { g as getWorkerState } from './utils.Ck2hJTRs.js';
|
|
6
6
|
import * as chai from 'chai';
|
|
7
7
|
import { assert, should } from 'chai';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MockedModuleType } from '@vitest/mocker';
|
|
2
|
+
|
|
3
|
+
type Promisable<T> = T | Promise<T>;
|
|
4
|
+
type MockFactoryWithHelper<M = unknown> = (importOriginal: <T extends M = M>() => Promise<T>) => Promisable<Partial<M>>;
|
|
5
|
+
type MockFactory = () => any;
|
|
6
|
+
interface MockOptions {
|
|
7
|
+
spy?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface PendingSuiteMock {
|
|
10
|
+
id: string;
|
|
11
|
+
importer: string;
|
|
12
|
+
action: 'mock' | 'unmock';
|
|
13
|
+
type?: MockedModuleType;
|
|
14
|
+
factory?: MockFactory;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { MockFactoryWithHelper as M, PendingSuiteMock as P, MockOptions as a, MockFactory as b };
|
|
@@ -379,7 +379,7 @@ interface BrowserProvider {
|
|
|
379
379
|
beforeCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
|
|
380
380
|
afterCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
|
|
381
381
|
getCommandsContext: (contextId: string) => Record<string, unknown>;
|
|
382
|
-
openPage: (contextId: string, url: string) => Promise<void>;
|
|
382
|
+
openPage: (contextId: string, url: string, beforeNavigate?: () => Promise<void>) => Promise<void>;
|
|
383
383
|
getCDPSession?: (contextId: string) => Promise<CDPSession>;
|
|
384
384
|
close: () => Awaitable$1<void>;
|
|
385
385
|
initialize(ctx: WorkspaceProject, options: BrowserProviderInitializationOptions): Awaitable$1<void>;
|
|
@@ -681,17 +681,28 @@ declare class WorkspaceProject {
|
|
|
681
681
|
initBrowserProvider(): Promise<void>;
|
|
682
682
|
}
|
|
683
683
|
|
|
684
|
-
|
|
684
|
+
type SerializedTestSpecification = [
|
|
685
|
+
project: {
|
|
686
|
+
name: string | undefined;
|
|
687
|
+
root: string;
|
|
688
|
+
},
|
|
689
|
+
file: string,
|
|
690
|
+
options: {
|
|
691
|
+
pool: string;
|
|
692
|
+
}
|
|
693
|
+
];
|
|
694
|
+
|
|
695
|
+
declare class TestSpecification {
|
|
685
696
|
/**
|
|
686
|
-
* @deprecated
|
|
697
|
+
* @deprecated use `project` instead
|
|
687
698
|
*/
|
|
688
699
|
readonly 0: WorkspaceProject;
|
|
689
700
|
/**
|
|
690
|
-
* @deprecated
|
|
701
|
+
* @deprecated use `moduleId` instead
|
|
691
702
|
*/
|
|
692
703
|
readonly 1: string;
|
|
693
704
|
/**
|
|
694
|
-
* @deprecated
|
|
705
|
+
* @deprecated use `pool` instead
|
|
695
706
|
*/
|
|
696
707
|
readonly 2: {
|
|
697
708
|
pool: Pool;
|
|
@@ -700,6 +711,7 @@ declare class WorkspaceSpec$1 {
|
|
|
700
711
|
readonly moduleId: string;
|
|
701
712
|
readonly pool: Pool;
|
|
702
713
|
constructor(workspaceProject: WorkspaceProject, moduleId: string, pool: Pool);
|
|
714
|
+
toJSON(): SerializedTestSpecification;
|
|
703
715
|
/**
|
|
704
716
|
* for backwards compatibility
|
|
705
717
|
* @deprecated
|
|
@@ -707,7 +719,10 @@ declare class WorkspaceSpec$1 {
|
|
|
707
719
|
[Symbol.iterator](): Generator<string | WorkspaceProject, void, unknown>;
|
|
708
720
|
}
|
|
709
721
|
|
|
710
|
-
|
|
722
|
+
/**
|
|
723
|
+
* @deprecated use TestSpecification instead
|
|
724
|
+
*/
|
|
725
|
+
type WorkspaceSpec = TestSpecification & [
|
|
711
726
|
/**
|
|
712
727
|
* @deprecated use spec.project instead
|
|
713
728
|
*/
|
|
@@ -1432,6 +1447,7 @@ declare class Vitest {
|
|
|
1432
1447
|
tests: File[];
|
|
1433
1448
|
errors: unknown[];
|
|
1434
1449
|
}>;
|
|
1450
|
+
listFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
1435
1451
|
start(filters?: string[]): Promise<void>;
|
|
1436
1452
|
init(): Promise<void>;
|
|
1437
1453
|
private getTestDependencies;
|
|
@@ -1441,9 +1457,8 @@ declare class Vitest {
|
|
|
1441
1457
|
*/
|
|
1442
1458
|
getProjectsByTestFile(file: string): WorkspaceSpec[];
|
|
1443
1459
|
getFileWorkspaceSpecs(file: string): WorkspaceSpec[];
|
|
1444
|
-
initializeGlobalSetup(paths:
|
|
1445
|
-
|
|
1446
|
-
runFiles(specs: WorkspaceSpec[], allTestsRun: boolean): Promise<void>;
|
|
1460
|
+
initializeGlobalSetup(paths: TestSpecification[]): Promise<void>;
|
|
1461
|
+
runFiles(specs: TestSpecification[], allTestsRun: boolean): Promise<void>;
|
|
1447
1462
|
collectFiles(specs: WorkspaceSpec[]): Promise<void>;
|
|
1448
1463
|
cancelCurrentRun(reason: CancelReason): Promise<void>;
|
|
1449
1464
|
rerunFiles(files?: string[], trigger?: string): Promise<void>;
|
|
@@ -1459,6 +1474,10 @@ declare class Vitest {
|
|
|
1459
1474
|
* Watch only the specified tests. If no tests are provided, all tests will be watched.
|
|
1460
1475
|
*/
|
|
1461
1476
|
watchTests(tests: string[]): void;
|
|
1477
|
+
private updateLastChanged;
|
|
1478
|
+
onChange: (id: string) => void;
|
|
1479
|
+
onUnlink: (id: string) => void;
|
|
1480
|
+
onAdd: (id: string) => Promise<void>;
|
|
1462
1481
|
private unregisterWatcher;
|
|
1463
1482
|
private registerWatcher;
|
|
1464
1483
|
/**
|
|
@@ -1486,21 +1505,10 @@ declare class Vitest {
|
|
|
1486
1505
|
onClose(fn: () => void): void;
|
|
1487
1506
|
}
|
|
1488
1507
|
|
|
1489
|
-
type SerializedSpec = [
|
|
1490
|
-
project: {
|
|
1491
|
-
name: string | undefined;
|
|
1492
|
-
root: string;
|
|
1493
|
-
},
|
|
1494
|
-
file: string,
|
|
1495
|
-
options: {
|
|
1496
|
-
pool: string;
|
|
1497
|
-
}
|
|
1498
|
-
];
|
|
1499
|
-
|
|
1500
1508
|
interface Reporter {
|
|
1501
1509
|
onInit?: (ctx: Vitest) => void;
|
|
1502
1510
|
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
1503
|
-
onSpecsCollected?: (specs?:
|
|
1511
|
+
onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable<void>;
|
|
1504
1512
|
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
1505
1513
|
onFinished?: (files: File[], errors: unknown[], coverage?: unknown) => Awaitable<void>;
|
|
1506
1514
|
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
@@ -2731,4 +2739,4 @@ type WorkspaceProjectConfiguration = string | (UserProjectConfigExport & {
|
|
|
2731
2739
|
extends?: string;
|
|
2732
2740
|
});
|
|
2733
2741
|
|
|
2734
|
-
export { type
|
|
2742
|
+
export { type BrowserProviderInitializationOptions as $, type ApiConfig as A, type BaseCoverageOptions as B, type CoverageProvider as C, type DepsOptimizationOptions as D, type ResolvedConfig as E, type ProjectConfig as F, type BenchmarkUserOptions as G, type VitestOptions as H, type InlineConfig as I, WorkspaceProject as J, type TestSequencer as K, Logger as L, type WorkspaceSpec as M, TestModule as N, type ModuleDiagnostic as O, type Pool as P, type ProcessPool as Q, type ResolvedCoverageOptions as R, type SerializedTestSpecification as S, type TscErrorInfo as T, type UserWorkspaceConfig as U, Vitest as V, type WorkspaceProjectConfiguration as W, getFilePoolName as X, VitestPackageInstaller as Y, TestSpecification as Z, type TestSequencerConstructor as _, type CoverageProviderModule as a, type BrowserProvider as a0, type CDPSession as a1, type BrowserProviderModule as a2, type ResolvedBrowserOptions as a3, type BrowserProviderOptions as a4, type BrowserBuiltinProvider as a5, type BrowserCommand as a6, type BrowserCommandContext as a7, type BrowserServer as a8, type BrowserServerState as a9, BaseReporter as aA, TestFile as aB, type FileDiagnostic as aC, ReportersMap as aD, type BuiltinReporters as aE, type BuiltinReporterOptions as aF, type JsonAssertionResult as aG, type JsonTestResult as aH, type JsonTestResults as aI, BenchmarkReportsMap as aJ, type BenchmarkBuiltinReporters as aK, type BrowserServerStateContext as aa, type BrowserOrchestrator as ab, type JsonOptions as ac, type JUnitOptions as ad, type HTMLOptions as ae, TestCase as af, TestSuite as ag, TestProject as ah, TestCollection as ai, type TaskOptions as aj, type TestDiagnostic as ak, type TestResult as al, type TestResultPassed as am, type TestResultFailed as an, type TestResultSkipped as ao, type ResolvedProjectConfig as ap, DefaultReporter as aq, BasicReporter as ar, DotReporter as as, JsonReporter as at, VerboseReporter as au, TapReporter as av, JUnitReporter as aw, TapFlatReporter as ax, HangingProcessReporter as ay, GithubActionsReporter as az, type CoverageV8Options as b, type UserProjectConfigFn as c, type UserProjectConfigExport as d, type VitestEnvironment as e, type RawErrsMap as f, type CollectLineNumbers as g, type CollectLines as h, type RootAndTarget as i, type Context as j, type ReportContext as k, type CoverageReporter as l, type CoverageProviderName as m, type CoverageOptions as n, type CoverageIstanbulOptions as o, type CustomProviderOptions as p, type Reporter as q, type BrowserScript as r, type BrowserConfigOptions as s, type BuiltinEnvironment as t, type PoolOptions as u, type CSSModuleScopeStrategy as v, type VitestRunMode as w, type TransformModePatterns as x, type TypecheckConfig as y, type UserConfig as z };
|
|
@@ -15,10 +15,10 @@ import nodeos__default from 'node:os';
|
|
|
15
15
|
import { i as isWindows } from './env.CmHVDJnw.js';
|
|
16
16
|
import { isCI, provider } from 'std-env';
|
|
17
17
|
import { hasFailed } from '@vitest/runner/utils';
|
|
18
|
-
import {
|
|
18
|
+
import { g as groupBy, A as AggregateErrorPonyfill, a as slash, t as toArray } from './base.BlXpj3e_.js';
|
|
19
19
|
import { createDefer } from '@vitest/utils';
|
|
20
20
|
import crypto, { createHash } from 'node:crypto';
|
|
21
|
-
import { w as wrapSerializableConfig, T as Typechecker, R as RandomSequencer, B as BaseSequencer } from './RandomSequencer.
|
|
21
|
+
import { w as wrapSerializableConfig, T as Typechecker, R as RandomSequencer, B as BaseSequencer } from './RandomSequencer.Bh5-tlNJ.js';
|
|
22
22
|
import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
|
|
23
23
|
import require$$0 from 'util';
|
|
24
24
|
import p from 'path';
|
|
@@ -7667,9 +7667,9 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
7667
7667
|
);
|
|
7668
7668
|
}
|
|
7669
7669
|
}
|
|
7670
|
-
if (resolved.browser.enabled && resolved.
|
|
7671
|
-
|
|
7672
|
-
|
|
7670
|
+
if (resolved.browser.enabled && !(resolved.browser.provider === "playwright" && resolved.browser.name === "chromium")) {
|
|
7671
|
+
const browserConfig = { browser: { provider: resolved.browser.provider, name: resolved.browser.name } };
|
|
7672
|
+
if (resolved.coverage.enabled && resolved.coverage.provider === "v8") {
|
|
7673
7673
|
throw new Error(
|
|
7674
7674
|
`@vitest/coverage-v8 does not work with
|
|
7675
7675
|
${JSON.stringify(browserConfig, null, 2)}
|
|
@@ -7679,6 +7679,19 @@ ${JSON.stringify({ browser: { provider: "playwright", name: "chromium" } }, null
|
|
|
7679
7679
|
|
|
7680
7680
|
...or change your coverage provider to:
|
|
7681
7681
|
${JSON.stringify({ coverage: { provider: "istanbul" } }, null, 2)}
|
|
7682
|
+
`
|
|
7683
|
+
);
|
|
7684
|
+
}
|
|
7685
|
+
if (resolved.inspect || resolved.inspectBrk) {
|
|
7686
|
+
const inspectOption = `--inspect${resolved.inspectBrk ? "-brk" : ""}`;
|
|
7687
|
+
throw new Error(
|
|
7688
|
+
`${inspectOption} does not work with
|
|
7689
|
+
${JSON.stringify(browserConfig, null, 2)}
|
|
7690
|
+
|
|
7691
|
+
Use either:
|
|
7692
|
+
${JSON.stringify({ browser: { provider: "playwright", name: "chromium" } }, null, 2)}
|
|
7693
|
+
|
|
7694
|
+
...or disable ${inspectOption}
|
|
7682
7695
|
`
|
|
7683
7696
|
);
|
|
7684
7697
|
}
|
|
@@ -8127,4 +8140,4 @@ function resolveCoverageReporters(configReporters) {
|
|
|
8127
8140
|
return resolvedReporters;
|
|
8128
8141
|
}
|
|
8129
8142
|
|
|
8130
|
-
export { VitestCache as V, resolveApiServerConfig as a, resolveConfig as b, createMethodsRPC as c,
|
|
8143
|
+
export { VitestCache as V, resolveApiServerConfig as a, resolveConfig as b, createMethodsRPC as c, configDefaults as d, isPackageExists as e, createPool as f, getFilePoolName as g, coverageConfigDefaults as h, isBrowserEnabled as i, mm as m, resolveCoverageReporters as r };
|
|
@@ -5,16 +5,16 @@ import '@vitest/runner/utils';
|
|
|
5
5
|
import { getSafeTimers } from '@vitest/utils';
|
|
6
6
|
import { g as getWorkerState } from './utils.Ck2hJTRs.js';
|
|
7
7
|
import './env.CmHVDJnw.js';
|
|
8
|
-
import { a as globalExpect, r as resetModules, v as vi } from './vi.
|
|
8
|
+
import { a as globalExpect, r as resetModules, v as vi } from './vi.DGgiNzJE.js';
|
|
9
9
|
import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from './coverage.zlNdAMHK.js';
|
|
10
|
-
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.
|
|
10
|
+
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.CSjyR2-v.js';
|
|
11
11
|
import { createRequire } from 'node:module';
|
|
12
12
|
import util from 'node:util';
|
|
13
13
|
import timers from 'node:timers';
|
|
14
14
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
15
15
|
import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
|
|
16
|
-
import { V as VitestIndex } from './index.
|
|
17
|
-
import { s as setupCommonEnv } from './setup-common.
|
|
16
|
+
import { V as VitestIndex } from './index.xm8OIiKD.js';
|
|
17
|
+
import { s as setupCommonEnv } from './setup-common.fGBFoQKJ.js';
|
|
18
18
|
import { c as closeInspector } from './inspector.70d6emsh.js';
|
|
19
19
|
import 'std-env';
|
|
20
20
|
import 'chai';
|
|
@@ -24,7 +24,7 @@ import '@vitest/snapshot';
|
|
|
24
24
|
import '@vitest/utils/error';
|
|
25
25
|
import './tasks.BZnCS9aT.js';
|
|
26
26
|
import '@vitest/utils/source-map';
|
|
27
|
-
import './base.
|
|
27
|
+
import './base.BlXpj3e_.js';
|
|
28
28
|
import './date.W2xKR2qe.js';
|
|
29
29
|
import '@vitest/spy';
|
|
30
30
|
import '../path.js';
|
|
@@ -122,7 +122,7 @@ async function run(method, files, config, environment, executor) {
|
|
|
122
122
|
const isIsolatedThreads = config.pool === "threads" && (config.poolOptions?.threads?.isolate ?? true);
|
|
123
123
|
const isIsolatedForks = config.pool === "forks" && (config.poolOptions?.forks?.isolate ?? true);
|
|
124
124
|
if (isIsolatedThreads || isIsolatedForks) {
|
|
125
|
-
|
|
125
|
+
executor.mocker.reset();
|
|
126
126
|
resetModules(workerState.moduleCache, true);
|
|
127
127
|
}
|
|
128
128
|
workerState.filepath = file;
|