vitest 2.1.3 → 2.1.5
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 -209
- package/dist/browser.d.ts +24 -24
- package/dist/browser.js +7 -7
- package/dist/chunks/{RandomSequencer.Bh5-tlNJ.js → RandomSequencer.CMRlh2v4.js} +143 -142
- package/dist/chunks/{base.BO5Jx7vw.js → base.BZZh4cSm.js} +3 -3
- package/dist/chunks/{benchmark.C8CRJYG4.js → benchmark.Cdu9hjj4.js} +2 -2
- package/dist/chunks/{benchmark.JVlTzojj.d.ts → benchmark.geERunq4.d.ts} +1 -1
- package/dist/chunks/{cac.BSMVokHR.js → cac.DWAW3Uh5.js} +11 -10
- package/dist/chunks/{cli-api.btGgw3PC.js → cli-api.BtqJwSCh.js} +828 -644
- package/dist/chunks/{config.Crbj2GAb.d.ts → config.Cy0C388Z.d.ts} +0 -1
- package/dist/chunks/{console.CfT1Wjed.js → console.BYGVloWk.js} +2 -6
- package/dist/chunks/{coverage.zlNdAMHK.js → coverage.BoMDb1ip.js} +1 -1
- package/dist/chunks/{creator.CBPphXqR.js → creator.IIqd8RWT.js} +8 -8
- package/dist/chunks/{execute._eQQfgI8.js → execute.2pr0rHgK.js} +8 -6
- package/dist/chunks/{globals.Bdzt04Qm.js → globals.D8ZVAdXd.js} +8 -13
- package/dist/chunks/{index.BpSiYbpB.js → index.68735LiX.js} +28 -5
- package/dist/chunks/{index.X0nbfr6-.js → index.BJDntFik.js} +7 -7
- package/dist/chunks/{index.CPD77dLA.js → index.CqYx2Nsr.js} +7 -7
- package/dist/chunks/{index.Dz2opmmU.js → index.DsZFoqi9.js} +3711 -3788
- package/dist/chunks/{index.lVXYBqEP.js → index.K90BXFOx.js} +186 -186
- package/dist/chunks/index.ckWaX2gY.js +54 -0
- package/dist/chunks/{index.4GFF2h22.js → index.nEwtF0bu.js} +6 -6
- package/dist/chunks/{node.Bx4JZjMG.js → node.AKq966Jp.js} +1 -5
- package/dist/chunks/{reporters.C4ZHgdxQ.d.ts → reporters.D7Jzd9GS.d.ts} +1246 -1221
- package/dist/chunks/{resolveConfig.Dha6ilPI.js → resolveConfig.RxKrDli4.js} +3196 -3176
- package/dist/chunks/{rpc.B7Mfb-Yf.js → rpc.C3q9uwRX.js} +2 -2
- package/dist/chunks/{run-once.Sxe67Wng.js → run-once.2ogXb3JV.js} +1 -1
- package/dist/chunks/{runBaseTests.Cx4wXyTR.js → runBaseTests.3qpJUEJM.js} +21 -25
- package/dist/chunks/{setup-common.BKyF15v_.js → setup-common.Dj6BZI3u.js} +3 -3
- package/dist/chunks/{suite.BMWOKiTe.d.ts → suite.B2jumIFP.d.ts} +2 -2
- package/dist/chunks/utils.C8RiOc4B.js +77 -0
- package/dist/chunks/{utils.CY6Spixo.js → utils.DNoFbBUZ.js} +7 -3
- package/dist/chunks/{vi.BskyZC5g.js → vi.DgezovHB.js} +177 -142
- package/dist/chunks/{vite.YH7MrecS.d.ts → vite.C-N5BBZe.d.ts} +1 -1
- package/dist/chunks/{vm.DB_hLchi.js → vm.Zr4qWzDJ.js} +8 -8
- package/dist/chunks/{worker.CcJLfX8w.d.ts → worker.B9FxPCaC.d.ts} +1 -1
- package/dist/chunks/{worker.B6RjTtbk.d.ts → worker.tN5KGIih.d.ts} +14 -4
- package/dist/cli.js +3 -4
- package/dist/config.cjs +4 -4
- package/dist/config.d.ts +11 -11
- package/dist/config.js +4 -4
- package/dist/coverage.d.ts +10 -10
- package/dist/coverage.js +8 -11
- package/dist/environments.d.ts +2 -2
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +54 -54
- package/dist/execute.js +7 -6
- package/dist/index.d.ts +106 -1101
- package/dist/index.js +7 -18
- package/dist/node.d.ts +44 -42
- package/dist/node.js +23 -29
- package/dist/path.js +1 -1
- package/dist/reporters.d.ts +10 -10
- package/dist/reporters.js +12 -18
- package/dist/runners.d.ts +12 -19
- package/dist/runners.js +142 -148
- package/dist/snapshot.js +2 -6
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +2 -6
- package/dist/worker.js +10 -7
- package/dist/workers/forks.js +9 -8
- package/dist/workers/runVmTests.js +16 -20
- package/dist/workers/threads.js +9 -8
- package/dist/workers/vmForks.js +9 -12
- package/dist/workers/vmThreads.js +9 -12
- package/dist/workers.d.ts +14 -14
- package/dist/workers.js +15 -18
- package/package.json +27 -27
- package/dist/chunks/base.DwXGwWst.js +0 -89
- package/dist/chunks/env.CmHVDJnw.js +0 -7
- package/dist/chunks/index.-d_XpZEA.js +0 -140
- package/dist/chunks/index.CxRxs566.js +0 -23
- package/dist/chunks/tasks.BZnCS9aT.js +0 -18
- package/dist/chunks/utils.Ck2hJTRs.js +0 -23
- package/dist/chunks/{environment.CzISCQ7o.d.ts → environment.LoooBwUu.d.ts} +24 -24
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { existsSync, promises, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { createFileTask, limitConcurrency, getTasks, hasFailed, getTests, getNames } from '@vitest/runner/utils';
|
|
3
|
+
import { normalize, relative, dirname, resolve, join, basename, isAbsolute } from 'pathe';
|
|
4
|
+
import { g as getCoverageProvider, C as CoverageProviderMap } from './coverage.BoMDb1ip.js';
|
|
5
|
+
import a, { resolve as resolve$1 } from 'node:path';
|
|
6
|
+
import { noop, isPrimitive, toArray, deepMerge, nanoid, slash, notNullish, createDefer } from '@vitest/utils';
|
|
7
|
+
import { f as findUp, p as prompt } from './index.BJDntFik.js';
|
|
4
8
|
import { searchForWorkspaceRoot, version, createServer, mergeConfig } from 'vite';
|
|
5
|
-
import {
|
|
6
|
-
import { A as API_PATH, c as configFiles, w as workspacesFiles, d as defaultPort } from './constants.fzPh7AOq.js';
|
|
7
|
-
import { e as requireMicromatch, V as VitestCache, f as configDefaults, m as mm, d as resolveConfig, i as isBrowserEnabled, h as isPackageExists, g as getFilePoolName, j as createPool, b as resolveApiServerConfig, c as coverageConfigDefaults } from './resolveConfig.Dha6ilPI.js';
|
|
8
|
-
import { ViteNodeRunner } from 'vite-node/client';
|
|
9
|
+
import { A as API_PATH, c as configFiles, a as defaultBrowserPort, w as workspacesFiles, d as defaultPort } from './constants.fzPh7AOq.js';
|
|
9
10
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
11
|
+
import { i as isPackageExists, e as requireMicromatch, V as VitestCache, f as configDefaults, m as mm, b as resolveConfig, h as isBrowserEnabled, w as wildcardPatternToRegExp, g as getFilePoolName, j as createPool, a as resolveApiServerConfig, c as coverageConfigDefaults, s as stdout } from './resolveConfig.RxKrDli4.js';
|
|
12
|
+
import { ViteNodeRunner } from 'vite-node/client';
|
|
10
13
|
import { ViteNodeServer } from 'vite-node/server';
|
|
11
|
-
import { v as version$1 } from './cac.
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { toArray as toArray$1, nanoid, notNullish, createDefer } from '@vitest/utils';
|
|
15
|
-
import { i as isWindows } from './env.CmHVDJnw.js';
|
|
16
|
-
import { c as createBirpc } from './index.BpSiYbpB.js';
|
|
17
|
-
import { s as stringify, p as parse, R as ReportersMap, h as BenchmarkReportsMap, f as TestModule, g as TestSuite, e as TestCase, j as generateCodeFrame, i as TestProject, L as Logger, k as BlobReporter, r as readBlobs } from './index.Dz2opmmU.js';
|
|
14
|
+
import { v as version$1 } from './cac.DWAW3Uh5.js';
|
|
15
|
+
import { c as createBirpc } from './index.68735LiX.js';
|
|
16
|
+
import { s as stringify, p as parse, R as ReportersMap, h as BenchmarkReportsMap, f as TestModule, g as TestSuite, e as TestCase, j as generateCodeFrame, i as TestProject, L as Logger, k as BlobReporter, r as readBlobs } from './index.DsZFoqi9.js';
|
|
18
17
|
import require$$0$2 from 'stream';
|
|
19
18
|
import require$$0 from 'zlib';
|
|
20
19
|
import require$$0$1 from 'buffer';
|
|
@@ -28,95 +27,22 @@ import require$$7 from 'url';
|
|
|
28
27
|
import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHelpers.BFTU3MAI.js';
|
|
29
28
|
import { parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
30
29
|
import { distDir, rootDir } from '../path.js';
|
|
31
|
-
import {
|
|
30
|
+
import { createRequire } from 'node:module';
|
|
31
|
+
import url from 'node:url';
|
|
32
|
+
import c from 'tinyrainbow';
|
|
33
|
+
import { h as hash, i as isWindows } from './RandomSequencer.CMRlh2v4.js';
|
|
34
|
+
import { isCI } from 'std-env';
|
|
32
35
|
import { rm } from 'node:fs/promises';
|
|
36
|
+
import nodeos__default, { tmpdir } from 'node:os';
|
|
33
37
|
import require$$0$4 from 'os';
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import { createHash } from 'node:crypto';
|
|
38
|
+
import require$$0$5 from 'path';
|
|
39
|
+
import require$$0$6 from 'fs';
|
|
37
40
|
import { normalizeRequestId, cleanUrl } from 'vite-node/utils';
|
|
38
|
-
import MagicString from 'magic-string';
|
|
39
41
|
import { hoistMocksPlugin, automockPlugin } from '@vitest/mocker/node';
|
|
40
|
-
import
|
|
41
|
-
import { createRequire } from 'node:module';
|
|
42
|
-
import c from 'tinyrainbow';
|
|
43
|
-
import { isCI } from 'std-env';
|
|
44
|
-
import { isMainThread } from 'node:worker_threads';
|
|
45
|
-
import { a as removeUndefinedValues } from './index.CxRxs566.js';
|
|
42
|
+
import MagicString from 'magic-string';
|
|
46
43
|
import readline from 'node:readline';
|
|
47
44
|
import { stripVTControlCharacters } from 'node:util';
|
|
48
45
|
|
|
49
|
-
async function getModuleGraph(ctx, projectName, id, browser = false) {
|
|
50
|
-
const graph = {};
|
|
51
|
-
const externalized = /* @__PURE__ */ new Set();
|
|
52
|
-
const inlined = /* @__PURE__ */ new Set();
|
|
53
|
-
const project = ctx.getProjectByName(projectName);
|
|
54
|
-
async function get(mod, seen = /* @__PURE__ */ new Map()) {
|
|
55
|
-
if (!mod || !mod.id) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (mod.id === "\0@vitest/browser/context") {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (seen.has(mod)) {
|
|
62
|
-
return seen.get(mod);
|
|
63
|
-
}
|
|
64
|
-
let id2 = clearId(mod.id);
|
|
65
|
-
seen.set(mod, id2);
|
|
66
|
-
const rewrote = browser ? mod.file?.includes(project.browser.vite.config.cacheDir) ? mod.id : false : await project.vitenode.shouldExternalize(id2);
|
|
67
|
-
if (rewrote) {
|
|
68
|
-
id2 = rewrote;
|
|
69
|
-
externalized.add(id2);
|
|
70
|
-
seen.set(mod, id2);
|
|
71
|
-
} else {
|
|
72
|
-
inlined.add(id2);
|
|
73
|
-
}
|
|
74
|
-
const mods = Array.from(mod.importedModules).filter(
|
|
75
|
-
(i) => i.id && !i.id.includes("/vitest/dist/")
|
|
76
|
-
);
|
|
77
|
-
graph[id2] = (await Promise.all(mods.map((m) => get(m, seen)))).filter(
|
|
78
|
-
Boolean
|
|
79
|
-
);
|
|
80
|
-
return id2;
|
|
81
|
-
}
|
|
82
|
-
if (browser && project.browser) {
|
|
83
|
-
await get(project.browser.vite.moduleGraph.getModuleById(id));
|
|
84
|
-
} else {
|
|
85
|
-
await get(project.server.moduleGraph.getModuleById(id));
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
graph,
|
|
89
|
-
externalized: Array.from(externalized),
|
|
90
|
-
inlined: Array.from(inlined)
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function clearId(id) {
|
|
94
|
-
return id?.replace(/\?v=\w+$/, "") || "";
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function cloneByOwnProperties(value) {
|
|
98
|
-
return Object.getOwnPropertyNames(value).reduce(
|
|
99
|
-
(clone, prop) => ({
|
|
100
|
-
...clone,
|
|
101
|
-
[prop]: value[prop]
|
|
102
|
-
}),
|
|
103
|
-
{}
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
function stringifyReplace(key, value) {
|
|
107
|
-
if (value instanceof Error) {
|
|
108
|
-
const cloned = cloneByOwnProperties(value);
|
|
109
|
-
return {
|
|
110
|
-
name: value.name,
|
|
111
|
-
message: value.message,
|
|
112
|
-
stack: value.stack,
|
|
113
|
-
...cloned
|
|
114
|
-
};
|
|
115
|
-
} else {
|
|
116
|
-
return value;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
46
|
var bufferUtil = {exports: {}};
|
|
121
47
|
|
|
122
48
|
var constants$1;
|
|
@@ -4883,6 +4809,77 @@ function requireWebsocketServer () {
|
|
|
4883
4809
|
var websocketServerExports = requireWebsocketServer();
|
|
4884
4810
|
var WebSocketServer = /*@__PURE__*/getDefaultExportFromCjs(websocketServerExports);
|
|
4885
4811
|
|
|
4812
|
+
async function getModuleGraph(ctx, projectName, id, browser = false) {
|
|
4813
|
+
const graph = {};
|
|
4814
|
+
const externalized = /* @__PURE__ */ new Set();
|
|
4815
|
+
const inlined = /* @__PURE__ */ new Set();
|
|
4816
|
+
const project = ctx.getProjectByName(projectName);
|
|
4817
|
+
async function get(mod, seen = /* @__PURE__ */ new Map()) {
|
|
4818
|
+
if (!mod || !mod.id) {
|
|
4819
|
+
return;
|
|
4820
|
+
}
|
|
4821
|
+
if (mod.id === "\0@vitest/browser/context") {
|
|
4822
|
+
return;
|
|
4823
|
+
}
|
|
4824
|
+
if (seen.has(mod)) {
|
|
4825
|
+
return seen.get(mod);
|
|
4826
|
+
}
|
|
4827
|
+
let id2 = clearId(mod.id);
|
|
4828
|
+
seen.set(mod, id2);
|
|
4829
|
+
const rewrote = browser ? mod.file?.includes(project.browser.vite.config.cacheDir) ? mod.id : false : await project.vitenode.shouldExternalize(id2);
|
|
4830
|
+
if (rewrote) {
|
|
4831
|
+
id2 = rewrote;
|
|
4832
|
+
externalized.add(id2);
|
|
4833
|
+
seen.set(mod, id2);
|
|
4834
|
+
} else {
|
|
4835
|
+
inlined.add(id2);
|
|
4836
|
+
}
|
|
4837
|
+
const mods = Array.from(mod.importedModules).filter(
|
|
4838
|
+
(i) => i.id && !i.id.includes("/vitest/dist/")
|
|
4839
|
+
);
|
|
4840
|
+
graph[id2] = (await Promise.all(mods.map((m) => get(m, seen)))).filter(
|
|
4841
|
+
Boolean
|
|
4842
|
+
);
|
|
4843
|
+
return id2;
|
|
4844
|
+
}
|
|
4845
|
+
if (browser && project.browser) {
|
|
4846
|
+
await get(project.browser.vite.moduleGraph.getModuleById(id));
|
|
4847
|
+
} else {
|
|
4848
|
+
await get(project.server.moduleGraph.getModuleById(id));
|
|
4849
|
+
}
|
|
4850
|
+
return {
|
|
4851
|
+
graph,
|
|
4852
|
+
externalized: Array.from(externalized),
|
|
4853
|
+
inlined: Array.from(inlined)
|
|
4854
|
+
};
|
|
4855
|
+
}
|
|
4856
|
+
function clearId(id) {
|
|
4857
|
+
return id?.replace(/\?v=\w+$/, "") || "";
|
|
4858
|
+
}
|
|
4859
|
+
|
|
4860
|
+
function cloneByOwnProperties(value) {
|
|
4861
|
+
return Object.getOwnPropertyNames(value).reduce(
|
|
4862
|
+
(clone, prop) => ({
|
|
4863
|
+
...clone,
|
|
4864
|
+
[prop]: value[prop]
|
|
4865
|
+
}),
|
|
4866
|
+
{}
|
|
4867
|
+
);
|
|
4868
|
+
}
|
|
4869
|
+
function stringifyReplace(key, value) {
|
|
4870
|
+
if (value instanceof Error) {
|
|
4871
|
+
const cloned = cloneByOwnProperties(value);
|
|
4872
|
+
return {
|
|
4873
|
+
name: value.name,
|
|
4874
|
+
message: value.message,
|
|
4875
|
+
stack: value.stack,
|
|
4876
|
+
...cloned
|
|
4877
|
+
};
|
|
4878
|
+
} else {
|
|
4879
|
+
return value;
|
|
4880
|
+
}
|
|
4881
|
+
}
|
|
4882
|
+
|
|
4886
4883
|
function setup(ctx, _server) {
|
|
4887
4884
|
const wss = new WebSocketServer({ noServer: true });
|
|
4888
4885
|
const clients = /* @__PURE__ */ new Map();
|
|
@@ -5057,6 +5054,75 @@ var setup$1 = /*#__PURE__*/Object.freeze({
|
|
|
5057
5054
|
setup: setup
|
|
5058
5055
|
});
|
|
5059
5056
|
|
|
5057
|
+
class FilesNotFoundError extends Error {
|
|
5058
|
+
code = "VITEST_FILES_NOT_FOUND";
|
|
5059
|
+
constructor(mode) {
|
|
5060
|
+
super(`No ${mode} files found`);
|
|
5061
|
+
}
|
|
5062
|
+
}
|
|
5063
|
+
class GitNotFoundError extends Error {
|
|
5064
|
+
code = "VITEST_GIT_NOT_FOUND";
|
|
5065
|
+
constructor() {
|
|
5066
|
+
super("Could not find Git root. Have you initialized git with `git init`?");
|
|
5067
|
+
}
|
|
5068
|
+
}
|
|
5069
|
+
|
|
5070
|
+
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
5071
|
+
class VitestPackageInstaller {
|
|
5072
|
+
isPackageExists(name, options) {
|
|
5073
|
+
return isPackageExists(name, options);
|
|
5074
|
+
}
|
|
5075
|
+
async ensureInstalled(dependency, root, version) {
|
|
5076
|
+
if (process.env.VITEST_SKIP_INSTALL_CHECKS) {
|
|
5077
|
+
return true;
|
|
5078
|
+
}
|
|
5079
|
+
if (process.versions.pnp) {
|
|
5080
|
+
const targetRequire = createRequire(__dirname);
|
|
5081
|
+
try {
|
|
5082
|
+
targetRequire.resolve(dependency, { paths: [root, __dirname] });
|
|
5083
|
+
return true;
|
|
5084
|
+
} catch {
|
|
5085
|
+
}
|
|
5086
|
+
}
|
|
5087
|
+
if (/* @__PURE__ */ isPackageExists(dependency, { paths: [root, __dirname] })) {
|
|
5088
|
+
return true;
|
|
5089
|
+
}
|
|
5090
|
+
const promptInstall = !isCI && process.stdout.isTTY;
|
|
5091
|
+
process.stderr.write(
|
|
5092
|
+
c.red(
|
|
5093
|
+
`${c.inverse(
|
|
5094
|
+
c.red(" MISSING DEPENDENCY ")
|
|
5095
|
+
)} Cannot find dependency '${dependency}'
|
|
5096
|
+
|
|
5097
|
+
`
|
|
5098
|
+
)
|
|
5099
|
+
);
|
|
5100
|
+
if (!promptInstall) {
|
|
5101
|
+
return false;
|
|
5102
|
+
}
|
|
5103
|
+
const prompts = await import('./index.BJDntFik.js').then(function (n) { return n.i; });
|
|
5104
|
+
const { install } = await prompts.prompt({
|
|
5105
|
+
type: "confirm",
|
|
5106
|
+
name: "install",
|
|
5107
|
+
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
5108
|
+
});
|
|
5109
|
+
if (install) {
|
|
5110
|
+
const packageName = version ? `${dependency}@${version}` : dependency;
|
|
5111
|
+
await (await import('./index.CqYx2Nsr.js')).installPackage(packageName, { dev: true });
|
|
5112
|
+
process.stderr.write(
|
|
5113
|
+
c.yellow(
|
|
5114
|
+
`
|
|
5115
|
+
Package ${packageName} installed, re-run the command to start.
|
|
5116
|
+
`
|
|
5117
|
+
)
|
|
5118
|
+
);
|
|
5119
|
+
process.exit();
|
|
5120
|
+
return true;
|
|
5121
|
+
}
|
|
5122
|
+
return false;
|
|
5123
|
+
}
|
|
5124
|
+
}
|
|
5125
|
+
|
|
5060
5126
|
async function loadCustomReporterModule(path, runner) {
|
|
5061
5127
|
let customReporterModule;
|
|
5062
5128
|
try {
|
|
@@ -5389,7 +5455,7 @@ function requirePath () {
|
|
|
5389
5455
|
Object.defineProperty(path, "__esModule", { value: true });
|
|
5390
5456
|
path.convertPosixPathToPattern = path.convertWindowsPathToPattern = path.convertPathToPattern = path.escapePosixPath = path.escapeWindowsPath = path.escape = path.removeLeadingDotSegment = path.makeAbsolute = path.unixify = void 0;
|
|
5391
5457
|
const os = require$$0$4;
|
|
5392
|
-
const path$1 =
|
|
5458
|
+
const path$1 = require$$0$5;
|
|
5393
5459
|
const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
|
|
5394
5460
|
const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
|
|
5395
5461
|
/**
|
|
@@ -5654,7 +5720,7 @@ function requireGlobParent () {
|
|
|
5654
5720
|
hasRequiredGlobParent = 1;
|
|
5655
5721
|
|
|
5656
5722
|
var isGlob = requireIsGlob();
|
|
5657
|
-
var pathPosixDirname =
|
|
5723
|
+
var pathPosixDirname = require$$0$5.posix.dirname;
|
|
5658
5724
|
var isWin32 = require$$0$4.platform() === 'win32';
|
|
5659
5725
|
|
|
5660
5726
|
var slash = '/';
|
|
@@ -5703,7 +5769,7 @@ function requirePattern () {
|
|
|
5703
5769
|
hasRequiredPattern = 1;
|
|
5704
5770
|
Object.defineProperty(pattern, "__esModule", { value: true });
|
|
5705
5771
|
pattern.removeDuplicateSlashes = pattern.matchAny = pattern.convertPatternsToRe = pattern.makeRe = pattern.getPatternParts = pattern.expandBraceExpansion = pattern.expandPatternsWithBraceExpansion = pattern.isAffectDepthOfReadingPattern = pattern.endsWithSlashGlobStar = pattern.hasGlobStar = pattern.getBaseDirectory = pattern.isPatternRelatedToParentDirectory = pattern.getPatternsOutsideCurrentDirectory = pattern.getPatternsInsideCurrentDirectory = pattern.getPositivePatterns = pattern.getNegativePatterns = pattern.isPositivePattern = pattern.isNegativePattern = pattern.convertToNegativePattern = pattern.convertToPositivePattern = pattern.isDynamicPattern = pattern.isStaticPattern = void 0;
|
|
5706
|
-
const path =
|
|
5772
|
+
const path = require$$0$5;
|
|
5707
5773
|
const globParent = requireGlobParent();
|
|
5708
5774
|
const micromatch = requireMicromatch();
|
|
5709
5775
|
const GLOBSTAR = '**';
|
|
@@ -6335,7 +6401,7 @@ function requireFs$2 () {
|
|
|
6335
6401
|
(function (exports) {
|
|
6336
6402
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6337
6403
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
6338
|
-
const fs =
|
|
6404
|
+
const fs = require$$0$6;
|
|
6339
6405
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
6340
6406
|
lstat: fs.lstat,
|
|
6341
6407
|
stat: fs.stat,
|
|
@@ -6765,7 +6831,7 @@ function requireFs () {
|
|
|
6765
6831
|
(function (exports) {
|
|
6766
6832
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6767
6833
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
6768
|
-
const fs =
|
|
6834
|
+
const fs = require$$0$6;
|
|
6769
6835
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
6770
6836
|
lstat: fs.lstat,
|
|
6771
6837
|
stat: fs.stat,
|
|
@@ -6791,7 +6857,7 @@ function requireSettings$2 () {
|
|
|
6791
6857
|
if (hasRequiredSettings$2) return settings$2;
|
|
6792
6858
|
hasRequiredSettings$2 = 1;
|
|
6793
6859
|
Object.defineProperty(settings$2, "__esModule", { value: true });
|
|
6794
|
-
const path =
|
|
6860
|
+
const path = require$$0$5;
|
|
6795
6861
|
const fsStat = requireOut$3();
|
|
6796
6862
|
const fs = requireFs();
|
|
6797
6863
|
class Settings {
|
|
@@ -7553,7 +7619,7 @@ function requireSettings$1 () {
|
|
|
7553
7619
|
if (hasRequiredSettings$1) return settings$1;
|
|
7554
7620
|
hasRequiredSettings$1 = 1;
|
|
7555
7621
|
Object.defineProperty(settings$1, "__esModule", { value: true });
|
|
7556
|
-
const path =
|
|
7622
|
+
const path = require$$0$5;
|
|
7557
7623
|
const fsScandir = requireOut$2();
|
|
7558
7624
|
class Settings {
|
|
7559
7625
|
constructor(_options = {}) {
|
|
@@ -7629,7 +7695,7 @@ function requireReader () {
|
|
|
7629
7695
|
if (hasRequiredReader) return reader;
|
|
7630
7696
|
hasRequiredReader = 1;
|
|
7631
7697
|
Object.defineProperty(reader, "__esModule", { value: true });
|
|
7632
|
-
const path =
|
|
7698
|
+
const path = require$$0$5;
|
|
7633
7699
|
const fsStat = requireOut$3();
|
|
7634
7700
|
const utils = requireUtils$1();
|
|
7635
7701
|
class Reader {
|
|
@@ -8080,7 +8146,7 @@ function requireProvider () {
|
|
|
8080
8146
|
if (hasRequiredProvider) return provider;
|
|
8081
8147
|
hasRequiredProvider = 1;
|
|
8082
8148
|
Object.defineProperty(provider, "__esModule", { value: true });
|
|
8083
|
-
const path =
|
|
8149
|
+
const path = require$$0$5;
|
|
8084
8150
|
const deep_1 = requireDeep();
|
|
8085
8151
|
const entry_1 = requireEntry$1();
|
|
8086
8152
|
const error_1 = requireError();
|
|
@@ -8293,7 +8359,7 @@ function requireSettings () {
|
|
|
8293
8359
|
(function (exports) {
|
|
8294
8360
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8295
8361
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
|
|
8296
|
-
const fs =
|
|
8362
|
+
const fs = require$$0$6;
|
|
8297
8363
|
const os = require$$0$4;
|
|
8298
8364
|
/**
|
|
8299
8365
|
* The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
|
|
@@ -8464,42 +8530,345 @@ function requireOut () {
|
|
|
8464
8530
|
var outExports = requireOut();
|
|
8465
8531
|
var fg = /*@__PURE__*/getDefaultExportFromCjs(outExports);
|
|
8466
8532
|
|
|
8467
|
-
function
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
if (strategy === "scoped") {
|
|
8472
|
-
return null;
|
|
8473
|
-
}
|
|
8474
|
-
if (strategy === "non-scoped") {
|
|
8475
|
-
return name;
|
|
8476
|
-
}
|
|
8477
|
-
const hash = generateCssFilenameHash(filename);
|
|
8478
|
-
return `_${name}_${hash}`;
|
|
8479
|
-
}
|
|
8480
|
-
|
|
8481
|
-
function CoverageTransform(ctx) {
|
|
8533
|
+
function serializeConfig(config, coreConfig, viteConfig) {
|
|
8534
|
+
const optimizer = config.deps?.optimizer;
|
|
8535
|
+
const poolOptions = config.poolOptions;
|
|
8536
|
+
const isolate = viteConfig?.test?.isolate;
|
|
8482
8537
|
return {
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8538
|
+
// TODO: remove functions from environmentOptions
|
|
8539
|
+
environmentOptions: config.environmentOptions,
|
|
8540
|
+
mode: config.mode,
|
|
8541
|
+
isolate: config.isolate,
|
|
8542
|
+
base: config.base,
|
|
8543
|
+
logHeapUsage: config.logHeapUsage,
|
|
8544
|
+
runner: config.runner,
|
|
8545
|
+
bail: config.bail,
|
|
8546
|
+
defines: config.defines,
|
|
8547
|
+
chaiConfig: config.chaiConfig,
|
|
8548
|
+
setupFiles: config.setupFiles,
|
|
8549
|
+
allowOnly: config.allowOnly,
|
|
8550
|
+
testTimeout: config.testTimeout,
|
|
8551
|
+
testNamePattern: config.testNamePattern,
|
|
8552
|
+
hookTimeout: config.hookTimeout,
|
|
8553
|
+
clearMocks: config.clearMocks,
|
|
8554
|
+
mockReset: config.mockReset,
|
|
8555
|
+
restoreMocks: config.restoreMocks,
|
|
8556
|
+
unstubEnvs: config.unstubEnvs,
|
|
8557
|
+
unstubGlobals: config.unstubGlobals,
|
|
8558
|
+
maxConcurrency: config.maxConcurrency,
|
|
8559
|
+
pool: config.pool,
|
|
8560
|
+
expect: config.expect,
|
|
8561
|
+
snapshotSerializers: config.snapshotSerializers,
|
|
8562
|
+
diff: config.diff,
|
|
8563
|
+
retry: config.retry,
|
|
8564
|
+
disableConsoleIntercept: config.disableConsoleIntercept,
|
|
8565
|
+
root: config.root,
|
|
8566
|
+
name: config.name,
|
|
8567
|
+
globals: config.globals,
|
|
8568
|
+
snapshotEnvironment: config.snapshotEnvironment,
|
|
8569
|
+
passWithNoTests: config.passWithNoTests,
|
|
8570
|
+
coverage: ((coverage) => {
|
|
8571
|
+
const htmlReporter = coverage.reporter.find(([reporterName]) => reporterName === "html");
|
|
8572
|
+
const subdir = htmlReporter && htmlReporter[1]?.subdir;
|
|
8573
|
+
return {
|
|
8574
|
+
reportsDirectory: coverage.reportsDirectory,
|
|
8575
|
+
provider: coverage.provider,
|
|
8576
|
+
enabled: coverage.enabled,
|
|
8577
|
+
htmlReporter: htmlReporter ? { subdir } : void 0,
|
|
8578
|
+
customProviderModule: "customProviderModule" in coverage ? coverage.customProviderModule : void 0
|
|
8579
|
+
};
|
|
8580
|
+
})(config.coverage),
|
|
8581
|
+
fakeTimers: config.fakeTimers,
|
|
8582
|
+
poolOptions: {
|
|
8583
|
+
forks: {
|
|
8584
|
+
singleFork: poolOptions?.forks?.singleFork ?? coreConfig.poolOptions?.forks?.singleFork ?? false,
|
|
8585
|
+
isolate: poolOptions?.forks?.isolate ?? isolate ?? coreConfig.poolOptions?.forks?.isolate ?? true
|
|
8586
|
+
},
|
|
8587
|
+
threads: {
|
|
8588
|
+
singleThread: poolOptions?.threads?.singleThread ?? coreConfig.poolOptions?.threads?.singleThread ?? false,
|
|
8589
|
+
isolate: poolOptions?.threads?.isolate ?? isolate ?? coreConfig.poolOptions?.threads?.isolate ?? true
|
|
8590
|
+
},
|
|
8591
|
+
vmThreads: {
|
|
8592
|
+
singleThread: poolOptions?.vmThreads?.singleThread ?? coreConfig.poolOptions?.vmThreads?.singleThread ?? false
|
|
8593
|
+
},
|
|
8594
|
+
vmForks: {
|
|
8595
|
+
singleFork: poolOptions?.vmForks?.singleFork ?? coreConfig.poolOptions?.vmForks?.singleFork ?? false
|
|
8596
|
+
}
|
|
8597
|
+
},
|
|
8598
|
+
deps: {
|
|
8599
|
+
web: config.deps.web || {},
|
|
8600
|
+
optimizer: {
|
|
8601
|
+
web: {
|
|
8602
|
+
enabled: optimizer?.web?.enabled ?? true
|
|
8603
|
+
},
|
|
8604
|
+
ssr: {
|
|
8605
|
+
enabled: optimizer?.ssr?.enabled ?? true
|
|
8606
|
+
}
|
|
8607
|
+
},
|
|
8608
|
+
interopDefault: config.deps.interopDefault,
|
|
8609
|
+
moduleDirectories: config.deps.moduleDirectories
|
|
8610
|
+
},
|
|
8611
|
+
snapshotOptions: {
|
|
8612
|
+
// TODO: store it differently, not on the config
|
|
8613
|
+
snapshotEnvironment: void 0,
|
|
8614
|
+
updateSnapshot: coreConfig.snapshotOptions.updateSnapshot,
|
|
8615
|
+
snapshotFormat: {
|
|
8616
|
+
...coreConfig.snapshotOptions.snapshotFormat,
|
|
8617
|
+
compareKeys: void 0
|
|
8618
|
+
},
|
|
8619
|
+
expand: config.snapshotOptions.expand ?? coreConfig.snapshotOptions.expand
|
|
8620
|
+
},
|
|
8621
|
+
sequence: {
|
|
8622
|
+
shuffle: coreConfig.sequence.shuffle,
|
|
8623
|
+
concurrent: coreConfig.sequence.concurrent,
|
|
8624
|
+
seed: coreConfig.sequence.seed,
|
|
8625
|
+
hooks: coreConfig.sequence.hooks,
|
|
8626
|
+
setupFiles: coreConfig.sequence.setupFiles
|
|
8627
|
+
},
|
|
8628
|
+
inspect: coreConfig.inspect,
|
|
8629
|
+
inspectBrk: coreConfig.inspectBrk,
|
|
8630
|
+
inspector: coreConfig.inspector,
|
|
8631
|
+
watch: config.watch,
|
|
8632
|
+
includeTaskLocation: config.includeTaskLocation ?? coreConfig.includeTaskLocation,
|
|
8633
|
+
env: {
|
|
8634
|
+
...viteConfig?.env,
|
|
8635
|
+
...config.env
|
|
8636
|
+
},
|
|
8637
|
+
browser: ((browser) => {
|
|
8638
|
+
return {
|
|
8639
|
+
name: browser.name,
|
|
8640
|
+
headless: browser.headless,
|
|
8641
|
+
isolate: browser.isolate,
|
|
8642
|
+
fileParallelism: browser.fileParallelism,
|
|
8643
|
+
ui: browser.ui,
|
|
8644
|
+
viewport: browser.viewport,
|
|
8645
|
+
screenshotFailures: browser.screenshotFailures,
|
|
8646
|
+
locators: {
|
|
8647
|
+
testIdAttribute: browser.locators.testIdAttribute
|
|
8648
|
+
}
|
|
8649
|
+
};
|
|
8650
|
+
})(config.browser),
|
|
8651
|
+
standalone: config.standalone,
|
|
8652
|
+
printConsoleTrace: config.printConsoleTrace ?? coreConfig.printConsoleTrace,
|
|
8653
|
+
benchmark: config.benchmark && {
|
|
8654
|
+
includeSamples: config.benchmark.includeSamples
|
|
8655
|
+
}
|
|
8656
|
+
};
|
|
8657
|
+
}
|
|
8658
|
+
|
|
8659
|
+
async function loadGlobalSetupFiles(runner, globalSetup) {
|
|
8660
|
+
const globalSetupFiles = toArray(globalSetup);
|
|
8661
|
+
return Promise.all(
|
|
8662
|
+
globalSetupFiles.map((file) => loadGlobalSetupFile(file, runner))
|
|
8663
|
+
);
|
|
8664
|
+
}
|
|
8665
|
+
async function loadGlobalSetupFile(file, runner) {
|
|
8666
|
+
const m = await runner.executeFile(file);
|
|
8667
|
+
for (const exp of ["default", "setup", "teardown"]) {
|
|
8668
|
+
if (m[exp] != null && typeof m[exp] !== "function") {
|
|
8669
|
+
throw new Error(
|
|
8670
|
+
`invalid export in globalSetup file ${file}: ${exp} must be a function`
|
|
8671
|
+
);
|
|
8672
|
+
}
|
|
8673
|
+
}
|
|
8674
|
+
if (m.default) {
|
|
8675
|
+
return {
|
|
8676
|
+
file,
|
|
8677
|
+
setup: m.default
|
|
8678
|
+
};
|
|
8679
|
+
} else if (m.setup || m.teardown) {
|
|
8680
|
+
return {
|
|
8681
|
+
file,
|
|
8682
|
+
setup: m.setup,
|
|
8683
|
+
teardown: m.teardown
|
|
8684
|
+
};
|
|
8685
|
+
} else {
|
|
8686
|
+
throw new Error(
|
|
8687
|
+
`invalid globalSetup file ${file}. Must export setup, teardown or have a default export`
|
|
8688
|
+
);
|
|
8689
|
+
}
|
|
8690
|
+
}
|
|
8691
|
+
|
|
8692
|
+
function CoverageTransform(ctx) {
|
|
8693
|
+
return {
|
|
8694
|
+
name: "vitest:coverage-transform",
|
|
8695
|
+
transform(srcCode, id) {
|
|
8696
|
+
return ctx.coverageProvider?.onFileTransform?.(
|
|
8697
|
+
srcCode,
|
|
8698
|
+
normalizeRequestId(id),
|
|
8699
|
+
this
|
|
8700
|
+
);
|
|
8701
|
+
}
|
|
8702
|
+
};
|
|
8703
|
+
}
|
|
8704
|
+
|
|
8705
|
+
function MocksPlugins(options = {}) {
|
|
8706
|
+
const normalizedDistDir = normalize(distDir);
|
|
8707
|
+
return [
|
|
8708
|
+
hoistMocksPlugin({
|
|
8709
|
+
filter(id) {
|
|
8710
|
+
if (id.includes(normalizedDistDir)) {
|
|
8711
|
+
return false;
|
|
8712
|
+
}
|
|
8713
|
+
if (options.filter) {
|
|
8714
|
+
return options.filter(id);
|
|
8715
|
+
}
|
|
8716
|
+
return true;
|
|
8717
|
+
},
|
|
8718
|
+
codeFrameGenerator(node, id, code) {
|
|
8719
|
+
return generateCodeFrame(
|
|
8720
|
+
code,
|
|
8721
|
+
4,
|
|
8722
|
+
node.start + 1
|
|
8723
|
+
);
|
|
8724
|
+
}
|
|
8725
|
+
}),
|
|
8726
|
+
automockPlugin()
|
|
8727
|
+
];
|
|
8728
|
+
}
|
|
8729
|
+
|
|
8730
|
+
function generateCssFilenameHash(filepath) {
|
|
8731
|
+
return hash("md5", filepath, "hex").slice(0, 6);
|
|
8732
|
+
}
|
|
8733
|
+
function generateScopedClassName(strategy, name, filename) {
|
|
8734
|
+
if (strategy === "scoped") {
|
|
8735
|
+
return null;
|
|
8736
|
+
}
|
|
8737
|
+
if (strategy === "non-scoped") {
|
|
8738
|
+
return name;
|
|
8739
|
+
}
|
|
8740
|
+
const hash2 = generateCssFilenameHash(filename);
|
|
8741
|
+
return `_${name}_${hash2}`;
|
|
8742
|
+
}
|
|
8743
|
+
|
|
8744
|
+
const LogLevels = {
|
|
8745
|
+
silent: 0,
|
|
8746
|
+
error: 1,
|
|
8747
|
+
warn: 2,
|
|
8748
|
+
info: 3
|
|
8749
|
+
};
|
|
8750
|
+
function clearScreen(logger) {
|
|
8751
|
+
const repeatCount = process.stdout.rows - 2;
|
|
8752
|
+
const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
|
|
8753
|
+
logger.clearScreen(blank);
|
|
8754
|
+
}
|
|
8755
|
+
let lastType;
|
|
8756
|
+
let lastMsg;
|
|
8757
|
+
let sameCount = 0;
|
|
8758
|
+
let timeFormatter;
|
|
8759
|
+
function getTimeFormatter() {
|
|
8760
|
+
timeFormatter ??= new Intl.DateTimeFormat(void 0, {
|
|
8761
|
+
hour: "numeric",
|
|
8762
|
+
minute: "numeric",
|
|
8763
|
+
second: "numeric"
|
|
8764
|
+
});
|
|
8765
|
+
return timeFormatter;
|
|
8766
|
+
}
|
|
8767
|
+
function createViteLogger(console, level = "info", options = {}) {
|
|
8768
|
+
const loggedErrors = /* @__PURE__ */ new WeakSet();
|
|
8769
|
+
const { prefix = "[vite]", allowClearScreen = true } = options;
|
|
8770
|
+
const thresh = LogLevels[level];
|
|
8771
|
+
const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
|
|
8772
|
+
const clear = canClearScreen ? clearScreen : () => {
|
|
8773
|
+
};
|
|
8774
|
+
function format(type, msg, options2 = {}) {
|
|
8775
|
+
if (options2.timestamp) {
|
|
8776
|
+
let tag = "";
|
|
8777
|
+
if (type === "info") {
|
|
8778
|
+
tag = c.cyan(c.bold(prefix));
|
|
8779
|
+
} else if (type === "warn") {
|
|
8780
|
+
tag = c.yellow(c.bold(prefix));
|
|
8781
|
+
} else {
|
|
8782
|
+
tag = c.red(c.bold(prefix));
|
|
8783
|
+
}
|
|
8784
|
+
const environment = options2.environment ? `${options2.environment} ` : "";
|
|
8785
|
+
return `${c.dim(getTimeFormatter().format(/* @__PURE__ */ new Date()))} ${tag} ${environment}${msg}`;
|
|
8786
|
+
} else {
|
|
8787
|
+
return msg;
|
|
8788
|
+
}
|
|
8789
|
+
}
|
|
8790
|
+
function output(type, msg, options2 = {}) {
|
|
8791
|
+
if (thresh >= LogLevels[type]) {
|
|
8792
|
+
const method = type === "info" ? "log" : type;
|
|
8793
|
+
if (options2.error) {
|
|
8794
|
+
loggedErrors.add(options2.error);
|
|
8795
|
+
}
|
|
8796
|
+
if (canClearScreen) {
|
|
8797
|
+
if (type === lastType && msg === lastMsg) {
|
|
8798
|
+
sameCount++;
|
|
8799
|
+
clear(console);
|
|
8800
|
+
console[method](
|
|
8801
|
+
format(type, msg, options2),
|
|
8802
|
+
c.yellow(`(x${sameCount + 1})`)
|
|
8803
|
+
);
|
|
8804
|
+
} else {
|
|
8805
|
+
sameCount = 0;
|
|
8806
|
+
lastMsg = msg;
|
|
8807
|
+
lastType = type;
|
|
8808
|
+
if (options2.clear) {
|
|
8809
|
+
clear(console);
|
|
8810
|
+
}
|
|
8811
|
+
console[method](format(type, msg, options2));
|
|
8812
|
+
}
|
|
8813
|
+
} else {
|
|
8814
|
+
console[method](format(type, msg, options2));
|
|
8815
|
+
}
|
|
8816
|
+
}
|
|
8817
|
+
}
|
|
8818
|
+
const warnedMessages = /* @__PURE__ */ new Set();
|
|
8819
|
+
const logger = {
|
|
8820
|
+
hasWarned: false,
|
|
8821
|
+
info(msg, opts) {
|
|
8822
|
+
output("info", msg, opts);
|
|
8823
|
+
},
|
|
8824
|
+
warn(msg, opts) {
|
|
8825
|
+
logger.hasWarned = true;
|
|
8826
|
+
output("warn", msg, opts);
|
|
8827
|
+
},
|
|
8828
|
+
warnOnce(msg, opts) {
|
|
8829
|
+
if (warnedMessages.has(msg)) {
|
|
8830
|
+
return;
|
|
8831
|
+
}
|
|
8832
|
+
logger.hasWarned = true;
|
|
8833
|
+
output("warn", msg, opts);
|
|
8834
|
+
warnedMessages.add(msg);
|
|
8835
|
+
},
|
|
8836
|
+
error(msg, opts) {
|
|
8837
|
+
logger.hasWarned = true;
|
|
8838
|
+
output("error", msg, opts);
|
|
8839
|
+
},
|
|
8840
|
+
clearScreen(type) {
|
|
8841
|
+
if (thresh >= LogLevels[type]) {
|
|
8842
|
+
clear(console);
|
|
8843
|
+
}
|
|
8844
|
+
},
|
|
8845
|
+
hasErrorLogged(error) {
|
|
8846
|
+
return loggedErrors.has(error);
|
|
8847
|
+
}
|
|
8848
|
+
};
|
|
8849
|
+
return logger;
|
|
8850
|
+
}
|
|
8851
|
+
function silenceImportViteIgnoreWarning(logger) {
|
|
8852
|
+
return {
|
|
8853
|
+
...logger,
|
|
8854
|
+
warn(msg, options) {
|
|
8855
|
+
if (msg.includes("The above dynamic import cannot be analyzed by Vite")) {
|
|
8856
|
+
return;
|
|
8857
|
+
}
|
|
8858
|
+
logger.warn(msg, options);
|
|
8859
|
+
}
|
|
8860
|
+
};
|
|
8861
|
+
}
|
|
8862
|
+
|
|
8863
|
+
const cssLangs = "\\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)(?:$|\\?)";
|
|
8864
|
+
const cssLangRE = new RegExp(cssLangs);
|
|
8865
|
+
const cssModuleRE = new RegExp(`\\.module${cssLangs}`);
|
|
8866
|
+
const cssInlineRE = /[?&]inline(?:&|$)/;
|
|
8867
|
+
function isCSS(id) {
|
|
8868
|
+
return cssLangRE.test(id);
|
|
8869
|
+
}
|
|
8870
|
+
function isCSSModule(id) {
|
|
8871
|
+
return cssModuleRE.test(id);
|
|
8503
8872
|
}
|
|
8504
8873
|
function isInline(id) {
|
|
8505
8874
|
return cssInlineRE.test(id);
|
|
@@ -9048,58 +9417,34 @@ function stripLiteralDetailed(code, options) {
|
|
|
9048
9417
|
return stripLiteralJsTokens(code);
|
|
9049
9418
|
}
|
|
9050
9419
|
|
|
9051
|
-
|
|
9420
|
+
const metaUrlLength = "import.meta.url".length;
|
|
9421
|
+
const locationString = "self.location".padEnd(metaUrlLength, " ");
|
|
9422
|
+
function NormalizeURLPlugin() {
|
|
9052
9423
|
return {
|
|
9053
|
-
name: "vitest:
|
|
9054
|
-
enforce: "
|
|
9055
|
-
transform(code, id) {
|
|
9056
|
-
|
|
9057
|
-
|
|
9424
|
+
name: "vitest:normalize-url",
|
|
9425
|
+
enforce: "post",
|
|
9426
|
+
transform(code, id, options) {
|
|
9427
|
+
const ssr = options?.ssr === true;
|
|
9428
|
+
if (ssr || !code.includes("new URL") || !code.includes("import.meta.url")) {
|
|
9429
|
+
return;
|
|
9058
9430
|
}
|
|
9059
|
-
|
|
9060
|
-
const
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
const
|
|
9065
|
-
const
|
|
9066
|
-
|
|
9067
|
-
}
|
|
9068
|
-
if (s) {
|
|
9069
|
-
return {
|
|
9070
|
-
code: s.toString(),
|
|
9071
|
-
map: s.generateMap({
|
|
9072
|
-
hires: "boundary",
|
|
9073
|
-
// Remove possible query parameters, e.g. vue's "?vue&type=script&src=true&lang.ts"
|
|
9074
|
-
source: cleanUrl(id)
|
|
9075
|
-
})
|
|
9076
|
-
};
|
|
9431
|
+
const cleanString = stripLiteral(code);
|
|
9432
|
+
const assetImportMetaUrlRE = /\bnew\s+URL\s*\(\s*(?:'[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\)/g;
|
|
9433
|
+
let updatedCode = code;
|
|
9434
|
+
let match;
|
|
9435
|
+
while (match = assetImportMetaUrlRE.exec(cleanString)) {
|
|
9436
|
+
const { 0: exp, index } = match;
|
|
9437
|
+
const metaUrlIndex = index + exp.indexOf("import.meta.url");
|
|
9438
|
+
updatedCode = updatedCode.slice(0, metaUrlIndex) + locationString + updatedCode.slice(metaUrlIndex + metaUrlLength);
|
|
9077
9439
|
}
|
|
9440
|
+
return {
|
|
9441
|
+
code: updatedCode,
|
|
9442
|
+
map: null
|
|
9443
|
+
};
|
|
9078
9444
|
}
|
|
9079
9445
|
};
|
|
9080
9446
|
}
|
|
9081
9447
|
|
|
9082
|
-
function MocksPlugins() {
|
|
9083
|
-
return [
|
|
9084
|
-
hoistMocksPlugin({
|
|
9085
|
-
filter(id) {
|
|
9086
|
-
if (id.includes(distDir)) {
|
|
9087
|
-
return false;
|
|
9088
|
-
}
|
|
9089
|
-
return true;
|
|
9090
|
-
},
|
|
9091
|
-
codeFrameGenerator(node, id, code) {
|
|
9092
|
-
return generateCodeFrame(
|
|
9093
|
-
code,
|
|
9094
|
-
4,
|
|
9095
|
-
node.start + 1
|
|
9096
|
-
);
|
|
9097
|
-
}
|
|
9098
|
-
}),
|
|
9099
|
-
automockPlugin()
|
|
9100
|
-
];
|
|
9101
|
-
}
|
|
9102
|
-
|
|
9103
9448
|
function resolveOptimizerConfig(_testOptions, viteOptions, testConfig) {
|
|
9104
9449
|
const testOptions = _testOptions || {};
|
|
9105
9450
|
const newConfig = {};
|
|
@@ -9148,7 +9493,7 @@ function resolveOptimizerConfig(_testOptions, viteOptions, testConfig) {
|
|
|
9148
9493
|
include
|
|
9149
9494
|
};
|
|
9150
9495
|
}
|
|
9151
|
-
if (major >= 5 && minor >= 1) {
|
|
9496
|
+
if (major >= 5 && minor >= 1 || major >= 6) {
|
|
9152
9497
|
if (newConfig.optimizeDeps.disabled) {
|
|
9153
9498
|
newConfig.optimizeDeps.noDiscovery = true;
|
|
9154
9499
|
newConfig.optimizeDeps.include = [];
|
|
@@ -9210,39 +9555,6 @@ function resolveFsAllow(projectRoot, rootConfigFile) {
|
|
|
9210
9555
|
];
|
|
9211
9556
|
}
|
|
9212
9557
|
|
|
9213
|
-
function VitestProjectResolver(ctx) {
|
|
9214
|
-
const plugin = {
|
|
9215
|
-
name: "vitest:resolve-root",
|
|
9216
|
-
enforce: "pre",
|
|
9217
|
-
async resolveId(id, _, { ssr }) {
|
|
9218
|
-
if (id === "vitest" || id.startsWith("@vitest/") || id.startsWith("vitest/")) {
|
|
9219
|
-
const resolved = await ctx.server.pluginContainer.resolveId(id, void 0, {
|
|
9220
|
-
skip: /* @__PURE__ */ new Set([plugin]),
|
|
9221
|
-
ssr
|
|
9222
|
-
});
|
|
9223
|
-
return resolved;
|
|
9224
|
-
}
|
|
9225
|
-
}
|
|
9226
|
-
};
|
|
9227
|
-
return plugin;
|
|
9228
|
-
}
|
|
9229
|
-
function VitestCoreResolver(ctx) {
|
|
9230
|
-
return {
|
|
9231
|
-
name: "vitest:resolve-core",
|
|
9232
|
-
enforce: "pre",
|
|
9233
|
-
async resolveId(id) {
|
|
9234
|
-
if (id === "vitest") {
|
|
9235
|
-
return resolve(distDir, "index.js");
|
|
9236
|
-
}
|
|
9237
|
-
if (id.startsWith("@vitest/") || id.startsWith("vitest/")) {
|
|
9238
|
-
return this.resolve(id, join(ctx.config.root, "index.html"), {
|
|
9239
|
-
skipSelf: true
|
|
9240
|
-
});
|
|
9241
|
-
}
|
|
9242
|
-
}
|
|
9243
|
-
};
|
|
9244
|
-
}
|
|
9245
|
-
|
|
9246
9558
|
function VitestOptimizer() {
|
|
9247
9559
|
return {
|
|
9248
9560
|
name: "vitest:normalize-optimizer",
|
|
@@ -9269,30 +9581,66 @@ function VitestOptimizer() {
|
|
|
9269
9581
|
};
|
|
9270
9582
|
}
|
|
9271
9583
|
|
|
9272
|
-
|
|
9273
|
-
const locationString = "self.location".padEnd(metaUrlLength, " ");
|
|
9274
|
-
function NormalizeURLPlugin() {
|
|
9584
|
+
function SsrReplacerPlugin() {
|
|
9275
9585
|
return {
|
|
9276
|
-
name: "vitest:
|
|
9277
|
-
enforce: "
|
|
9278
|
-
transform(code, id
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
return;
|
|
9586
|
+
name: "vitest:ssr-replacer",
|
|
9587
|
+
enforce: "pre",
|
|
9588
|
+
transform(code, id) {
|
|
9589
|
+
if (!/\bimport\.meta\.env\b/.test(code)) {
|
|
9590
|
+
return null;
|
|
9282
9591
|
}
|
|
9283
|
-
|
|
9284
|
-
const
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
const
|
|
9289
|
-
const
|
|
9290
|
-
|
|
9592
|
+
let s = null;
|
|
9593
|
+
const cleanCode = stripLiteral(code);
|
|
9594
|
+
const envs = cleanCode.matchAll(/\bimport\.meta\.env\b/g);
|
|
9595
|
+
for (const env of envs) {
|
|
9596
|
+
s ||= new MagicString(code);
|
|
9597
|
+
const startIndex = env.index;
|
|
9598
|
+
const endIndex = startIndex + env[0].length;
|
|
9599
|
+
s.overwrite(startIndex, endIndex, "__vite_ssr_import_meta__.env");
|
|
9600
|
+
}
|
|
9601
|
+
if (s) {
|
|
9602
|
+
return {
|
|
9603
|
+
code: s.toString(),
|
|
9604
|
+
map: s.generateMap({
|
|
9605
|
+
hires: "boundary",
|
|
9606
|
+
// Remove possible query parameters, e.g. vue's "?vue&type=script&src=true&lang.ts"
|
|
9607
|
+
source: cleanUrl(id)
|
|
9608
|
+
})
|
|
9609
|
+
};
|
|
9610
|
+
}
|
|
9611
|
+
}
|
|
9612
|
+
};
|
|
9613
|
+
}
|
|
9614
|
+
|
|
9615
|
+
function VitestProjectResolver(ctx) {
|
|
9616
|
+
const plugin = {
|
|
9617
|
+
name: "vitest:resolve-root",
|
|
9618
|
+
enforce: "pre",
|
|
9619
|
+
async resolveId(id, _, { ssr }) {
|
|
9620
|
+
if (id === "vitest" || id.startsWith("@vitest/") || id.startsWith("vitest/")) {
|
|
9621
|
+
const resolved = await ctx.server.pluginContainer.resolveId(id, void 0, {
|
|
9622
|
+
skip: /* @__PURE__ */ new Set([plugin]),
|
|
9623
|
+
ssr
|
|
9624
|
+
});
|
|
9625
|
+
return resolved;
|
|
9626
|
+
}
|
|
9627
|
+
}
|
|
9628
|
+
};
|
|
9629
|
+
return plugin;
|
|
9630
|
+
}
|
|
9631
|
+
function VitestCoreResolver(ctx) {
|
|
9632
|
+
return {
|
|
9633
|
+
name: "vitest:resolve-core",
|
|
9634
|
+
enforce: "pre",
|
|
9635
|
+
async resolveId(id) {
|
|
9636
|
+
if (id === "vitest") {
|
|
9637
|
+
return resolve(distDir, "index.js");
|
|
9638
|
+
}
|
|
9639
|
+
if (id.startsWith("@vitest/") || id.startsWith("vitest/")) {
|
|
9640
|
+
return this.resolve(id, join(ctx.config.root, "index.html"), {
|
|
9641
|
+
skipSelf: true
|
|
9642
|
+
});
|
|
9291
9643
|
}
|
|
9292
|
-
return {
|
|
9293
|
-
code: updatedCode,
|
|
9294
|
-
map: null
|
|
9295
|
-
};
|
|
9296
9644
|
}
|
|
9297
9645
|
};
|
|
9298
9646
|
}
|
|
@@ -9310,266 +9658,111 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
9310
9658
|
const testConfig = viteConfig.test || {};
|
|
9311
9659
|
const root = testConfig.root || viteConfig.root || options.root;
|
|
9312
9660
|
let name = testConfig.name;
|
|
9313
|
-
if (!name) {
|
|
9314
|
-
if (typeof options.workspacePath === "string") {
|
|
9315
|
-
const dir = options.workspacePath.endsWith("/") ? options.workspacePath.slice(0, -1) : dirname(options.workspacePath);
|
|
9316
|
-
const pkgJsonPath = resolve(dir, "package.json");
|
|
9317
|
-
if (existsSync(pkgJsonPath)) {
|
|
9318
|
-
name = JSON.parse(readFileSync(pkgJsonPath, "utf-8")).name;
|
|
9319
|
-
}
|
|
9320
|
-
if (typeof name !== "string" || !name) {
|
|
9321
|
-
name = basename(dir);
|
|
9322
|
-
}
|
|
9323
|
-
} else {
|
|
9324
|
-
name = options.workspacePath.toString();
|
|
9325
|
-
}
|
|
9326
|
-
}
|
|
9327
|
-
const config = {
|
|
9328
|
-
root,
|
|
9329
|
-
resolve: {
|
|
9330
|
-
// by default Vite resolves `module` field, which not always a native ESM module
|
|
9331
|
-
// setting this option can bypass that and fallback to cjs version
|
|
9332
|
-
mainFields: [],
|
|
9333
|
-
alias: testConfig.alias,
|
|
9334
|
-
conditions: ["node"]
|
|
9335
|
-
},
|
|
9336
|
-
esbuild: viteConfig.esbuild === false ? false : {
|
|
9337
|
-
// Lowest target Vitest supports is Node18
|
|
9338
|
-
target: viteConfig.esbuild?.target || "node18",
|
|
9339
|
-
sourcemap: "external",
|
|
9340
|
-
// Enables using ignore hint for coverage providers with @preserve keyword
|
|
9341
|
-
legalComments: "inline"
|
|
9342
|
-
},
|
|
9343
|
-
server: {
|
|
9344
|
-
// disable watch mode in workspaces,
|
|
9345
|
-
// because it is handled by the top-level watcher
|
|
9346
|
-
watch: null,
|
|
9347
|
-
open: false,
|
|
9348
|
-
hmr: false,
|
|
9349
|
-
ws: false,
|
|
9350
|
-
preTransformRequests: false,
|
|
9351
|
-
middlewareMode: true,
|
|
9352
|
-
fs: {
|
|
9353
|
-
allow: resolveFsAllow(
|
|
9354
|
-
project.ctx.config.root,
|
|
9355
|
-
project.ctx.server.config.configFile
|
|
9356
|
-
)
|
|
9357
|
-
}
|
|
9358
|
-
},
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
|
|
9390
|
-
SsrReplacerPlugin(),
|
|
9391
|
-
...CSSEnablerPlugin(project),
|
|
9392
|
-
CoverageTransform(project.ctx),
|
|
9393
|
-
...MocksPlugins(),
|
|
9394
|
-
VitestProjectResolver(project.ctx),
|
|
9395
|
-
VitestOptimizer(),
|
|
9396
|
-
NormalizeURLPlugin()
|
|
9397
|
-
];
|
|
9398
|
-
}
|
|
9399
|
-
|
|
9400
|
-
async function createViteServer(inlineConfig) {
|
|
9401
|
-
const error = console.error;
|
|
9402
|
-
console.error = (...args) => {
|
|
9403
|
-
if (typeof args[0] === "string" && args[0].includes("WebSocket server error:")) {
|
|
9404
|
-
return;
|
|
9405
|
-
}
|
|
9406
|
-
error(...args);
|
|
9407
|
-
};
|
|
9408
|
-
const server = await createServer({
|
|
9409
|
-
logLevel: "error",
|
|
9410
|
-
...inlineConfig
|
|
9411
|
-
});
|
|
9412
|
-
console.error = error;
|
|
9413
|
-
return server;
|
|
9414
|
-
}
|
|
9415
|
-
|
|
9416
|
-
async function loadGlobalSetupFiles(runner, globalSetup) {
|
|
9417
|
-
const globalSetupFiles = toArray$1(globalSetup);
|
|
9418
|
-
return Promise.all(
|
|
9419
|
-
globalSetupFiles.map((file) => loadGlobalSetupFile(file, runner))
|
|
9420
|
-
);
|
|
9421
|
-
}
|
|
9422
|
-
async function loadGlobalSetupFile(file, runner) {
|
|
9423
|
-
const m = await runner.executeFile(file);
|
|
9424
|
-
for (const exp of ["default", "setup", "teardown"]) {
|
|
9425
|
-
if (m[exp] != null && typeof m[exp] !== "function") {
|
|
9426
|
-
throw new Error(
|
|
9427
|
-
`invalid export in globalSetup file ${file}: ${exp} must be a function`
|
|
9428
|
-
);
|
|
9429
|
-
}
|
|
9430
|
-
}
|
|
9431
|
-
if (m.default) {
|
|
9432
|
-
return {
|
|
9433
|
-
file,
|
|
9434
|
-
setup: m.default
|
|
9435
|
-
};
|
|
9436
|
-
} else if (m.setup || m.teardown) {
|
|
9437
|
-
return {
|
|
9438
|
-
file,
|
|
9439
|
-
setup: m.setup,
|
|
9440
|
-
teardown: m.teardown
|
|
9441
|
-
};
|
|
9442
|
-
} else {
|
|
9443
|
-
throw new Error(
|
|
9444
|
-
`invalid globalSetup file ${file}. Must export setup, teardown or have a default export`
|
|
9445
|
-
);
|
|
9446
|
-
}
|
|
9447
|
-
}
|
|
9448
|
-
|
|
9449
|
-
function serializeConfig(config, coreConfig, viteConfig) {
|
|
9450
|
-
const optimizer = config.deps?.optimizer;
|
|
9451
|
-
const poolOptions = config.poolOptions;
|
|
9452
|
-
const isolate = viteConfig?.test?.isolate;
|
|
9453
|
-
return {
|
|
9454
|
-
// TODO: remove functions from environmentOptions
|
|
9455
|
-
environmentOptions: config.environmentOptions,
|
|
9456
|
-
mode: config.mode,
|
|
9457
|
-
isolate: config.isolate,
|
|
9458
|
-
base: config.base,
|
|
9459
|
-
logHeapUsage: config.logHeapUsage,
|
|
9460
|
-
runner: config.runner,
|
|
9461
|
-
bail: config.bail,
|
|
9462
|
-
defines: config.defines,
|
|
9463
|
-
chaiConfig: config.chaiConfig,
|
|
9464
|
-
setupFiles: config.setupFiles,
|
|
9465
|
-
allowOnly: config.allowOnly,
|
|
9466
|
-
testTimeout: config.testTimeout,
|
|
9467
|
-
testNamePattern: config.testNamePattern,
|
|
9468
|
-
hookTimeout: config.hookTimeout,
|
|
9469
|
-
clearMocks: config.clearMocks,
|
|
9470
|
-
mockReset: config.mockReset,
|
|
9471
|
-
restoreMocks: config.restoreMocks,
|
|
9472
|
-
unstubEnvs: config.unstubEnvs,
|
|
9473
|
-
unstubGlobals: config.unstubGlobals,
|
|
9474
|
-
maxConcurrency: config.maxConcurrency,
|
|
9475
|
-
pool: config.pool,
|
|
9476
|
-
expect: config.expect,
|
|
9477
|
-
snapshotSerializers: config.snapshotSerializers,
|
|
9478
|
-
diff: config.diff,
|
|
9479
|
-
retry: config.retry,
|
|
9480
|
-
disableConsoleIntercept: config.disableConsoleIntercept,
|
|
9481
|
-
root: config.root,
|
|
9482
|
-
name: config.name,
|
|
9483
|
-
globals: config.globals,
|
|
9484
|
-
snapshotEnvironment: config.snapshotEnvironment,
|
|
9485
|
-
passWithNoTests: config.passWithNoTests,
|
|
9486
|
-
coverage: ((coverage) => {
|
|
9487
|
-
const htmlReporter = coverage.reporter.find(([reporterName]) => reporterName === "html");
|
|
9488
|
-
const subdir = htmlReporter && htmlReporter[1]?.subdir;
|
|
9489
|
-
return {
|
|
9490
|
-
reportsDirectory: coverage.reportsDirectory,
|
|
9491
|
-
provider: coverage.provider,
|
|
9492
|
-
enabled: coverage.enabled,
|
|
9493
|
-
htmlReporter: htmlReporter ? { subdir } : void 0,
|
|
9494
|
-
customProviderModule: "customProviderModule" in coverage ? coverage.customProviderModule : void 0
|
|
9495
|
-
};
|
|
9496
|
-
})(config.coverage),
|
|
9497
|
-
fakeTimers: config.fakeTimers,
|
|
9498
|
-
poolOptions: {
|
|
9499
|
-
forks: {
|
|
9500
|
-
singleFork: poolOptions?.forks?.singleFork ?? coreConfig.poolOptions?.forks?.singleFork ?? false,
|
|
9501
|
-
isolate: poolOptions?.forks?.isolate ?? isolate ?? coreConfig.poolOptions?.forks?.isolate ?? true
|
|
9502
|
-
},
|
|
9503
|
-
threads: {
|
|
9504
|
-
singleThread: poolOptions?.threads?.singleThread ?? coreConfig.poolOptions?.threads?.singleThread ?? false,
|
|
9505
|
-
isolate: poolOptions?.threads?.isolate ?? isolate ?? coreConfig.poolOptions?.threads?.isolate ?? true
|
|
9506
|
-
},
|
|
9507
|
-
vmThreads: {
|
|
9508
|
-
singleThread: poolOptions?.vmThreads?.singleThread ?? coreConfig.poolOptions?.vmThreads?.singleThread ?? false
|
|
9509
|
-
},
|
|
9510
|
-
vmForks: {
|
|
9511
|
-
singleFork: poolOptions?.vmForks?.singleFork ?? coreConfig.poolOptions?.vmForks?.singleFork ?? false
|
|
9512
|
-
}
|
|
9513
|
-
},
|
|
9514
|
-
deps: {
|
|
9515
|
-
web: config.deps.web || {},
|
|
9516
|
-
optimizer: {
|
|
9517
|
-
web: {
|
|
9518
|
-
enabled: optimizer?.web?.enabled ?? true
|
|
9519
|
-
},
|
|
9520
|
-
ssr: {
|
|
9521
|
-
enabled: optimizer?.ssr?.enabled ?? true
|
|
9661
|
+
if (!name) {
|
|
9662
|
+
if (typeof options.workspacePath === "string") {
|
|
9663
|
+
const dir = options.workspacePath.endsWith("/") ? options.workspacePath.slice(0, -1) : dirname(options.workspacePath);
|
|
9664
|
+
const pkgJsonPath = resolve(dir, "package.json");
|
|
9665
|
+
if (existsSync(pkgJsonPath)) {
|
|
9666
|
+
name = JSON.parse(readFileSync(pkgJsonPath, "utf-8")).name;
|
|
9667
|
+
}
|
|
9668
|
+
if (typeof name !== "string" || !name) {
|
|
9669
|
+
name = basename(dir);
|
|
9670
|
+
}
|
|
9671
|
+
} else {
|
|
9672
|
+
name = options.workspacePath.toString();
|
|
9673
|
+
}
|
|
9674
|
+
}
|
|
9675
|
+
const config = {
|
|
9676
|
+
root,
|
|
9677
|
+
resolve: {
|
|
9678
|
+
// by default Vite resolves `module` field, which not always a native ESM module
|
|
9679
|
+
// setting this option can bypass that and fallback to cjs version
|
|
9680
|
+
mainFields: [],
|
|
9681
|
+
alias: testConfig.alias,
|
|
9682
|
+
conditions: ["node"]
|
|
9683
|
+
},
|
|
9684
|
+
esbuild: viteConfig.esbuild === false ? false : {
|
|
9685
|
+
// Lowest target Vitest supports is Node18
|
|
9686
|
+
target: viteConfig.esbuild?.target || "node18",
|
|
9687
|
+
sourcemap: "external",
|
|
9688
|
+
// Enables using ignore hint for coverage providers with @preserve keyword
|
|
9689
|
+
legalComments: "inline"
|
|
9690
|
+
},
|
|
9691
|
+
server: {
|
|
9692
|
+
// disable watch mode in workspaces,
|
|
9693
|
+
// because it is handled by the top-level watcher
|
|
9694
|
+
watch: null,
|
|
9695
|
+
open: false,
|
|
9696
|
+
hmr: false,
|
|
9697
|
+
ws: false,
|
|
9698
|
+
preTransformRequests: false,
|
|
9699
|
+
middlewareMode: true,
|
|
9700
|
+
fs: {
|
|
9701
|
+
allow: resolveFsAllow(
|
|
9702
|
+
project.ctx.config.root,
|
|
9703
|
+
project.ctx.server.config.configFile
|
|
9704
|
+
)
|
|
9705
|
+
}
|
|
9706
|
+
},
|
|
9707
|
+
// eslint-disable-next-line ts/ban-ts-comment
|
|
9708
|
+
// @ts-ignore Vite 6 compat
|
|
9709
|
+
environments: {
|
|
9710
|
+
ssr: {
|
|
9711
|
+
resolve: {
|
|
9712
|
+
// by default Vite resolves `module` field, which not always a native ESM module
|
|
9713
|
+
// setting this option can bypass that and fallback to cjs version
|
|
9714
|
+
mainFields: [],
|
|
9715
|
+
conditions: ["node"]
|
|
9716
|
+
}
|
|
9717
|
+
}
|
|
9718
|
+
},
|
|
9719
|
+
test: {
|
|
9720
|
+
name
|
|
9721
|
+
}
|
|
9722
|
+
};
|
|
9723
|
+
config.test.defines = defines;
|
|
9724
|
+
const classNameStrategy = typeof testConfig.css !== "boolean" && testConfig.css?.modules?.classNameStrategy || "stable";
|
|
9725
|
+
if (classNameStrategy !== "scoped") {
|
|
9726
|
+
config.css ??= {};
|
|
9727
|
+
config.css.modules ??= {};
|
|
9728
|
+
if (config.css.modules) {
|
|
9729
|
+
config.css.modules.generateScopedName = (name2, filename) => {
|
|
9730
|
+
const root2 = project.config.root;
|
|
9731
|
+
return generateScopedClassName(
|
|
9732
|
+
classNameStrategy,
|
|
9733
|
+
name2,
|
|
9734
|
+
relative(root2, filename)
|
|
9735
|
+
);
|
|
9736
|
+
};
|
|
9737
|
+
}
|
|
9522
9738
|
}
|
|
9739
|
+
config.customLogger = createViteLogger(
|
|
9740
|
+
project.logger,
|
|
9741
|
+
viteConfig.logLevel || "warn",
|
|
9742
|
+
{
|
|
9743
|
+
allowClearScreen: false
|
|
9744
|
+
}
|
|
9745
|
+
);
|
|
9746
|
+
config.customLogger = silenceImportViteIgnoreWarning(config.customLogger);
|
|
9747
|
+
return config;
|
|
9523
9748
|
},
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
},
|
|
9527
|
-
snapshotOptions: {
|
|
9528
|
-
// TODO: store it differently, not on the config
|
|
9529
|
-
snapshotEnvironment: void 0,
|
|
9530
|
-
updateSnapshot: coreConfig.snapshotOptions.updateSnapshot,
|
|
9531
|
-
snapshotFormat: {
|
|
9532
|
-
...coreConfig.snapshotOptions.snapshotFormat,
|
|
9533
|
-
compareKeys: void 0
|
|
9749
|
+
configResolved(viteConfig) {
|
|
9750
|
+
hijackVitePluginInject(viteConfig);
|
|
9534
9751
|
},
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
seed: coreConfig.sequence.seed,
|
|
9541
|
-
hooks: coreConfig.sequence.hooks,
|
|
9542
|
-
setupFiles: coreConfig.sequence.setupFiles
|
|
9543
|
-
},
|
|
9544
|
-
inspect: coreConfig.inspect,
|
|
9545
|
-
inspectBrk: coreConfig.inspectBrk,
|
|
9546
|
-
inspector: coreConfig.inspector,
|
|
9547
|
-
watch: config.watch,
|
|
9548
|
-
includeTaskLocation: config.includeTaskLocation ?? coreConfig.includeTaskLocation,
|
|
9549
|
-
env: {
|
|
9550
|
-
...viteConfig?.env,
|
|
9551
|
-
...config.env
|
|
9752
|
+
async configureServer(server) {
|
|
9753
|
+
const options2 = deepMerge({}, configDefaults, server.config.test || {});
|
|
9754
|
+
await project.setServer(options2, server);
|
|
9755
|
+
await server.watcher.close();
|
|
9756
|
+
}
|
|
9552
9757
|
},
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
screenshotFailures: browser.screenshotFailures,
|
|
9562
|
-
locators: {
|
|
9563
|
-
testIdAttribute: browser.locators.testIdAttribute
|
|
9564
|
-
}
|
|
9565
|
-
};
|
|
9566
|
-
})(config.browser),
|
|
9567
|
-
standalone: config.standalone,
|
|
9568
|
-
printConsoleTrace: config.printConsoleTrace ?? coreConfig.printConsoleTrace,
|
|
9569
|
-
benchmark: config.benchmark && {
|
|
9570
|
-
includeSamples: config.benchmark.includeSamples
|
|
9571
|
-
}
|
|
9572
|
-
};
|
|
9758
|
+
SsrReplacerPlugin(),
|
|
9759
|
+
...CSSEnablerPlugin(project),
|
|
9760
|
+
CoverageTransform(project.ctx),
|
|
9761
|
+
...MocksPlugins(),
|
|
9762
|
+
VitestProjectResolver(project.ctx),
|
|
9763
|
+
VitestOptimizer(),
|
|
9764
|
+
NormalizeURLPlugin()
|
|
9765
|
+
];
|
|
9573
9766
|
}
|
|
9574
9767
|
|
|
9575
9768
|
class TestSpecification {
|
|
@@ -9618,6 +9811,19 @@ class TestSpecification {
|
|
|
9618
9811
|
}
|
|
9619
9812
|
}
|
|
9620
9813
|
|
|
9814
|
+
async function createViteServer(inlineConfig) {
|
|
9815
|
+
const error = console.error;
|
|
9816
|
+
console.error = (...args) => {
|
|
9817
|
+
if (typeof args[0] === "string" && args[0].includes("WebSocket server error:")) {
|
|
9818
|
+
return;
|
|
9819
|
+
}
|
|
9820
|
+
error(...args);
|
|
9821
|
+
};
|
|
9822
|
+
const server = await createServer(inlineConfig);
|
|
9823
|
+
console.error = error;
|
|
9824
|
+
return server;
|
|
9825
|
+
}
|
|
9826
|
+
|
|
9621
9827
|
async function initializeProject(workspacePath, ctx, options) {
|
|
9622
9828
|
const project = new WorkspaceProject(workspacePath, ctx, options);
|
|
9623
9829
|
const root = options.root || (typeof workspacePath === "number" ? void 0 : workspacePath.endsWith("/") ? workspacePath : dirname(workspacePath));
|
|
@@ -9625,7 +9831,6 @@ async function initializeProject(workspacePath, ctx, options) {
|
|
|
9625
9831
|
const config = {
|
|
9626
9832
|
...options,
|
|
9627
9833
|
root,
|
|
9628
|
-
logLevel: "error",
|
|
9629
9834
|
configFile,
|
|
9630
9835
|
// this will make "mode": "test" | "benchmark" inside defineConfig
|
|
9631
9836
|
mode: options.test?.mode || options.mode || ctx.config.mode,
|
|
@@ -9638,8 +9843,8 @@ async function initializeProject(workspacePath, ctx, options) {
|
|
|
9638
9843
|
return project;
|
|
9639
9844
|
}
|
|
9640
9845
|
class WorkspaceProject {
|
|
9641
|
-
constructor(
|
|
9642
|
-
this.path =
|
|
9846
|
+
constructor(path2, ctx, options) {
|
|
9847
|
+
this.path = path2;
|
|
9643
9848
|
this.ctx = ctx;
|
|
9644
9849
|
this.options = options;
|
|
9645
9850
|
}
|
|
@@ -9797,7 +10002,7 @@ class WorkspaceProject {
|
|
|
9797
10002
|
ignore: exclude
|
|
9798
10003
|
};
|
|
9799
10004
|
const files = await fg(include, globOptions);
|
|
9800
|
-
return files.map((file) => resolve(cwd, file));
|
|
10005
|
+
return files.map((file) => slash(a.resolve(cwd, file)));
|
|
9801
10006
|
}
|
|
9802
10007
|
async isTargetFile(id, source) {
|
|
9803
10008
|
const relativeId = relative(this.config.dir || this.config.root, id);
|
|
@@ -9818,7 +10023,7 @@ class WorkspaceProject {
|
|
|
9818
10023
|
}
|
|
9819
10024
|
filterFiles(testFiles, filters, dir) {
|
|
9820
10025
|
if (filters.length && process.platform === "win32") {
|
|
9821
|
-
filters = filters.map((f) =>
|
|
10026
|
+
filters = filters.map((f) => slash(f));
|
|
9822
10027
|
}
|
|
9823
10028
|
if (filters.length) {
|
|
9824
10029
|
return testFiles.filter((t) => {
|
|
@@ -9834,17 +10039,25 @@ class WorkspaceProject {
|
|
|
9834
10039
|
}
|
|
9835
10040
|
return testFiles;
|
|
9836
10041
|
}
|
|
9837
|
-
async initBrowserServer(
|
|
9838
|
-
if (!this.isBrowserEnabled()) {
|
|
10042
|
+
async initBrowserServer() {
|
|
10043
|
+
if (!this.isBrowserEnabled() || this.browser) {
|
|
9839
10044
|
return;
|
|
9840
10045
|
}
|
|
9841
10046
|
await this.ctx.packageInstaller.ensureInstalled("@vitest/browser", this.config.root, this.ctx.version);
|
|
9842
|
-
const { createBrowserServer } = await import('@vitest/browser');
|
|
9843
|
-
await this.browser?.close();
|
|
10047
|
+
const { createBrowserServer, distRoot } = await import('@vitest/browser');
|
|
9844
10048
|
const browser = await createBrowserServer(
|
|
9845
10049
|
this,
|
|
9846
|
-
configFile,
|
|
9847
|
-
[
|
|
10050
|
+
this.server.config.configFile,
|
|
10051
|
+
[
|
|
10052
|
+
...MocksPlugins({
|
|
10053
|
+
filter(id) {
|
|
10054
|
+
if (id.includes(distRoot)) {
|
|
10055
|
+
return false;
|
|
10056
|
+
}
|
|
10057
|
+
return true;
|
|
10058
|
+
}
|
|
10059
|
+
})
|
|
10060
|
+
],
|
|
9848
10061
|
[CoverageTransform(this.ctx)]
|
|
9849
10062
|
);
|
|
9850
10063
|
this.browser = browser;
|
|
@@ -9872,9 +10085,7 @@ class WorkspaceProject {
|
|
|
9872
10085
|
return project;
|
|
9873
10086
|
}
|
|
9874
10087
|
static async createCoreProject(ctx) {
|
|
9875
|
-
|
|
9876
|
-
await project.initBrowserServer(ctx.server.config.configFile);
|
|
9877
|
-
return project;
|
|
10088
|
+
return WorkspaceProject.createBasicProject(ctx);
|
|
9878
10089
|
}
|
|
9879
10090
|
async setServer(options, server) {
|
|
9880
10091
|
this.config = resolveConfig(
|
|
@@ -9893,6 +10104,7 @@ class WorkspaceProject {
|
|
|
9893
10104
|
this.config.provide[providedKey]
|
|
9894
10105
|
);
|
|
9895
10106
|
}
|
|
10107
|
+
this.closingPromise = void 0;
|
|
9896
10108
|
this.testProject = new TestProject(this);
|
|
9897
10109
|
this.server = server;
|
|
9898
10110
|
this.vitenode = new ViteNodeServer(server, this.config.server);
|
|
@@ -9907,7 +10119,6 @@ class WorkspaceProject {
|
|
|
9907
10119
|
return node.resolveId(id, importer);
|
|
9908
10120
|
}
|
|
9909
10121
|
});
|
|
9910
|
-
await this.initBrowserServer(this.server.config.configFile);
|
|
9911
10122
|
}
|
|
9912
10123
|
isBrowserEnabled() {
|
|
9913
10124
|
return isBrowserEnabled(this.config);
|
|
@@ -9930,7 +10141,7 @@ class WorkspaceProject {
|
|
|
9930
10141
|
if (!this.closingPromise) {
|
|
9931
10142
|
this.closingPromise = Promise.all(
|
|
9932
10143
|
[
|
|
9933
|
-
this.server
|
|
10144
|
+
this.server?.close(),
|
|
9934
10145
|
this.typechecker?.stop(),
|
|
9935
10146
|
this.browser?.close(),
|
|
9936
10147
|
this.clearTmpDir()
|
|
@@ -9946,76 +10157,13 @@ class WorkspaceProject {
|
|
|
9946
10157
|
}
|
|
9947
10158
|
}
|
|
9948
10159
|
async initBrowserProvider() {
|
|
9949
|
-
if (!this.isBrowserEnabled()) {
|
|
10160
|
+
if (!this.isBrowserEnabled() || this.browser?.provider) {
|
|
9950
10161
|
return;
|
|
9951
10162
|
}
|
|
9952
|
-
|
|
9953
|
-
|
|
9954
|
-
}
|
|
9955
|
-
|
|
9956
|
-
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
9957
|
-
class VitestPackageInstaller {
|
|
9958
|
-
async ensureInstalled(dependency, root, version) {
|
|
9959
|
-
if (process.env.VITEST_SKIP_INSTALL_CHECKS) {
|
|
9960
|
-
return true;
|
|
9961
|
-
}
|
|
9962
|
-
if (process.versions.pnp) {
|
|
9963
|
-
const targetRequire = createRequire(__dirname);
|
|
9964
|
-
try {
|
|
9965
|
-
targetRequire.resolve(dependency, { paths: [root, __dirname] });
|
|
9966
|
-
return true;
|
|
9967
|
-
} catch {
|
|
9968
|
-
}
|
|
9969
|
-
}
|
|
9970
|
-
if (/* @__PURE__ */ isPackageExists(dependency, { paths: [root, __dirname] })) {
|
|
9971
|
-
return true;
|
|
9972
|
-
}
|
|
9973
|
-
const promptInstall = !isCI && process.stdout.isTTY;
|
|
9974
|
-
process.stderr.write(
|
|
9975
|
-
c.red(
|
|
9976
|
-
`${c.inverse(
|
|
9977
|
-
c.red(" MISSING DEPENDENCY ")
|
|
9978
|
-
)} Cannot find dependency '${dependency}'
|
|
9979
|
-
|
|
9980
|
-
`
|
|
9981
|
-
)
|
|
9982
|
-
);
|
|
9983
|
-
if (!promptInstall) {
|
|
9984
|
-
return false;
|
|
9985
|
-
}
|
|
9986
|
-
const prompts = await import('./index.X0nbfr6-.js').then(function (n) { return n.i; });
|
|
9987
|
-
const { install } = await prompts.prompt({
|
|
9988
|
-
type: "confirm",
|
|
9989
|
-
name: "install",
|
|
9990
|
-
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
9991
|
-
});
|
|
9992
|
-
if (install) {
|
|
9993
|
-
const packageName = version ? `${dependency}@${version}` : dependency;
|
|
9994
|
-
await (await import('./index.CPD77dLA.js')).installPackage(packageName, { dev: true });
|
|
9995
|
-
process.stderr.write(
|
|
9996
|
-
c.yellow(
|
|
9997
|
-
`
|
|
9998
|
-
Package ${packageName} installed, re-run the command to start.
|
|
9999
|
-
`
|
|
10000
|
-
)
|
|
10001
|
-
);
|
|
10002
|
-
process.exit();
|
|
10003
|
-
return true;
|
|
10163
|
+
if (!this.browser) {
|
|
10164
|
+
await this.initBrowserServer();
|
|
10004
10165
|
}
|
|
10005
|
-
|
|
10006
|
-
}
|
|
10007
|
-
}
|
|
10008
|
-
|
|
10009
|
-
class FilesNotFoundError extends Error {
|
|
10010
|
-
code = "VITEST_FILES_NOT_FOUND";
|
|
10011
|
-
constructor(mode) {
|
|
10012
|
-
super(`No ${mode} files found`);
|
|
10013
|
-
}
|
|
10014
|
-
}
|
|
10015
|
-
class GitNotFoundError extends Error {
|
|
10016
|
-
code = "VITEST_GIT_NOT_FOUND";
|
|
10017
|
-
constructor() {
|
|
10018
|
-
super("Could not find Git root. Have you initialized git with `git init`?");
|
|
10166
|
+
await this.browser?.initBrowserProvider();
|
|
10019
10167
|
}
|
|
10020
10168
|
}
|
|
10021
10169
|
|
|
@@ -10085,48 +10233,33 @@ async function resolveWorkspace(vitest, cliOptions, workspaceConfigPath, workspa
|
|
|
10085
10233
|
}
|
|
10086
10234
|
return acc;
|
|
10087
10235
|
}, {});
|
|
10088
|
-
const
|
|
10089
|
-
const projects = [];
|
|
10236
|
+
const projectPromises = [];
|
|
10090
10237
|
const fileProjects = [...configFiles, ...nonConfigDirectories];
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
continue;
|
|
10097
|
-
}
|
|
10098
|
-
const directory = filepath.endsWith("/") ? filepath.slice(0, -1) : dirname(filepath);
|
|
10099
|
-
if (isMainThread) {
|
|
10100
|
-
process.chdir(directory);
|
|
10101
|
-
}
|
|
10102
|
-
projects.push(
|
|
10103
|
-
await initializeProject(
|
|
10104
|
-
filepath,
|
|
10105
|
-
vitest,
|
|
10106
|
-
{ workspaceConfigPath, test: cliOverrides }
|
|
10107
|
-
)
|
|
10108
|
-
);
|
|
10109
|
-
}
|
|
10110
|
-
} finally {
|
|
10111
|
-
if (isMainThread) {
|
|
10112
|
-
process.chdir(cwd);
|
|
10238
|
+
const concurrent = limitConcurrency(nodeos__default.availableParallelism?.() || nodeos__default.cpus().length || 5);
|
|
10239
|
+
for (const filepath of fileProjects) {
|
|
10240
|
+
if (vitest.server.config.configFile === filepath) {
|
|
10241
|
+
projectPromises.push(concurrent(() => vitest._createCoreProject()));
|
|
10242
|
+
continue;
|
|
10113
10243
|
}
|
|
10244
|
+
projectPromises.push(
|
|
10245
|
+
concurrent(() => initializeProject(
|
|
10246
|
+
filepath,
|
|
10247
|
+
vitest,
|
|
10248
|
+
{ workspaceConfigPath, test: cliOverrides }
|
|
10249
|
+
))
|
|
10250
|
+
);
|
|
10114
10251
|
}
|
|
10115
|
-
const projectPromises = [];
|
|
10116
10252
|
projectConfigs.forEach((options, index) => {
|
|
10117
|
-
projectPromises.push(initializeProject(
|
|
10253
|
+
projectPromises.push(concurrent(() => initializeProject(
|
|
10118
10254
|
index,
|
|
10119
10255
|
vitest,
|
|
10120
10256
|
mergeConfig(options, { workspaceConfigPath, test: cliOverrides })
|
|
10121
|
-
));
|
|
10257
|
+
)));
|
|
10122
10258
|
});
|
|
10123
|
-
if (!
|
|
10259
|
+
if (!projectPromises.length) {
|
|
10124
10260
|
return [await vitest._createCoreProject()];
|
|
10125
10261
|
}
|
|
10126
|
-
const resolvedProjects = await Promise.all(
|
|
10127
|
-
...projects,
|
|
10128
|
-
...projectPromises
|
|
10129
|
-
]);
|
|
10262
|
+
const resolvedProjects = await Promise.all(projectPromises);
|
|
10130
10263
|
const names = /* @__PURE__ */ new Set();
|
|
10131
10264
|
for (const project of resolvedProjects) {
|
|
10132
10265
|
const name = project.getName();
|
|
@@ -10270,12 +10403,16 @@ class Vitest {
|
|
|
10270
10403
|
runner = void 0;
|
|
10271
10404
|
packageInstaller;
|
|
10272
10405
|
coreWorkspaceProject;
|
|
10406
|
+
/** @private */
|
|
10273
10407
|
resolvedProjects = [];
|
|
10274
10408
|
projects = [];
|
|
10275
10409
|
distPath = distDir;
|
|
10276
10410
|
_cachedSpecs = /* @__PURE__ */ new Map();
|
|
10411
|
+
_workspaceConfigPath;
|
|
10277
10412
|
/** @deprecated use `_cachedSpecs` */
|
|
10278
10413
|
projectTestFiles = this._cachedSpecs;
|
|
10414
|
+
/** @private */
|
|
10415
|
+
_browserLastPort = defaultBrowserPort;
|
|
10279
10416
|
_onRestartListeners = [];
|
|
10280
10417
|
_onClose = [];
|
|
10281
10418
|
_onSetServer = [];
|
|
@@ -10284,8 +10421,13 @@ class Vitest {
|
|
|
10284
10421
|
this.unregisterWatcher?.();
|
|
10285
10422
|
clearTimeout(this._rerunTimer);
|
|
10286
10423
|
this.restartsCount += 1;
|
|
10424
|
+
this._browserLastPort = defaultBrowserPort;
|
|
10287
10425
|
this.pool?.close?.();
|
|
10288
10426
|
this.pool = void 0;
|
|
10427
|
+
this.closingPromise = void 0;
|
|
10428
|
+
this.projects = [];
|
|
10429
|
+
this.resolvedProjects = [];
|
|
10430
|
+
this._workspaceConfigPath = void 0;
|
|
10289
10431
|
this.coverageProvider = void 0;
|
|
10290
10432
|
this.runningPromise = void 0;
|
|
10291
10433
|
this._cachedSpecs.clear();
|
|
@@ -10314,18 +10456,18 @@ class Vitest {
|
|
|
10314
10456
|
const serverRestart = server.restart;
|
|
10315
10457
|
server.restart = async (...args) => {
|
|
10316
10458
|
await Promise.all(this._onRestartListeners.map((fn) => fn()));
|
|
10459
|
+
this.report("onServerRestart");
|
|
10460
|
+
await this.close();
|
|
10317
10461
|
await serverRestart(...args);
|
|
10318
|
-
this.unregisterWatcher();
|
|
10319
|
-
this.registerWatcher();
|
|
10320
10462
|
};
|
|
10321
10463
|
server.watcher.on("change", async (file) => {
|
|
10322
10464
|
file = normalize(file);
|
|
10323
|
-
const isConfig = file === server.config.configFile;
|
|
10465
|
+
const isConfig = file === server.config.configFile || this.resolvedProjects.some((p) => p.server.config.configFile === file) || file === this._workspaceConfigPath;
|
|
10324
10466
|
if (isConfig) {
|
|
10325
10467
|
await Promise.all(this._onRestartListeners.map((fn) => fn("config")));
|
|
10468
|
+
this.report("onServerRestart", "config");
|
|
10469
|
+
await this.close();
|
|
10326
10470
|
await serverRestart();
|
|
10327
|
-
this.unregisterWatcher();
|
|
10328
|
-
this.registerWatcher();
|
|
10329
10471
|
}
|
|
10330
10472
|
});
|
|
10331
10473
|
}
|
|
@@ -10335,7 +10477,6 @@ class Vitest {
|
|
|
10335
10477
|
await this.cache.results.readFromCache();
|
|
10336
10478
|
} catch {
|
|
10337
10479
|
}
|
|
10338
|
-
await Promise.all(this._onSetServer.map((fn) => fn()));
|
|
10339
10480
|
const projects = await this.resolveWorkspace(cliOptions);
|
|
10340
10481
|
this.resolvedProjects = projects;
|
|
10341
10482
|
this.projects = projects;
|
|
@@ -10351,6 +10492,7 @@ class Vitest {
|
|
|
10351
10492
|
if (this.config.testNamePattern) {
|
|
10352
10493
|
this.configOverride.testNamePattern = this.config.testNamePattern;
|
|
10353
10494
|
}
|
|
10495
|
+
await Promise.all(this._onSetServer.map((fn) => fn()));
|
|
10354
10496
|
}
|
|
10355
10497
|
provide(key, value) {
|
|
10356
10498
|
this.getCoreWorkspaceProject().provide(key, value);
|
|
@@ -10392,12 +10534,13 @@ class Vitest {
|
|
|
10392
10534
|
return rootFiles.includes(configFile);
|
|
10393
10535
|
});
|
|
10394
10536
|
if (!workspaceConfigName) {
|
|
10395
|
-
return
|
|
10537
|
+
return void 0;
|
|
10396
10538
|
}
|
|
10397
10539
|
return join(configDir, workspaceConfigName);
|
|
10398
10540
|
}
|
|
10399
10541
|
async resolveWorkspace(cliOptions) {
|
|
10400
10542
|
const workspaceConfigPath = await this.getWorkspaceConfigPath();
|
|
10543
|
+
this._workspaceConfigPath = workspaceConfigPath;
|
|
10401
10544
|
if (!workspaceConfigPath) {
|
|
10402
10545
|
return [await this._createCoreProject()];
|
|
10403
10546
|
}
|
|
@@ -10426,9 +10569,6 @@ class Vitest {
|
|
|
10426
10569
|
}
|
|
10427
10570
|
return this.coverageProvider;
|
|
10428
10571
|
}
|
|
10429
|
-
async initBrowserProviders() {
|
|
10430
|
-
return Promise.all(this.projects.map((w) => w.initBrowserProvider()));
|
|
10431
|
-
}
|
|
10432
10572
|
async mergeReports() {
|
|
10433
10573
|
if (this.reporters.some((r) => r instanceof BlobReporter)) {
|
|
10434
10574
|
throw new Error("Cannot merge reports when `--reporter=blob` is used. Remove blob reporter from the config first.");
|
|
@@ -10471,13 +10611,13 @@ class Vitest {
|
|
|
10471
10611
|
if (hasFailed(files)) {
|
|
10472
10612
|
process.exitCode = 1;
|
|
10473
10613
|
}
|
|
10614
|
+
this.checkUnhandledErrors(errors);
|
|
10474
10615
|
await this.report("onFinished", files, errors);
|
|
10475
10616
|
await this.initCoverageProvider();
|
|
10476
10617
|
await this.coverageProvider?.mergeReports?.(coverages);
|
|
10477
10618
|
}
|
|
10478
10619
|
async collect(filters) {
|
|
10479
10620
|
this._onClose = [];
|
|
10480
|
-
await this.initBrowserProviders();
|
|
10481
10621
|
const files = await this.filterTestsBySource(
|
|
10482
10622
|
await this.globTestFiles(filters)
|
|
10483
10623
|
);
|
|
@@ -10501,7 +10641,6 @@ class Vitest {
|
|
|
10501
10641
|
try {
|
|
10502
10642
|
await this.initCoverageProvider();
|
|
10503
10643
|
await this.coverageProvider?.clean(this.config.coverage.clean);
|
|
10504
|
-
await this.initBrowserProviders();
|
|
10505
10644
|
} finally {
|
|
10506
10645
|
await this.report("onInit", this);
|
|
10507
10646
|
}
|
|
@@ -10531,7 +10670,6 @@ class Vitest {
|
|
|
10531
10670
|
try {
|
|
10532
10671
|
await this.initCoverageProvider();
|
|
10533
10672
|
await this.coverageProvider?.clean(this.config.coverage.clean);
|
|
10534
|
-
await this.initBrowserProviders();
|
|
10535
10673
|
} finally {
|
|
10536
10674
|
await this.report("onInit", this);
|
|
10537
10675
|
}
|
|
@@ -10669,8 +10807,10 @@ class Vitest {
|
|
|
10669
10807
|
await this.cache.results.writeToCache();
|
|
10670
10808
|
})().finally(async () => {
|
|
10671
10809
|
const files = Array.from(new Set(specs.map((spec) => spec.moduleId)));
|
|
10810
|
+
const errors = this.state.getUnhandledErrors();
|
|
10672
10811
|
const coverage = await this.coverageProvider?.generateCoverage({ allTestsRun });
|
|
10673
|
-
|
|
10812
|
+
this.checkUnhandledErrors(errors);
|
|
10813
|
+
await this.report("onFinished", this.state.getFiles(files), errors, coverage);
|
|
10674
10814
|
await this.reportCoverage(coverage, allTestsRun);
|
|
10675
10815
|
this.runningPromise = void 0;
|
|
10676
10816
|
this.isFirstRun = false;
|
|
@@ -10714,13 +10854,16 @@ class Vitest {
|
|
|
10714
10854
|
this.isCancelling = true;
|
|
10715
10855
|
await Promise.all(this._onCancelListeners.splice(0).map((listener) => listener(reason)));
|
|
10716
10856
|
}
|
|
10717
|
-
async
|
|
10857
|
+
async initBrowserServers() {
|
|
10858
|
+
await Promise.all(this.projects.map((p) => p.initBrowserServer()));
|
|
10859
|
+
}
|
|
10860
|
+
async rerunFiles(files = this.state.getFilepaths(), trigger, allTestsRun = true) {
|
|
10718
10861
|
if (this.filenamePattern) {
|
|
10719
10862
|
const filteredFiles = await this.globTestFiles([this.filenamePattern]);
|
|
10720
10863
|
files = files.filter((file) => filteredFiles.some((f) => f[1] === file));
|
|
10721
10864
|
}
|
|
10722
10865
|
await this.report("onWatcherRerun", files, trigger);
|
|
10723
|
-
await this.runFiles(files.flatMap((file) => this.getProjectsByTestFile(file)),
|
|
10866
|
+
await this.runFiles(files.flatMap((file) => this.getProjectsByTestFile(file)), allTestsRun);
|
|
10724
10867
|
await this.report("onWatcherStart", this.state.getFiles(files));
|
|
10725
10868
|
}
|
|
10726
10869
|
async changeProjectName(pattern) {
|
|
@@ -10731,7 +10874,7 @@ class Vitest {
|
|
|
10731
10874
|
}
|
|
10732
10875
|
this.projects = this.resolvedProjects.filter((p) => p.getName() === pattern);
|
|
10733
10876
|
const files = (await this.globTestSpecs()).map((spec) => spec.moduleId);
|
|
10734
|
-
await this.rerunFiles(files, "change project filter");
|
|
10877
|
+
await this.rerunFiles(files, "change project filter", pattern === "");
|
|
10735
10878
|
}
|
|
10736
10879
|
async changeNamePattern(pattern, files = this.state.getFilepaths(), trigger) {
|
|
10737
10880
|
if (pattern === "") {
|
|
@@ -10748,15 +10891,15 @@ class Vitest {
|
|
|
10748
10891
|
});
|
|
10749
10892
|
});
|
|
10750
10893
|
}
|
|
10751
|
-
await this.rerunFiles(files, trigger);
|
|
10894
|
+
await this.rerunFiles(files, trigger, pattern === "");
|
|
10752
10895
|
}
|
|
10753
10896
|
async changeFilenamePattern(pattern, files = this.state.getFilepaths()) {
|
|
10754
10897
|
this.filenamePattern = pattern;
|
|
10755
10898
|
const trigger = this.filenamePattern ? "change filename pattern" : "reset filename pattern";
|
|
10756
|
-
await this.rerunFiles(files, trigger);
|
|
10899
|
+
await this.rerunFiles(files, trigger, pattern === "");
|
|
10757
10900
|
}
|
|
10758
10901
|
async rerunFailed() {
|
|
10759
|
-
await this.rerunFiles(this.state.getFailedFilepaths(), "rerun failed");
|
|
10902
|
+
await this.rerunFiles(this.state.getFailedFilepaths(), "rerun failed", false);
|
|
10760
10903
|
}
|
|
10761
10904
|
async updateSnapshot(files) {
|
|
10762
10905
|
files = files || [
|
|
@@ -10769,7 +10912,7 @@ class Vitest {
|
|
|
10769
10912
|
snapshotEnvironment: null
|
|
10770
10913
|
};
|
|
10771
10914
|
try {
|
|
10772
|
-
await this.rerunFiles(files, "update snapshot");
|
|
10915
|
+
await this.rerunFiles(files, "update snapshot", false);
|
|
10773
10916
|
} finally {
|
|
10774
10917
|
delete this.configOverride.snapshotOptions;
|
|
10775
10918
|
}
|
|
@@ -10881,6 +11024,11 @@ class Vitest {
|
|
|
10881
11024
|
}
|
|
10882
11025
|
}
|
|
10883
11026
|
};
|
|
11027
|
+
checkUnhandledErrors(errors) {
|
|
11028
|
+
if (errors.length && !this.config.dangerouslyIgnoreUnhandledErrors) {
|
|
11029
|
+
process.exitCode = 1;
|
|
11030
|
+
}
|
|
11031
|
+
}
|
|
10884
11032
|
unregisterWatcher = noop;
|
|
10885
11033
|
registerWatcher() {
|
|
10886
11034
|
const watcher = this.server.watcher;
|
|
@@ -11147,6 +11295,18 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
11147
11295
|
// https://github.com/vitejs/vite/pull/16453
|
|
11148
11296
|
emptyOutDir: false
|
|
11149
11297
|
},
|
|
11298
|
+
// eslint-disable-next-line ts/ban-ts-comment
|
|
11299
|
+
// @ts-ignore Vite 6 compat
|
|
11300
|
+
environments: {
|
|
11301
|
+
ssr: {
|
|
11302
|
+
resolve: {
|
|
11303
|
+
// by default Vite resolves `module` field, which not always a native ESM module
|
|
11304
|
+
// setting this option can bypass that and fallback to cjs version
|
|
11305
|
+
mainFields: [],
|
|
11306
|
+
conditions: ["node"]
|
|
11307
|
+
}
|
|
11308
|
+
}
|
|
11309
|
+
},
|
|
11150
11310
|
test: {
|
|
11151
11311
|
poolOptions: {
|
|
11152
11312
|
threads: {
|
|
@@ -11158,6 +11318,14 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
11158
11318
|
}
|
|
11159
11319
|
}
|
|
11160
11320
|
};
|
|
11321
|
+
config.customLogger = createViteLogger(
|
|
11322
|
+
ctx.logger,
|
|
11323
|
+
viteConfig.logLevel || "warn",
|
|
11324
|
+
{
|
|
11325
|
+
allowClearScreen: false
|
|
11326
|
+
}
|
|
11327
|
+
);
|
|
11328
|
+
config.customLogger = silenceImportViteIgnoreWarning(config.customLogger);
|
|
11161
11329
|
if (userConfig.coverage?.enabled && !userConfig.coverage.exclude && userConfig.include && config.test) {
|
|
11162
11330
|
config.test.coverage = {
|
|
11163
11331
|
exclude: [...coverageConfigDefaults.exclude, ...userConfig.include]
|
|
@@ -11250,14 +11418,21 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
11250
11418
|
NormalizeURLPlugin()
|
|
11251
11419
|
].filter(notNullish);
|
|
11252
11420
|
}
|
|
11421
|
+
function removeUndefinedValues(obj) {
|
|
11422
|
+
for (const key in Object.keys(obj)) {
|
|
11423
|
+
if (obj[key] === void 0) {
|
|
11424
|
+
delete obj[key];
|
|
11425
|
+
}
|
|
11426
|
+
}
|
|
11427
|
+
return obj;
|
|
11428
|
+
}
|
|
11253
11429
|
|
|
11254
11430
|
async function createVitest(mode, options, viteOverrides = {}, vitestOptions = {}) {
|
|
11255
11431
|
const ctx = new Vitest(mode, vitestOptions);
|
|
11256
|
-
const root = resolve(options.root || process.cwd());
|
|
11257
|
-
const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
11432
|
+
const root = slash(resolve$1(options.root || process.cwd()));
|
|
11433
|
+
const configPath = options.config === false ? false : options.config ? resolve$1(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
11258
11434
|
options.config = configPath;
|
|
11259
11435
|
const config = {
|
|
11260
|
-
logLevel: "error",
|
|
11261
11436
|
configFile: configPath,
|
|
11262
11437
|
// this will make "mode": "test" | "benchmark" inside defineConfig
|
|
11263
11438
|
mode: options.mode || mode,
|
|
@@ -11322,9 +11497,9 @@ class WatchFilter {
|
|
|
11322
11497
|
break;
|
|
11323
11498
|
case (key?.ctrl && key?.name === "c"):
|
|
11324
11499
|
case key?.name === "escape":
|
|
11325
|
-
this.
|
|
11500
|
+
this.write(`${ESC}1G${ESC}0J`);
|
|
11326
11501
|
onSubmit(void 0);
|
|
11327
|
-
|
|
11502
|
+
return;
|
|
11328
11503
|
case key?.name === "enter":
|
|
11329
11504
|
case key?.name === "return":
|
|
11330
11505
|
onSubmit(
|
|
@@ -11428,9 +11603,6 @@ ${resultBody}`;
|
|
|
11428
11603
|
const cursortPos = this.keywordOffset() + (this.currentKeyword?.length || 0);
|
|
11429
11604
|
this.write(`${ESC}${cursortPos}G`);
|
|
11430
11605
|
}
|
|
11431
|
-
cancel() {
|
|
11432
|
-
this.write(`${ESC}J`);
|
|
11433
|
-
}
|
|
11434
11606
|
write(data) {
|
|
11435
11607
|
this.stdout.write(data);
|
|
11436
11608
|
}
|
|
@@ -11447,6 +11619,7 @@ const keys = [
|
|
|
11447
11619
|
["p", "filter by a filename"],
|
|
11448
11620
|
["t", "filter by a test name regex pattern"],
|
|
11449
11621
|
["w", "filter by a project name"],
|
|
11622
|
+
["b", "start the browser server if not started yet"],
|
|
11450
11623
|
["q", "quit"]
|
|
11451
11624
|
];
|
|
11452
11625
|
const cancelKeys = ["space", "c", "h", ...keys.map((key) => key[0]).flat()];
|
|
@@ -11515,6 +11688,14 @@ function registerConsoleShortcuts(ctx, stdin = process.stdin, stdout2) {
|
|
|
11515
11688
|
if (name === "p") {
|
|
11516
11689
|
return inputFilePattern();
|
|
11517
11690
|
}
|
|
11691
|
+
if (name === "b") {
|
|
11692
|
+
await ctx.initBrowserServers();
|
|
11693
|
+
ctx.projects.forEach((project) => {
|
|
11694
|
+
ctx.logger.log();
|
|
11695
|
+
ctx.logger.printBrowserBanner(project);
|
|
11696
|
+
});
|
|
11697
|
+
return null;
|
|
11698
|
+
}
|
|
11518
11699
|
}
|
|
11519
11700
|
async function keypressHandler(str, key) {
|
|
11520
11701
|
await _keypressHandler(str, key);
|
|
@@ -11537,6 +11718,9 @@ function registerConsoleShortcuts(ctx, stdin = process.stdin, stdout2) {
|
|
|
11537
11718
|
}
|
|
11538
11719
|
});
|
|
11539
11720
|
on();
|
|
11721
|
+
if (typeof filter === "undefined") {
|
|
11722
|
+
return;
|
|
11723
|
+
}
|
|
11540
11724
|
const files = ctx.state.getFilepaths();
|
|
11541
11725
|
const cliFiles = ctx.config.standalone && !files.length ? await ctx.getTestFilepaths() : void 0;
|
|
11542
11726
|
await ctx.changeNamePattern(
|
|
@@ -11570,6 +11754,9 @@ function registerConsoleShortcuts(ctx, stdin = process.stdin, stdout2) {
|
|
|
11570
11754
|
return files.map((file) => relative(ctx.config.root, file[1]));
|
|
11571
11755
|
});
|
|
11572
11756
|
on();
|
|
11757
|
+
if (typeof filter === "undefined") {
|
|
11758
|
+
return;
|
|
11759
|
+
}
|
|
11573
11760
|
latestFilename = filter?.trim() || "";
|
|
11574
11761
|
const lastResults = watchFilter.getLastResults();
|
|
11575
11762
|
await ctx.changeFilenamePattern(
|
|
@@ -11625,9 +11812,6 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, v
|
|
|
11625
11812
|
if (stdin.isTTY && ctx.config.watch) {
|
|
11626
11813
|
stdinCleanup = registerConsoleShortcuts(ctx, stdin, stdout);
|
|
11627
11814
|
}
|
|
11628
|
-
ctx.onServerRestart((reason) => {
|
|
11629
|
-
ctx.report("onServerRestart", reason);
|
|
11630
|
-
});
|
|
11631
11815
|
ctx.onAfterSetServer(() => {
|
|
11632
11816
|
if (ctx.config.standalone) {
|
|
11633
11817
|
ctx.init();
|
|
@@ -11816,4 +12000,4 @@ var cliApi = /*#__PURE__*/Object.freeze({
|
|
|
11816
12000
|
startVitest: startVitest
|
|
11817
12001
|
});
|
|
11818
12002
|
|
|
11819
|
-
export { FilesNotFoundError as F, GitNotFoundError as G, TestSpecification as T,
|
|
12003
|
+
export { FilesNotFoundError as F, GitNotFoundError as G, TestSpecification as T, VitestPackageInstaller as V, VitestPlugin as a, registerConsoleShortcuts as b, createVitest as c, createViteLogger as d, cliApi as e, resolveFsAllow as r, startVitest as s };
|