vitest 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -209
- package/dist/browser.d.ts +21 -21
- 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.C3xNdjV6.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.DrfPaMvZ.js} +11 -10
- package/dist/chunks/{cli-api.btGgw3PC.js → cli-api.CKrRYkw8.js} +732 -577
- 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.Bp645TTJ.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.Dz2opmmU.js → index.Bn81VaWg.js} +3808 -3787
- package/dist/chunks/{index.CPD77dLA.js → index.CqYx2Nsr.js} +7 -7
- package/dist/chunks/{index.4GFF2h22.js → index.D3d79vc8.js} +6 -6
- package/dist/chunks/index.Dqe5k2Rk.js +54 -0
- package/dist/chunks/{node.Bx4JZjMG.js → node.AKq966Jp.js} +1 -5
- package/dist/chunks/{reporters.C4ZHgdxQ.d.ts → reporters.anwo7Y6a.d.ts} +1328 -1313
- package/dist/chunks/{resolveConfig.Dha6ilPI.js → resolveConfig.DPmbhVlP.js} +3193 -3175
- 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.Dm-659zB.js} +21 -25
- package/dist/chunks/{setup-common.BKyF15v_.js → setup-common.DDmVKp6O.js} +3 -3
- package/dist/chunks/{suite.BMWOKiTe.d.ts → suite.B2jumIFP.d.ts} +2 -2
- package/dist/chunks/{utils.CY6Spixo.js → utils.BB4zjzR8.js} +2 -2
- package/dist/chunks/utils.C8RiOc4B.js +77 -0
- package/dist/chunks/{vi.BskyZC5g.js → vi.JMQoNY_Z.js} +94 -141
- package/dist/chunks/{vite.YH7MrecS.d.ts → vite.BdBj-UWY.d.ts} +1 -1
- package/dist/chunks/{vm.DB_hLchi.js → vm.jpyrB0xy.js} +5 -8
- package/dist/chunks/{worker.B6RjTtbk.d.ts → worker.BAlI9hII.d.ts} +12 -3
- package/dist/chunks/{worker.CcJLfX8w.d.ts → worker.DHnGaO2M.d.ts} +1 -1
- package/dist/cli.js +3 -4
- package/dist/config.cjs +4 -4
- package/dist/config.d.ts +10 -10
- package/dist/config.js +4 -4
- package/dist/coverage.d.ts +9 -9
- package/dist/coverage.js +8 -11
- package/dist/environments.d.ts +2 -2
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +53 -53
- package/dist/execute.js +7 -6
- package/dist/index.d.ts +75 -1099
- package/dist/index.js +7 -18
- package/dist/node.d.ts +43 -41
- package/dist/node.js +22 -28
- 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 +5 -6
- 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 +13 -13
- package/dist/workers.js +14 -18
- package/package.json +26 -26
- 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
- package/dist/chunks/{index.lVXYBqEP.js → index.BMoXz_-n.js} +186 -186
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { existsSync, promises, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { createFileTask, 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.DPmbhVlP.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.DrfPaMvZ.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.Bn81VaWg.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,23 @@ 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 { 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';
|
|
42
|
+
import MagicString from 'magic-string';
|
|
44
43
|
import { isMainThread } from 'node:worker_threads';
|
|
45
|
-
import { a as removeUndefinedValues } from './index.CxRxs566.js';
|
|
46
44
|
import readline from 'node:readline';
|
|
47
45
|
import { stripVTControlCharacters } from 'node:util';
|
|
48
46
|
|
|
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
47
|
var bufferUtil = {exports: {}};
|
|
121
48
|
|
|
122
49
|
var constants$1;
|
|
@@ -4883,6 +4810,77 @@ function requireWebsocketServer () {
|
|
|
4883
4810
|
var websocketServerExports = requireWebsocketServer();
|
|
4884
4811
|
var WebSocketServer = /*@__PURE__*/getDefaultExportFromCjs(websocketServerExports);
|
|
4885
4812
|
|
|
4813
|
+
async function getModuleGraph(ctx, projectName, id, browser = false) {
|
|
4814
|
+
const graph = {};
|
|
4815
|
+
const externalized = /* @__PURE__ */ new Set();
|
|
4816
|
+
const inlined = /* @__PURE__ */ new Set();
|
|
4817
|
+
const project = ctx.getProjectByName(projectName);
|
|
4818
|
+
async function get(mod, seen = /* @__PURE__ */ new Map()) {
|
|
4819
|
+
if (!mod || !mod.id) {
|
|
4820
|
+
return;
|
|
4821
|
+
}
|
|
4822
|
+
if (mod.id === "\0@vitest/browser/context") {
|
|
4823
|
+
return;
|
|
4824
|
+
}
|
|
4825
|
+
if (seen.has(mod)) {
|
|
4826
|
+
return seen.get(mod);
|
|
4827
|
+
}
|
|
4828
|
+
let id2 = clearId(mod.id);
|
|
4829
|
+
seen.set(mod, id2);
|
|
4830
|
+
const rewrote = browser ? mod.file?.includes(project.browser.vite.config.cacheDir) ? mod.id : false : await project.vitenode.shouldExternalize(id2);
|
|
4831
|
+
if (rewrote) {
|
|
4832
|
+
id2 = rewrote;
|
|
4833
|
+
externalized.add(id2);
|
|
4834
|
+
seen.set(mod, id2);
|
|
4835
|
+
} else {
|
|
4836
|
+
inlined.add(id2);
|
|
4837
|
+
}
|
|
4838
|
+
const mods = Array.from(mod.importedModules).filter(
|
|
4839
|
+
(i) => i.id && !i.id.includes("/vitest/dist/")
|
|
4840
|
+
);
|
|
4841
|
+
graph[id2] = (await Promise.all(mods.map((m) => get(m, seen)))).filter(
|
|
4842
|
+
Boolean
|
|
4843
|
+
);
|
|
4844
|
+
return id2;
|
|
4845
|
+
}
|
|
4846
|
+
if (browser && project.browser) {
|
|
4847
|
+
await get(project.browser.vite.moduleGraph.getModuleById(id));
|
|
4848
|
+
} else {
|
|
4849
|
+
await get(project.server.moduleGraph.getModuleById(id));
|
|
4850
|
+
}
|
|
4851
|
+
return {
|
|
4852
|
+
graph,
|
|
4853
|
+
externalized: Array.from(externalized),
|
|
4854
|
+
inlined: Array.from(inlined)
|
|
4855
|
+
};
|
|
4856
|
+
}
|
|
4857
|
+
function clearId(id) {
|
|
4858
|
+
return id?.replace(/\?v=\w+$/, "") || "";
|
|
4859
|
+
}
|
|
4860
|
+
|
|
4861
|
+
function cloneByOwnProperties(value) {
|
|
4862
|
+
return Object.getOwnPropertyNames(value).reduce(
|
|
4863
|
+
(clone, prop) => ({
|
|
4864
|
+
...clone,
|
|
4865
|
+
[prop]: value[prop]
|
|
4866
|
+
}),
|
|
4867
|
+
{}
|
|
4868
|
+
);
|
|
4869
|
+
}
|
|
4870
|
+
function stringifyReplace(key, value) {
|
|
4871
|
+
if (value instanceof Error) {
|
|
4872
|
+
const cloned = cloneByOwnProperties(value);
|
|
4873
|
+
return {
|
|
4874
|
+
name: value.name,
|
|
4875
|
+
message: value.message,
|
|
4876
|
+
stack: value.stack,
|
|
4877
|
+
...cloned
|
|
4878
|
+
};
|
|
4879
|
+
} else {
|
|
4880
|
+
return value;
|
|
4881
|
+
}
|
|
4882
|
+
}
|
|
4883
|
+
|
|
4886
4884
|
function setup(ctx, _server) {
|
|
4887
4885
|
const wss = new WebSocketServer({ noServer: true });
|
|
4888
4886
|
const clients = /* @__PURE__ */ new Map();
|
|
@@ -5057,6 +5055,75 @@ var setup$1 = /*#__PURE__*/Object.freeze({
|
|
|
5057
5055
|
setup: setup
|
|
5058
5056
|
});
|
|
5059
5057
|
|
|
5058
|
+
class FilesNotFoundError extends Error {
|
|
5059
|
+
code = "VITEST_FILES_NOT_FOUND";
|
|
5060
|
+
constructor(mode) {
|
|
5061
|
+
super(`No ${mode} files found`);
|
|
5062
|
+
}
|
|
5063
|
+
}
|
|
5064
|
+
class GitNotFoundError extends Error {
|
|
5065
|
+
code = "VITEST_GIT_NOT_FOUND";
|
|
5066
|
+
constructor() {
|
|
5067
|
+
super("Could not find Git root. Have you initialized git with `git init`?");
|
|
5068
|
+
}
|
|
5069
|
+
}
|
|
5070
|
+
|
|
5071
|
+
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
5072
|
+
class VitestPackageInstaller {
|
|
5073
|
+
isPackageExists(name, options) {
|
|
5074
|
+
return isPackageExists(name, options);
|
|
5075
|
+
}
|
|
5076
|
+
async ensureInstalled(dependency, root, version) {
|
|
5077
|
+
if (process.env.VITEST_SKIP_INSTALL_CHECKS) {
|
|
5078
|
+
return true;
|
|
5079
|
+
}
|
|
5080
|
+
if (process.versions.pnp) {
|
|
5081
|
+
const targetRequire = createRequire(__dirname);
|
|
5082
|
+
try {
|
|
5083
|
+
targetRequire.resolve(dependency, { paths: [root, __dirname] });
|
|
5084
|
+
return true;
|
|
5085
|
+
} catch {
|
|
5086
|
+
}
|
|
5087
|
+
}
|
|
5088
|
+
if (/* @__PURE__ */ isPackageExists(dependency, { paths: [root, __dirname] })) {
|
|
5089
|
+
return true;
|
|
5090
|
+
}
|
|
5091
|
+
const promptInstall = !isCI && process.stdout.isTTY;
|
|
5092
|
+
process.stderr.write(
|
|
5093
|
+
c.red(
|
|
5094
|
+
`${c.inverse(
|
|
5095
|
+
c.red(" MISSING DEPENDENCY ")
|
|
5096
|
+
)} Cannot find dependency '${dependency}'
|
|
5097
|
+
|
|
5098
|
+
`
|
|
5099
|
+
)
|
|
5100
|
+
);
|
|
5101
|
+
if (!promptInstall) {
|
|
5102
|
+
return false;
|
|
5103
|
+
}
|
|
5104
|
+
const prompts = await import('./index.BJDntFik.js').then(function (n) { return n.i; });
|
|
5105
|
+
const { install } = await prompts.prompt({
|
|
5106
|
+
type: "confirm",
|
|
5107
|
+
name: "install",
|
|
5108
|
+
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
5109
|
+
});
|
|
5110
|
+
if (install) {
|
|
5111
|
+
const packageName = version ? `${dependency}@${version}` : dependency;
|
|
5112
|
+
await (await import('./index.CqYx2Nsr.js')).installPackage(packageName, { dev: true });
|
|
5113
|
+
process.stderr.write(
|
|
5114
|
+
c.yellow(
|
|
5115
|
+
`
|
|
5116
|
+
Package ${packageName} installed, re-run the command to start.
|
|
5117
|
+
`
|
|
5118
|
+
)
|
|
5119
|
+
);
|
|
5120
|
+
process.exit();
|
|
5121
|
+
return true;
|
|
5122
|
+
}
|
|
5123
|
+
return false;
|
|
5124
|
+
}
|
|
5125
|
+
}
|
|
5126
|
+
|
|
5060
5127
|
async function loadCustomReporterModule(path, runner) {
|
|
5061
5128
|
let customReporterModule;
|
|
5062
5129
|
try {
|
|
@@ -5389,7 +5456,7 @@ function requirePath () {
|
|
|
5389
5456
|
Object.defineProperty(path, "__esModule", { value: true });
|
|
5390
5457
|
path.convertPosixPathToPattern = path.convertWindowsPathToPattern = path.convertPathToPattern = path.escapePosixPath = path.escapeWindowsPath = path.escape = path.removeLeadingDotSegment = path.makeAbsolute = path.unixify = void 0;
|
|
5391
5458
|
const os = require$$0$4;
|
|
5392
|
-
const path$1 =
|
|
5459
|
+
const path$1 = require$$0$5;
|
|
5393
5460
|
const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
|
|
5394
5461
|
const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
|
|
5395
5462
|
/**
|
|
@@ -5654,7 +5721,7 @@ function requireGlobParent () {
|
|
|
5654
5721
|
hasRequiredGlobParent = 1;
|
|
5655
5722
|
|
|
5656
5723
|
var isGlob = requireIsGlob();
|
|
5657
|
-
var pathPosixDirname =
|
|
5724
|
+
var pathPosixDirname = require$$0$5.posix.dirname;
|
|
5658
5725
|
var isWin32 = require$$0$4.platform() === 'win32';
|
|
5659
5726
|
|
|
5660
5727
|
var slash = '/';
|
|
@@ -5703,7 +5770,7 @@ function requirePattern () {
|
|
|
5703
5770
|
hasRequiredPattern = 1;
|
|
5704
5771
|
Object.defineProperty(pattern, "__esModule", { value: true });
|
|
5705
5772
|
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 =
|
|
5773
|
+
const path = require$$0$5;
|
|
5707
5774
|
const globParent = requireGlobParent();
|
|
5708
5775
|
const micromatch = requireMicromatch();
|
|
5709
5776
|
const GLOBSTAR = '**';
|
|
@@ -6335,7 +6402,7 @@ function requireFs$2 () {
|
|
|
6335
6402
|
(function (exports) {
|
|
6336
6403
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6337
6404
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
6338
|
-
const fs =
|
|
6405
|
+
const fs = require$$0$6;
|
|
6339
6406
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
6340
6407
|
lstat: fs.lstat,
|
|
6341
6408
|
stat: fs.stat,
|
|
@@ -6765,7 +6832,7 @@ function requireFs () {
|
|
|
6765
6832
|
(function (exports) {
|
|
6766
6833
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6767
6834
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
6768
|
-
const fs =
|
|
6835
|
+
const fs = require$$0$6;
|
|
6769
6836
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
6770
6837
|
lstat: fs.lstat,
|
|
6771
6838
|
stat: fs.stat,
|
|
@@ -6791,7 +6858,7 @@ function requireSettings$2 () {
|
|
|
6791
6858
|
if (hasRequiredSettings$2) return settings$2;
|
|
6792
6859
|
hasRequiredSettings$2 = 1;
|
|
6793
6860
|
Object.defineProperty(settings$2, "__esModule", { value: true });
|
|
6794
|
-
const path =
|
|
6861
|
+
const path = require$$0$5;
|
|
6795
6862
|
const fsStat = requireOut$3();
|
|
6796
6863
|
const fs = requireFs();
|
|
6797
6864
|
class Settings {
|
|
@@ -7553,7 +7620,7 @@ function requireSettings$1 () {
|
|
|
7553
7620
|
if (hasRequiredSettings$1) return settings$1;
|
|
7554
7621
|
hasRequiredSettings$1 = 1;
|
|
7555
7622
|
Object.defineProperty(settings$1, "__esModule", { value: true });
|
|
7556
|
-
const path =
|
|
7623
|
+
const path = require$$0$5;
|
|
7557
7624
|
const fsScandir = requireOut$2();
|
|
7558
7625
|
class Settings {
|
|
7559
7626
|
constructor(_options = {}) {
|
|
@@ -7629,7 +7696,7 @@ function requireReader () {
|
|
|
7629
7696
|
if (hasRequiredReader) return reader;
|
|
7630
7697
|
hasRequiredReader = 1;
|
|
7631
7698
|
Object.defineProperty(reader, "__esModule", { value: true });
|
|
7632
|
-
const path =
|
|
7699
|
+
const path = require$$0$5;
|
|
7633
7700
|
const fsStat = requireOut$3();
|
|
7634
7701
|
const utils = requireUtils$1();
|
|
7635
7702
|
class Reader {
|
|
@@ -8080,7 +8147,7 @@ function requireProvider () {
|
|
|
8080
8147
|
if (hasRequiredProvider) return provider;
|
|
8081
8148
|
hasRequiredProvider = 1;
|
|
8082
8149
|
Object.defineProperty(provider, "__esModule", { value: true });
|
|
8083
|
-
const path =
|
|
8150
|
+
const path = require$$0$5;
|
|
8084
8151
|
const deep_1 = requireDeep();
|
|
8085
8152
|
const entry_1 = requireEntry$1();
|
|
8086
8153
|
const error_1 = requireError();
|
|
@@ -8293,7 +8360,7 @@ function requireSettings () {
|
|
|
8293
8360
|
(function (exports) {
|
|
8294
8361
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8295
8362
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
|
|
8296
|
-
const fs =
|
|
8363
|
+
const fs = require$$0$6;
|
|
8297
8364
|
const os = require$$0$4;
|
|
8298
8365
|
/**
|
|
8299
8366
|
* The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
|
|
@@ -8464,38 +8531,341 @@ function requireOut () {
|
|
|
8464
8531
|
var outExports = requireOut();
|
|
8465
8532
|
var fg = /*@__PURE__*/getDefaultExportFromCjs(outExports);
|
|
8466
8533
|
|
|
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) {
|
|
8534
|
+
function serializeConfig(config, coreConfig, viteConfig) {
|
|
8535
|
+
const optimizer = config.deps?.optimizer;
|
|
8536
|
+
const poolOptions = config.poolOptions;
|
|
8537
|
+
const isolate = viteConfig?.test?.isolate;
|
|
8482
8538
|
return {
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8539
|
+
// TODO: remove functions from environmentOptions
|
|
8540
|
+
environmentOptions: config.environmentOptions,
|
|
8541
|
+
mode: config.mode,
|
|
8542
|
+
isolate: config.isolate,
|
|
8543
|
+
base: config.base,
|
|
8544
|
+
logHeapUsage: config.logHeapUsage,
|
|
8545
|
+
runner: config.runner,
|
|
8546
|
+
bail: config.bail,
|
|
8547
|
+
defines: config.defines,
|
|
8548
|
+
chaiConfig: config.chaiConfig,
|
|
8549
|
+
setupFiles: config.setupFiles,
|
|
8550
|
+
allowOnly: config.allowOnly,
|
|
8551
|
+
testTimeout: config.testTimeout,
|
|
8552
|
+
testNamePattern: config.testNamePattern,
|
|
8553
|
+
hookTimeout: config.hookTimeout,
|
|
8554
|
+
clearMocks: config.clearMocks,
|
|
8555
|
+
mockReset: config.mockReset,
|
|
8556
|
+
restoreMocks: config.restoreMocks,
|
|
8557
|
+
unstubEnvs: config.unstubEnvs,
|
|
8558
|
+
unstubGlobals: config.unstubGlobals,
|
|
8559
|
+
maxConcurrency: config.maxConcurrency,
|
|
8560
|
+
pool: config.pool,
|
|
8561
|
+
expect: config.expect,
|
|
8562
|
+
snapshotSerializers: config.snapshotSerializers,
|
|
8563
|
+
diff: config.diff,
|
|
8564
|
+
retry: config.retry,
|
|
8565
|
+
disableConsoleIntercept: config.disableConsoleIntercept,
|
|
8566
|
+
root: config.root,
|
|
8567
|
+
name: config.name,
|
|
8568
|
+
globals: config.globals,
|
|
8569
|
+
snapshotEnvironment: config.snapshotEnvironment,
|
|
8570
|
+
passWithNoTests: config.passWithNoTests,
|
|
8571
|
+
coverage: ((coverage) => {
|
|
8572
|
+
const htmlReporter = coverage.reporter.find(([reporterName]) => reporterName === "html");
|
|
8573
|
+
const subdir = htmlReporter && htmlReporter[1]?.subdir;
|
|
8574
|
+
return {
|
|
8575
|
+
reportsDirectory: coverage.reportsDirectory,
|
|
8576
|
+
provider: coverage.provider,
|
|
8577
|
+
enabled: coverage.enabled,
|
|
8578
|
+
htmlReporter: htmlReporter ? { subdir } : void 0,
|
|
8579
|
+
customProviderModule: "customProviderModule" in coverage ? coverage.customProviderModule : void 0
|
|
8580
|
+
};
|
|
8581
|
+
})(config.coverage),
|
|
8582
|
+
fakeTimers: config.fakeTimers,
|
|
8583
|
+
poolOptions: {
|
|
8584
|
+
forks: {
|
|
8585
|
+
singleFork: poolOptions?.forks?.singleFork ?? coreConfig.poolOptions?.forks?.singleFork ?? false,
|
|
8586
|
+
isolate: poolOptions?.forks?.isolate ?? isolate ?? coreConfig.poolOptions?.forks?.isolate ?? true
|
|
8587
|
+
},
|
|
8588
|
+
threads: {
|
|
8589
|
+
singleThread: poolOptions?.threads?.singleThread ?? coreConfig.poolOptions?.threads?.singleThread ?? false,
|
|
8590
|
+
isolate: poolOptions?.threads?.isolate ?? isolate ?? coreConfig.poolOptions?.threads?.isolate ?? true
|
|
8591
|
+
},
|
|
8592
|
+
vmThreads: {
|
|
8593
|
+
singleThread: poolOptions?.vmThreads?.singleThread ?? coreConfig.poolOptions?.vmThreads?.singleThread ?? false
|
|
8594
|
+
},
|
|
8595
|
+
vmForks: {
|
|
8596
|
+
singleFork: poolOptions?.vmForks?.singleFork ?? coreConfig.poolOptions?.vmForks?.singleFork ?? false
|
|
8597
|
+
}
|
|
8598
|
+
},
|
|
8599
|
+
deps: {
|
|
8600
|
+
web: config.deps.web || {},
|
|
8601
|
+
optimizer: {
|
|
8602
|
+
web: {
|
|
8603
|
+
enabled: optimizer?.web?.enabled ?? true
|
|
8604
|
+
},
|
|
8605
|
+
ssr: {
|
|
8606
|
+
enabled: optimizer?.ssr?.enabled ?? true
|
|
8607
|
+
}
|
|
8608
|
+
},
|
|
8609
|
+
interopDefault: config.deps.interopDefault,
|
|
8610
|
+
moduleDirectories: config.deps.moduleDirectories
|
|
8611
|
+
},
|
|
8612
|
+
snapshotOptions: {
|
|
8613
|
+
// TODO: store it differently, not on the config
|
|
8614
|
+
snapshotEnvironment: void 0,
|
|
8615
|
+
updateSnapshot: coreConfig.snapshotOptions.updateSnapshot,
|
|
8616
|
+
snapshotFormat: {
|
|
8617
|
+
...coreConfig.snapshotOptions.snapshotFormat,
|
|
8618
|
+
compareKeys: void 0
|
|
8619
|
+
},
|
|
8620
|
+
expand: config.snapshotOptions.expand ?? coreConfig.snapshotOptions.expand
|
|
8621
|
+
},
|
|
8622
|
+
sequence: {
|
|
8623
|
+
shuffle: coreConfig.sequence.shuffle,
|
|
8624
|
+
concurrent: coreConfig.sequence.concurrent,
|
|
8625
|
+
seed: coreConfig.sequence.seed,
|
|
8626
|
+
hooks: coreConfig.sequence.hooks,
|
|
8627
|
+
setupFiles: coreConfig.sequence.setupFiles
|
|
8628
|
+
},
|
|
8629
|
+
inspect: coreConfig.inspect,
|
|
8630
|
+
inspectBrk: coreConfig.inspectBrk,
|
|
8631
|
+
inspector: coreConfig.inspector,
|
|
8632
|
+
watch: config.watch,
|
|
8633
|
+
includeTaskLocation: config.includeTaskLocation ?? coreConfig.includeTaskLocation,
|
|
8634
|
+
env: {
|
|
8635
|
+
...viteConfig?.env,
|
|
8636
|
+
...config.env
|
|
8637
|
+
},
|
|
8638
|
+
browser: ((browser) => {
|
|
8639
|
+
return {
|
|
8640
|
+
name: browser.name,
|
|
8641
|
+
headless: browser.headless,
|
|
8642
|
+
isolate: browser.isolate,
|
|
8643
|
+
fileParallelism: browser.fileParallelism,
|
|
8644
|
+
ui: browser.ui,
|
|
8645
|
+
viewport: browser.viewport,
|
|
8646
|
+
screenshotFailures: browser.screenshotFailures,
|
|
8647
|
+
locators: {
|
|
8648
|
+
testIdAttribute: browser.locators.testIdAttribute
|
|
8649
|
+
}
|
|
8650
|
+
};
|
|
8651
|
+
})(config.browser),
|
|
8652
|
+
standalone: config.standalone,
|
|
8653
|
+
printConsoleTrace: config.printConsoleTrace ?? coreConfig.printConsoleTrace,
|
|
8654
|
+
benchmark: config.benchmark && {
|
|
8655
|
+
includeSamples: config.benchmark.includeSamples
|
|
8656
|
+
}
|
|
8657
|
+
};
|
|
8658
|
+
}
|
|
8659
|
+
|
|
8660
|
+
async function loadGlobalSetupFiles(runner, globalSetup) {
|
|
8661
|
+
const globalSetupFiles = toArray(globalSetup);
|
|
8662
|
+
return Promise.all(
|
|
8663
|
+
globalSetupFiles.map((file) => loadGlobalSetupFile(file, runner))
|
|
8664
|
+
);
|
|
8665
|
+
}
|
|
8666
|
+
async function loadGlobalSetupFile(file, runner) {
|
|
8667
|
+
const m = await runner.executeFile(file);
|
|
8668
|
+
for (const exp of ["default", "setup", "teardown"]) {
|
|
8669
|
+
if (m[exp] != null && typeof m[exp] !== "function") {
|
|
8670
|
+
throw new Error(
|
|
8671
|
+
`invalid export in globalSetup file ${file}: ${exp} must be a function`
|
|
8672
|
+
);
|
|
8673
|
+
}
|
|
8674
|
+
}
|
|
8675
|
+
if (m.default) {
|
|
8676
|
+
return {
|
|
8677
|
+
file,
|
|
8678
|
+
setup: m.default
|
|
8679
|
+
};
|
|
8680
|
+
} else if (m.setup || m.teardown) {
|
|
8681
|
+
return {
|
|
8682
|
+
file,
|
|
8683
|
+
setup: m.setup,
|
|
8684
|
+
teardown: m.teardown
|
|
8685
|
+
};
|
|
8686
|
+
} else {
|
|
8687
|
+
throw new Error(
|
|
8688
|
+
`invalid globalSetup file ${file}. Must export setup, teardown or have a default export`
|
|
8689
|
+
);
|
|
8690
|
+
}
|
|
8691
|
+
}
|
|
8692
|
+
|
|
8693
|
+
function CoverageTransform(ctx) {
|
|
8694
|
+
return {
|
|
8695
|
+
name: "vitest:coverage-transform",
|
|
8696
|
+
transform(srcCode, id) {
|
|
8697
|
+
return ctx.coverageProvider?.onFileTransform?.(
|
|
8698
|
+
srcCode,
|
|
8699
|
+
normalizeRequestId(id),
|
|
8700
|
+
this
|
|
8701
|
+
);
|
|
8702
|
+
}
|
|
8703
|
+
};
|
|
8704
|
+
}
|
|
8705
|
+
|
|
8706
|
+
function MocksPlugins(options = {}) {
|
|
8707
|
+
const normalizedDistDir = normalize(distDir);
|
|
8708
|
+
return [
|
|
8709
|
+
hoistMocksPlugin({
|
|
8710
|
+
filter(id) {
|
|
8711
|
+
if (id.includes(normalizedDistDir)) {
|
|
8712
|
+
return false;
|
|
8713
|
+
}
|
|
8714
|
+
if (options.filter) {
|
|
8715
|
+
return options.filter(id);
|
|
8716
|
+
}
|
|
8717
|
+
return true;
|
|
8718
|
+
},
|
|
8719
|
+
codeFrameGenerator(node, id, code) {
|
|
8720
|
+
return generateCodeFrame(
|
|
8721
|
+
code,
|
|
8722
|
+
4,
|
|
8723
|
+
node.start + 1
|
|
8724
|
+
);
|
|
8725
|
+
}
|
|
8726
|
+
}),
|
|
8727
|
+
automockPlugin()
|
|
8728
|
+
];
|
|
8729
|
+
}
|
|
8730
|
+
|
|
8731
|
+
function generateCssFilenameHash(filepath) {
|
|
8732
|
+
return hash("md5", filepath, "hex").slice(0, 6);
|
|
8733
|
+
}
|
|
8734
|
+
function generateScopedClassName(strategy, name, filename) {
|
|
8735
|
+
if (strategy === "scoped") {
|
|
8736
|
+
return null;
|
|
8737
|
+
}
|
|
8738
|
+
if (strategy === "non-scoped") {
|
|
8739
|
+
return name;
|
|
8740
|
+
}
|
|
8741
|
+
const hash2 = generateCssFilenameHash(filename);
|
|
8742
|
+
return `_${name}_${hash2}`;
|
|
8743
|
+
}
|
|
8744
|
+
|
|
8745
|
+
const LogLevels = {
|
|
8746
|
+
silent: 0,
|
|
8747
|
+
error: 1,
|
|
8748
|
+
warn: 2,
|
|
8749
|
+
info: 3
|
|
8750
|
+
};
|
|
8751
|
+
function clearScreen(logger) {
|
|
8752
|
+
const repeatCount = process.stdout.rows - 2;
|
|
8753
|
+
const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
|
|
8754
|
+
logger.clearScreen(blank);
|
|
8755
|
+
}
|
|
8756
|
+
let lastType;
|
|
8757
|
+
let lastMsg;
|
|
8758
|
+
let sameCount = 0;
|
|
8759
|
+
let timeFormatter;
|
|
8760
|
+
function getTimeFormatter() {
|
|
8761
|
+
timeFormatter ??= new Intl.DateTimeFormat(void 0, {
|
|
8762
|
+
hour: "numeric",
|
|
8763
|
+
minute: "numeric",
|
|
8764
|
+
second: "numeric"
|
|
8765
|
+
});
|
|
8766
|
+
return timeFormatter;
|
|
8767
|
+
}
|
|
8768
|
+
function createViteLogger(console, level = "info", options = {}) {
|
|
8769
|
+
const loggedErrors = /* @__PURE__ */ new WeakSet();
|
|
8770
|
+
const { prefix = "[vite]", allowClearScreen = true } = options;
|
|
8771
|
+
const thresh = LogLevels[level];
|
|
8772
|
+
const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
|
|
8773
|
+
const clear = canClearScreen ? clearScreen : () => {
|
|
8774
|
+
};
|
|
8775
|
+
function format(type, msg, options2 = {}) {
|
|
8776
|
+
if (options2.timestamp) {
|
|
8777
|
+
let tag = "";
|
|
8778
|
+
if (type === "info") {
|
|
8779
|
+
tag = c.cyan(c.bold(prefix));
|
|
8780
|
+
} else if (type === "warn") {
|
|
8781
|
+
tag = c.yellow(c.bold(prefix));
|
|
8782
|
+
} else {
|
|
8783
|
+
tag = c.red(c.bold(prefix));
|
|
8784
|
+
}
|
|
8785
|
+
const environment = options2.environment ? `${options2.environment} ` : "";
|
|
8786
|
+
return `${c.dim(getTimeFormatter().format(/* @__PURE__ */ new Date()))} ${tag} ${environment}${msg}`;
|
|
8787
|
+
} else {
|
|
8788
|
+
return msg;
|
|
8789
|
+
}
|
|
8790
|
+
}
|
|
8791
|
+
function output(type, msg, options2 = {}) {
|
|
8792
|
+
if (thresh >= LogLevels[type]) {
|
|
8793
|
+
const method = type === "info" ? "log" : type;
|
|
8794
|
+
if (options2.error) {
|
|
8795
|
+
loggedErrors.add(options2.error);
|
|
8796
|
+
}
|
|
8797
|
+
if (canClearScreen) {
|
|
8798
|
+
if (type === lastType && msg === lastMsg) {
|
|
8799
|
+
sameCount++;
|
|
8800
|
+
clear(console);
|
|
8801
|
+
console[method](
|
|
8802
|
+
format(type, msg, options2),
|
|
8803
|
+
c.yellow(`(x${sameCount + 1})`)
|
|
8804
|
+
);
|
|
8805
|
+
} else {
|
|
8806
|
+
sameCount = 0;
|
|
8807
|
+
lastMsg = msg;
|
|
8808
|
+
lastType = type;
|
|
8809
|
+
if (options2.clear) {
|
|
8810
|
+
clear(console);
|
|
8811
|
+
}
|
|
8812
|
+
console[method](format(type, msg, options2));
|
|
8813
|
+
}
|
|
8814
|
+
} else {
|
|
8815
|
+
console[method](format(type, msg, options2));
|
|
8816
|
+
}
|
|
8817
|
+
}
|
|
8818
|
+
}
|
|
8819
|
+
const warnedMessages = /* @__PURE__ */ new Set();
|
|
8820
|
+
const logger = {
|
|
8821
|
+
hasWarned: false,
|
|
8822
|
+
info(msg, opts) {
|
|
8823
|
+
output("info", msg, opts);
|
|
8824
|
+
},
|
|
8825
|
+
warn(msg, opts) {
|
|
8826
|
+
logger.hasWarned = true;
|
|
8827
|
+
output("warn", msg, opts);
|
|
8828
|
+
},
|
|
8829
|
+
warnOnce(msg, opts) {
|
|
8830
|
+
if (warnedMessages.has(msg)) {
|
|
8831
|
+
return;
|
|
8832
|
+
}
|
|
8833
|
+
logger.hasWarned = true;
|
|
8834
|
+
output("warn", msg, opts);
|
|
8835
|
+
warnedMessages.add(msg);
|
|
8836
|
+
},
|
|
8837
|
+
error(msg, opts) {
|
|
8838
|
+
logger.hasWarned = true;
|
|
8839
|
+
output("error", msg, opts);
|
|
8840
|
+
},
|
|
8841
|
+
clearScreen(type) {
|
|
8842
|
+
if (thresh >= LogLevels[type]) {
|
|
8843
|
+
clear(console);
|
|
8844
|
+
}
|
|
8845
|
+
},
|
|
8846
|
+
hasErrorLogged(error) {
|
|
8847
|
+
return loggedErrors.has(error);
|
|
8848
|
+
}
|
|
8849
|
+
};
|
|
8850
|
+
return logger;
|
|
8851
|
+
}
|
|
8852
|
+
function silenceImportViteIgnoreWarning(logger) {
|
|
8853
|
+
return {
|
|
8854
|
+
...logger,
|
|
8855
|
+
warn(msg, options) {
|
|
8856
|
+
if (msg.includes("The above dynamic import cannot be analyzed by Vite")) {
|
|
8857
|
+
return;
|
|
8858
|
+
}
|
|
8859
|
+
logger.warn(msg, options);
|
|
8860
|
+
}
|
|
8861
|
+
};
|
|
8862
|
+
}
|
|
8863
|
+
|
|
8864
|
+
const cssLangs = "\\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)(?:$|\\?)";
|
|
8865
|
+
const cssLangRE = new RegExp(cssLangs);
|
|
8866
|
+
const cssModuleRE = new RegExp(`\\.module${cssLangs}`);
|
|
8867
|
+
const cssInlineRE = /[?&]inline(?:&|$)/;
|
|
8868
|
+
function isCSS(id) {
|
|
8499
8869
|
return cssLangRE.test(id);
|
|
8500
8870
|
}
|
|
8501
8871
|
function isCSSModule(id) {
|
|
@@ -9048,58 +9418,34 @@ function stripLiteralDetailed(code, options) {
|
|
|
9048
9418
|
return stripLiteralJsTokens(code);
|
|
9049
9419
|
}
|
|
9050
9420
|
|
|
9051
|
-
|
|
9421
|
+
const metaUrlLength = "import.meta.url".length;
|
|
9422
|
+
const locationString = "self.location".padEnd(metaUrlLength, " ");
|
|
9423
|
+
function NormalizeURLPlugin() {
|
|
9052
9424
|
return {
|
|
9053
|
-
name: "vitest:
|
|
9054
|
-
enforce: "
|
|
9055
|
-
transform(code, id) {
|
|
9056
|
-
|
|
9057
|
-
|
|
9425
|
+
name: "vitest:normalize-url",
|
|
9426
|
+
enforce: "post",
|
|
9427
|
+
transform(code, id, options) {
|
|
9428
|
+
const ssr = options?.ssr === true;
|
|
9429
|
+
if (ssr || !code.includes("new URL") || !code.includes("import.meta.url")) {
|
|
9430
|
+
return;
|
|
9058
9431
|
}
|
|
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
|
-
};
|
|
9432
|
+
const cleanString = stripLiteral(code);
|
|
9433
|
+
const assetImportMetaUrlRE = /\bnew\s+URL\s*\(\s*(?:'[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\)/g;
|
|
9434
|
+
let updatedCode = code;
|
|
9435
|
+
let match;
|
|
9436
|
+
while (match = assetImportMetaUrlRE.exec(cleanString)) {
|
|
9437
|
+
const { 0: exp, index } = match;
|
|
9438
|
+
const metaUrlIndex = index + exp.indexOf("import.meta.url");
|
|
9439
|
+
updatedCode = updatedCode.slice(0, metaUrlIndex) + locationString + updatedCode.slice(metaUrlIndex + metaUrlLength);
|
|
9077
9440
|
}
|
|
9441
|
+
return {
|
|
9442
|
+
code: updatedCode,
|
|
9443
|
+
map: null
|
|
9444
|
+
};
|
|
9078
9445
|
}
|
|
9079
9446
|
};
|
|
9080
9447
|
}
|
|
9081
9448
|
|
|
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
9449
|
function resolveOptimizerConfig(_testOptions, viteOptions, testConfig) {
|
|
9104
9450
|
const testOptions = _testOptions || {};
|
|
9105
9451
|
const newConfig = {};
|
|
@@ -9148,7 +9494,7 @@ function resolveOptimizerConfig(_testOptions, viteOptions, testConfig) {
|
|
|
9148
9494
|
include
|
|
9149
9495
|
};
|
|
9150
9496
|
}
|
|
9151
|
-
if (major >= 5 && minor >= 1) {
|
|
9497
|
+
if (major >= 5 && minor >= 1 || major >= 6) {
|
|
9152
9498
|
if (newConfig.optimizeDeps.disabled) {
|
|
9153
9499
|
newConfig.optimizeDeps.noDiscovery = true;
|
|
9154
9500
|
newConfig.optimizeDeps.include = [];
|
|
@@ -9210,39 +9556,6 @@ function resolveFsAllow(projectRoot, rootConfigFile) {
|
|
|
9210
9556
|
];
|
|
9211
9557
|
}
|
|
9212
9558
|
|
|
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
9559
|
function VitestOptimizer() {
|
|
9247
9560
|
return {
|
|
9248
9561
|
name: "vitest:normalize-optimizer",
|
|
@@ -9269,307 +9582,176 @@ function VitestOptimizer() {
|
|
|
9269
9582
|
};
|
|
9270
9583
|
}
|
|
9271
9584
|
|
|
9272
|
-
|
|
9273
|
-
const locationString = "self.location".padEnd(metaUrlLength, " ");
|
|
9274
|
-
function NormalizeURLPlugin() {
|
|
9585
|
+
function SsrReplacerPlugin() {
|
|
9275
9586
|
return {
|
|
9276
|
-
name: "vitest:
|
|
9277
|
-
enforce: "
|
|
9278
|
-
transform(code, id
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
return;
|
|
9587
|
+
name: "vitest:ssr-replacer",
|
|
9588
|
+
enforce: "pre",
|
|
9589
|
+
transform(code, id) {
|
|
9590
|
+
if (!/\bimport\.meta\.env\b/.test(code)) {
|
|
9591
|
+
return null;
|
|
9282
9592
|
}
|
|
9283
|
-
|
|
9284
|
-
const
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
const
|
|
9289
|
-
const
|
|
9290
|
-
|
|
9593
|
+
let s = null;
|
|
9594
|
+
const cleanCode = stripLiteral(code);
|
|
9595
|
+
const envs = cleanCode.matchAll(/\bimport\.meta\.env\b/g);
|
|
9596
|
+
for (const env of envs) {
|
|
9597
|
+
s ||= new MagicString(code);
|
|
9598
|
+
const startIndex = env.index;
|
|
9599
|
+
const endIndex = startIndex + env[0].length;
|
|
9600
|
+
s.overwrite(startIndex, endIndex, "__vite_ssr_import_meta__.env");
|
|
9291
9601
|
}
|
|
9292
|
-
|
|
9293
|
-
|
|
9294
|
-
|
|
9295
|
-
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
function WorkspaceVitestPlugin(project, options) {
|
|
9301
|
-
return [
|
|
9302
|
-
{
|
|
9303
|
-
name: "vitest:project",
|
|
9304
|
-
enforce: "pre",
|
|
9305
|
-
options() {
|
|
9306
|
-
this.meta.watchMode = false;
|
|
9307
|
-
},
|
|
9308
|
-
config(viteConfig) {
|
|
9309
|
-
const defines = deleteDefineConfig(viteConfig);
|
|
9310
|
-
const testConfig = viteConfig.test || {};
|
|
9311
|
-
const root = testConfig.root || viteConfig.root || options.root;
|
|
9312
|
-
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
|
-
test: {
|
|
9360
|
-
name
|
|
9361
|
-
}
|
|
9602
|
+
if (s) {
|
|
9603
|
+
return {
|
|
9604
|
+
code: s.toString(),
|
|
9605
|
+
map: s.generateMap({
|
|
9606
|
+
hires: "boundary",
|
|
9607
|
+
// Remove possible query parameters, e.g. vue's "?vue&type=script&src=true&lang.ts"
|
|
9608
|
+
source: cleanUrl(id)
|
|
9609
|
+
})
|
|
9362
9610
|
};
|
|
9363
|
-
config.test.defines = defines;
|
|
9364
|
-
const classNameStrategy = typeof testConfig.css !== "boolean" && testConfig.css?.modules?.classNameStrategy || "stable";
|
|
9365
|
-
if (classNameStrategy !== "scoped") {
|
|
9366
|
-
config.css ??= {};
|
|
9367
|
-
config.css.modules ??= {};
|
|
9368
|
-
if (config.css.modules) {
|
|
9369
|
-
config.css.modules.generateScopedName = (name2, filename) => {
|
|
9370
|
-
const root2 = project.config.root;
|
|
9371
|
-
return generateScopedClassName(
|
|
9372
|
-
classNameStrategy,
|
|
9373
|
-
name2,
|
|
9374
|
-
relative(root2, filename)
|
|
9375
|
-
);
|
|
9376
|
-
};
|
|
9377
|
-
}
|
|
9378
|
-
}
|
|
9379
|
-
return config;
|
|
9380
|
-
},
|
|
9381
|
-
configResolved(viteConfig) {
|
|
9382
|
-
hijackVitePluginInject(viteConfig);
|
|
9383
|
-
},
|
|
9384
|
-
async configureServer(server) {
|
|
9385
|
-
const options2 = deepMerge({}, configDefaults, server.config.test || {});
|
|
9386
|
-
await project.setServer(options2, server);
|
|
9387
|
-
await server.watcher.close();
|
|
9388
9611
|
}
|
|
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
9612
|
}
|
|
9406
|
-
error(...args);
|
|
9407
9613
|
};
|
|
9408
|
-
const server = await createServer({
|
|
9409
|
-
logLevel: "error",
|
|
9410
|
-
...inlineConfig
|
|
9411
|
-
});
|
|
9412
|
-
console.error = error;
|
|
9413
|
-
return server;
|
|
9414
9614
|
}
|
|
9415
9615
|
|
|
9416
|
-
|
|
9417
|
-
const
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
|
|
9421
|
-
|
|
9422
|
-
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
|
|
9428
|
-
);
|
|
9616
|
+
function VitestProjectResolver(ctx) {
|
|
9617
|
+
const plugin = {
|
|
9618
|
+
name: "vitest:resolve-root",
|
|
9619
|
+
enforce: "pre",
|
|
9620
|
+
async resolveId(id, _, { ssr }) {
|
|
9621
|
+
if (id === "vitest" || id.startsWith("@vitest/") || id.startsWith("vitest/")) {
|
|
9622
|
+
const resolved = await ctx.server.pluginContainer.resolveId(id, void 0, {
|
|
9623
|
+
skip: /* @__PURE__ */ new Set([plugin]),
|
|
9624
|
+
ssr
|
|
9625
|
+
});
|
|
9626
|
+
return resolved;
|
|
9627
|
+
}
|
|
9429
9628
|
}
|
|
9430
|
-
}
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
|
|
9437
|
-
|
|
9438
|
-
|
|
9439
|
-
|
|
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
|
|
9629
|
+
};
|
|
9630
|
+
return plugin;
|
|
9631
|
+
}
|
|
9632
|
+
function VitestCoreResolver(ctx) {
|
|
9633
|
+
return {
|
|
9634
|
+
name: "vitest:resolve-core",
|
|
9635
|
+
enforce: "pre",
|
|
9636
|
+
async resolveId(id) {
|
|
9637
|
+
if (id === "vitest") {
|
|
9638
|
+
return resolve(distDir, "index.js");
|
|
9512
9639
|
}
|
|
9513
|
-
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
|
|
9517
|
-
|
|
9518
|
-
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9640
|
+
if (id.startsWith("@vitest/") || id.startsWith("vitest/")) {
|
|
9641
|
+
return this.resolve(id, join(ctx.config.root, "index.html"), {
|
|
9642
|
+
skipSelf: true
|
|
9643
|
+
});
|
|
9644
|
+
}
|
|
9645
|
+
}
|
|
9646
|
+
};
|
|
9647
|
+
}
|
|
9648
|
+
|
|
9649
|
+
function WorkspaceVitestPlugin(project, options) {
|
|
9650
|
+
return [
|
|
9651
|
+
{
|
|
9652
|
+
name: "vitest:project",
|
|
9653
|
+
enforce: "pre",
|
|
9654
|
+
options() {
|
|
9655
|
+
this.meta.watchMode = false;
|
|
9656
|
+
},
|
|
9657
|
+
config(viteConfig) {
|
|
9658
|
+
const defines = deleteDefineConfig(viteConfig);
|
|
9659
|
+
const testConfig = viteConfig.test || {};
|
|
9660
|
+
const root = testConfig.root || viteConfig.root || options.root;
|
|
9661
|
+
let name = testConfig.name;
|
|
9662
|
+
if (!name) {
|
|
9663
|
+
if (typeof options.workspacePath === "string") {
|
|
9664
|
+
const dir = options.workspacePath.endsWith("/") ? options.workspacePath.slice(0, -1) : dirname(options.workspacePath);
|
|
9665
|
+
const pkgJsonPath = resolve(dir, "package.json");
|
|
9666
|
+
if (existsSync(pkgJsonPath)) {
|
|
9667
|
+
name = JSON.parse(readFileSync(pkgJsonPath, "utf-8")).name;
|
|
9668
|
+
}
|
|
9669
|
+
if (typeof name !== "string" || !name) {
|
|
9670
|
+
name = basename(dir);
|
|
9671
|
+
}
|
|
9672
|
+
} else {
|
|
9673
|
+
name = options.workspacePath.toString();
|
|
9674
|
+
}
|
|
9675
|
+
}
|
|
9676
|
+
const config = {
|
|
9677
|
+
root,
|
|
9678
|
+
resolve: {
|
|
9679
|
+
// by default Vite resolves `module` field, which not always a native ESM module
|
|
9680
|
+
// setting this option can bypass that and fallback to cjs version
|
|
9681
|
+
mainFields: [],
|
|
9682
|
+
alias: testConfig.alias,
|
|
9683
|
+
conditions: ["node"]
|
|
9684
|
+
},
|
|
9685
|
+
esbuild: viteConfig.esbuild === false ? false : {
|
|
9686
|
+
// Lowest target Vitest supports is Node18
|
|
9687
|
+
target: viteConfig.esbuild?.target || "node18",
|
|
9688
|
+
sourcemap: "external",
|
|
9689
|
+
// Enables using ignore hint for coverage providers with @preserve keyword
|
|
9690
|
+
legalComments: "inline"
|
|
9691
|
+
},
|
|
9692
|
+
server: {
|
|
9693
|
+
// disable watch mode in workspaces,
|
|
9694
|
+
// because it is handled by the top-level watcher
|
|
9695
|
+
watch: null,
|
|
9696
|
+
open: false,
|
|
9697
|
+
hmr: false,
|
|
9698
|
+
ws: false,
|
|
9699
|
+
preTransformRequests: false,
|
|
9700
|
+
middlewareMode: true,
|
|
9701
|
+
fs: {
|
|
9702
|
+
allow: resolveFsAllow(
|
|
9703
|
+
project.ctx.config.root,
|
|
9704
|
+
project.ctx.server.config.configFile
|
|
9705
|
+
)
|
|
9706
|
+
}
|
|
9707
|
+
},
|
|
9708
|
+
test: {
|
|
9709
|
+
name
|
|
9710
|
+
}
|
|
9711
|
+
};
|
|
9712
|
+
config.test.defines = defines;
|
|
9713
|
+
const classNameStrategy = typeof testConfig.css !== "boolean" && testConfig.css?.modules?.classNameStrategy || "stable";
|
|
9714
|
+
if (classNameStrategy !== "scoped") {
|
|
9715
|
+
config.css ??= {};
|
|
9716
|
+
config.css.modules ??= {};
|
|
9717
|
+
if (config.css.modules) {
|
|
9718
|
+
config.css.modules.generateScopedName = (name2, filename) => {
|
|
9719
|
+
const root2 = project.config.root;
|
|
9720
|
+
return generateScopedClassName(
|
|
9721
|
+
classNameStrategy,
|
|
9722
|
+
name2,
|
|
9723
|
+
relative(root2, filename)
|
|
9724
|
+
);
|
|
9725
|
+
};
|
|
9726
|
+
}
|
|
9522
9727
|
}
|
|
9728
|
+
config.customLogger = createViteLogger(
|
|
9729
|
+
project.logger,
|
|
9730
|
+
viteConfig.logLevel || "warn",
|
|
9731
|
+
{
|
|
9732
|
+
allowClearScreen: false
|
|
9733
|
+
}
|
|
9734
|
+
);
|
|
9735
|
+
config.customLogger = silenceImportViteIgnoreWarning(config.customLogger);
|
|
9736
|
+
return config;
|
|
9523
9737
|
},
|
|
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
|
|
9738
|
+
configResolved(viteConfig) {
|
|
9739
|
+
hijackVitePluginInject(viteConfig);
|
|
9534
9740
|
},
|
|
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
|
|
9741
|
+
async configureServer(server) {
|
|
9742
|
+
const options2 = deepMerge({}, configDefaults, server.config.test || {});
|
|
9743
|
+
await project.setServer(options2, server);
|
|
9744
|
+
await server.watcher.close();
|
|
9745
|
+
}
|
|
9552
9746
|
},
|
|
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
|
-
};
|
|
9747
|
+
SsrReplacerPlugin(),
|
|
9748
|
+
...CSSEnablerPlugin(project),
|
|
9749
|
+
CoverageTransform(project.ctx),
|
|
9750
|
+
...MocksPlugins(),
|
|
9751
|
+
VitestProjectResolver(project.ctx),
|
|
9752
|
+
VitestOptimizer(),
|
|
9753
|
+
NormalizeURLPlugin()
|
|
9754
|
+
];
|
|
9573
9755
|
}
|
|
9574
9756
|
|
|
9575
9757
|
class TestSpecification {
|
|
@@ -9618,6 +9800,19 @@ class TestSpecification {
|
|
|
9618
9800
|
}
|
|
9619
9801
|
}
|
|
9620
9802
|
|
|
9803
|
+
async function createViteServer(inlineConfig) {
|
|
9804
|
+
const error = console.error;
|
|
9805
|
+
console.error = (...args) => {
|
|
9806
|
+
if (typeof args[0] === "string" && args[0].includes("WebSocket server error:")) {
|
|
9807
|
+
return;
|
|
9808
|
+
}
|
|
9809
|
+
error(...args);
|
|
9810
|
+
};
|
|
9811
|
+
const server = await createServer(inlineConfig);
|
|
9812
|
+
console.error = error;
|
|
9813
|
+
return server;
|
|
9814
|
+
}
|
|
9815
|
+
|
|
9621
9816
|
async function initializeProject(workspacePath, ctx, options) {
|
|
9622
9817
|
const project = new WorkspaceProject(workspacePath, ctx, options);
|
|
9623
9818
|
const root = options.root || (typeof workspacePath === "number" ? void 0 : workspacePath.endsWith("/") ? workspacePath : dirname(workspacePath));
|
|
@@ -9625,7 +9820,6 @@ async function initializeProject(workspacePath, ctx, options) {
|
|
|
9625
9820
|
const config = {
|
|
9626
9821
|
...options,
|
|
9627
9822
|
root,
|
|
9628
|
-
logLevel: "error",
|
|
9629
9823
|
configFile,
|
|
9630
9824
|
// this will make "mode": "test" | "benchmark" inside defineConfig
|
|
9631
9825
|
mode: options.test?.mode || options.mode || ctx.config.mode,
|
|
@@ -9638,8 +9832,8 @@ async function initializeProject(workspacePath, ctx, options) {
|
|
|
9638
9832
|
return project;
|
|
9639
9833
|
}
|
|
9640
9834
|
class WorkspaceProject {
|
|
9641
|
-
constructor(
|
|
9642
|
-
this.path =
|
|
9835
|
+
constructor(path2, ctx, options) {
|
|
9836
|
+
this.path = path2;
|
|
9643
9837
|
this.ctx = ctx;
|
|
9644
9838
|
this.options = options;
|
|
9645
9839
|
}
|
|
@@ -9797,7 +9991,7 @@ class WorkspaceProject {
|
|
|
9797
9991
|
ignore: exclude
|
|
9798
9992
|
};
|
|
9799
9993
|
const files = await fg(include, globOptions);
|
|
9800
|
-
return files.map((file) => resolve(cwd, file));
|
|
9994
|
+
return files.map((file) => slash(a.resolve(cwd, file)));
|
|
9801
9995
|
}
|
|
9802
9996
|
async isTargetFile(id, source) {
|
|
9803
9997
|
const relativeId = relative(this.config.dir || this.config.root, id);
|
|
@@ -9818,7 +10012,7 @@ class WorkspaceProject {
|
|
|
9818
10012
|
}
|
|
9819
10013
|
filterFiles(testFiles, filters, dir) {
|
|
9820
10014
|
if (filters.length && process.platform === "win32") {
|
|
9821
|
-
filters = filters.map((f) =>
|
|
10015
|
+
filters = filters.map((f) => slash(f));
|
|
9822
10016
|
}
|
|
9823
10017
|
if (filters.length) {
|
|
9824
10018
|
return testFiles.filter((t) => {
|
|
@@ -9839,12 +10033,21 @@ class WorkspaceProject {
|
|
|
9839
10033
|
return;
|
|
9840
10034
|
}
|
|
9841
10035
|
await this.ctx.packageInstaller.ensureInstalled("@vitest/browser", this.config.root, this.ctx.version);
|
|
9842
|
-
const { createBrowserServer } = await import('@vitest/browser');
|
|
10036
|
+
const { createBrowserServer, distRoot } = await import('@vitest/browser');
|
|
9843
10037
|
await this.browser?.close();
|
|
9844
10038
|
const browser = await createBrowserServer(
|
|
9845
10039
|
this,
|
|
9846
10040
|
configFile,
|
|
9847
|
-
[
|
|
10041
|
+
[
|
|
10042
|
+
...MocksPlugins({
|
|
10043
|
+
filter(id) {
|
|
10044
|
+
if (id.includes(distRoot)) {
|
|
10045
|
+
return false;
|
|
10046
|
+
}
|
|
10047
|
+
return true;
|
|
10048
|
+
}
|
|
10049
|
+
})
|
|
10050
|
+
],
|
|
9848
10051
|
[CoverageTransform(this.ctx)]
|
|
9849
10052
|
);
|
|
9850
10053
|
this.browser = browser;
|
|
@@ -9953,72 +10156,6 @@ class WorkspaceProject {
|
|
|
9953
10156
|
}
|
|
9954
10157
|
}
|
|
9955
10158
|
|
|
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;
|
|
10004
|
-
}
|
|
10005
|
-
return false;
|
|
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`?");
|
|
10019
|
-
}
|
|
10020
|
-
}
|
|
10021
|
-
|
|
10022
10159
|
const ESCAPE_SYMBOL = "\\";
|
|
10023
10160
|
const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
|
|
10024
10161
|
const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[[^[]*\]/;
|
|
@@ -10276,6 +10413,8 @@ class Vitest {
|
|
|
10276
10413
|
_cachedSpecs = /* @__PURE__ */ new Map();
|
|
10277
10414
|
/** @deprecated use `_cachedSpecs` */
|
|
10278
10415
|
projectTestFiles = this._cachedSpecs;
|
|
10416
|
+
/** @private */
|
|
10417
|
+
_browserLastPort = defaultBrowserPort;
|
|
10279
10418
|
_onRestartListeners = [];
|
|
10280
10419
|
_onClose = [];
|
|
10281
10420
|
_onSetServer = [];
|
|
@@ -10284,6 +10423,7 @@ class Vitest {
|
|
|
10284
10423
|
this.unregisterWatcher?.();
|
|
10285
10424
|
clearTimeout(this._rerunTimer);
|
|
10286
10425
|
this.restartsCount += 1;
|
|
10426
|
+
this._browserLastPort = defaultBrowserPort;
|
|
10287
10427
|
this.pool?.close?.();
|
|
10288
10428
|
this.pool = void 0;
|
|
10289
10429
|
this.coverageProvider = void 0;
|
|
@@ -11158,6 +11298,14 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
11158
11298
|
}
|
|
11159
11299
|
}
|
|
11160
11300
|
};
|
|
11301
|
+
config.customLogger = createViteLogger(
|
|
11302
|
+
ctx.logger,
|
|
11303
|
+
viteConfig.logLevel || "warn",
|
|
11304
|
+
{
|
|
11305
|
+
allowClearScreen: false
|
|
11306
|
+
}
|
|
11307
|
+
);
|
|
11308
|
+
config.customLogger = silenceImportViteIgnoreWarning(config.customLogger);
|
|
11161
11309
|
if (userConfig.coverage?.enabled && !userConfig.coverage.exclude && userConfig.include && config.test) {
|
|
11162
11310
|
config.test.coverage = {
|
|
11163
11311
|
exclude: [...coverageConfigDefaults.exclude, ...userConfig.include]
|
|
@@ -11250,14 +11398,21 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
11250
11398
|
NormalizeURLPlugin()
|
|
11251
11399
|
].filter(notNullish);
|
|
11252
11400
|
}
|
|
11401
|
+
function removeUndefinedValues(obj) {
|
|
11402
|
+
for (const key in Object.keys(obj)) {
|
|
11403
|
+
if (obj[key] === void 0) {
|
|
11404
|
+
delete obj[key];
|
|
11405
|
+
}
|
|
11406
|
+
}
|
|
11407
|
+
return obj;
|
|
11408
|
+
}
|
|
11253
11409
|
|
|
11254
11410
|
async function createVitest(mode, options, viteOverrides = {}, vitestOptions = {}) {
|
|
11255
11411
|
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 });
|
|
11412
|
+
const root = slash(resolve$1(options.root || process.cwd()));
|
|
11413
|
+
const configPath = options.config === false ? false : options.config ? resolve$1(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
11258
11414
|
options.config = configPath;
|
|
11259
11415
|
const config = {
|
|
11260
|
-
logLevel: "error",
|
|
11261
11416
|
configFile: configPath,
|
|
11262
11417
|
// this will make "mode": "test" | "benchmark" inside defineConfig
|
|
11263
11418
|
mode: options.mode || mode,
|
|
@@ -11816,4 +11971,4 @@ var cliApi = /*#__PURE__*/Object.freeze({
|
|
|
11816
11971
|
startVitest: startVitest
|
|
11817
11972
|
});
|
|
11818
11973
|
|
|
11819
|
-
export { FilesNotFoundError as F, GitNotFoundError as G, TestSpecification as T,
|
|
11974
|
+
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 };
|