vitest 2.0.0-beta.12 → 2.0.0-beta.13
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 +0 -21
- package/dist/browser.d.ts +3 -2
- package/dist/browser.js +2 -2
- package/dist/chunks/{browser-creator.Bw94IHrL.js → browser-creator.DSqYDthP.js} +1 -1
- package/dist/chunks/{integrations-globals.DSNOaUHv.js → integrations-globals.CzYWb38r.js} +1 -1
- package/dist/chunks/{runtime-runBaseTests.BDt9gQFB.js → runtime-runBaseTests.DX3h28Mp.js} +9 -5
- package/dist/cli.js +2 -2
- package/dist/config.cjs +3 -2
- package/dist/config.d.ts +2 -1
- package/dist/config.js +3 -2
- package/dist/coverage.d.ts +2 -1
- package/dist/environments.d.ts +2 -1
- package/dist/execute.d.ts +4 -3
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/node.d.ts +18 -4
- package/dist/node.js +8 -8
- package/dist/{reporters-Cd1vkLMZ.d.ts → reporters-DrywOHjt.d.ts} +56 -19
- package/dist/reporters.d.ts +2 -1
- package/dist/reporters.js +2 -2
- package/dist/runners.d.ts +3 -1
- package/dist/runners.js +1 -0
- package/dist/{suite-BS2CV79a.d.ts → suite-CrOPuDIk.d.ts} +1 -1
- package/dist/suite.d.ts +3 -2
- package/dist/vendor/{base.Cy97mmVC.js → base.CdA1i5tB.js} +4 -3
- package/dist/vendor/{cac.DRNUX42m.js → cac.CpoEMnGk.js} +62 -15
- package/dist/vendor/{cli-api.Bu-PSdzx.js → cli-api.CXFLjKVN.js} +369 -97
- package/dist/vendor/{constants.BWsVtsAj.js → constants.CsnA4eRy.js} +1 -2
- package/dist/vendor/{execute.T3gg2ZK6.js → execute.Dx503nGn.js} +12 -4
- package/dist/vendor/{index.ZtQtNPP2.js → index.3x3MdmUV.js} +135 -78
- package/dist/vendor/{index.B7pSlOSa.js → index.CROIsoiT.js} +1 -1
- package/dist/vendor/{setup-common.CWnv_2-5.js → setup-common.yHaxjRhz.js} +1 -1
- package/dist/vendor/{utils.DSO2UK15.js → utils.BVMrsl6E.js} +15 -5
- package/dist/vendor/{vm.D9wVR14y.js → vm.BrDS6p7h.js} +6 -4
- package/dist/worker.js +11 -4
- package/dist/workers/forks.js +10 -4
- package/dist/workers/runVmTests.js +9 -5
- package/dist/workers/threads.js +6 -3
- package/dist/workers/vmForks.js +10 -4
- package/dist/workers/vmThreads.js +6 -3
- package/dist/workers.d.ts +7 -4
- package/dist/workers.js +4 -4
- package/package.json +12 -12
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import fs$8, { existsSync, promises as promises$1, statSync as statSync$1, realpathSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
1
2
|
import { join, resolve, isAbsolute, relative, dirname, normalize, basename, toNamespacedPath } from 'pathe';
|
|
2
|
-
import { A as API_PATH, e as extraInlineDeps, d as defaultPort, a as defaultBrowserPort, b as defaultInspectPort, E as EXIT_CODE_RESTART, w as workspacesFiles, C as CONFIG_NAMES, c as configFiles } from './constants.BWsVtsAj.js';
|
|
3
3
|
import { g as getCoverageProvider, C as CoverageProviderMap } from './coverage.BhYSDdTT.js';
|
|
4
4
|
import { g as getEnvPackageName } from './index.D4nqnQWz.js';
|
|
5
5
|
import { searchForWorkspaceRoot, version, createServer, mergeConfig } from 'vite';
|
|
6
6
|
import { f as findUp, p as prompt } from './index.D6GZqexG.js';
|
|
7
|
-
import
|
|
7
|
+
import { A as API_PATH, e as extraInlineDeps, d as defaultPort, a as defaultBrowserPort, b as defaultInspectPort, w as workspacesFiles, C as CONFIG_NAMES, c as configFiles } from './constants.CsnA4eRy.js';
|
|
8
8
|
import { MessageChannel, isMainThread } from 'node:worker_threads';
|
|
9
9
|
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
|
|
10
10
|
import require$$0 from 'os';
|
|
@@ -14,18 +14,17 @@ import { b as braces_1, p as picomatch$1, u as utils$d, m as mm } from './index.
|
|
|
14
14
|
import require$$0$2 from 'stream';
|
|
15
15
|
import require$$0$4 from 'events';
|
|
16
16
|
import require$$0$3 from 'fs';
|
|
17
|
-
import c from 'picocolors';
|
|
18
17
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
19
18
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
20
19
|
import { ViteNodeServer } from 'vite-node/server';
|
|
21
|
-
import { v as version$1 } from './cac.
|
|
22
|
-
import { hasFailed, createFileTask, getTasks, getTests } from '@vitest/runner/utils';
|
|
20
|
+
import { v as version$1 } from './cac.CpoEMnGk.js';
|
|
21
|
+
import { hasFailed, createFileTask, getTasks, getTests, getNames } from '@vitest/runner/utils';
|
|
23
22
|
import { n as noop$1, b as isPrimitive, c as groupBy, A as AggregateErrorPonyfill, a as slash$1, t as toArray, d as deepMerge, e as nanoid, w as wildcardPatternToRegExp, f as stdout } from './base.CTYV4Gnz.js';
|
|
24
23
|
import { createDefer, toArray as toArray$1, notNullish } from '@vitest/utils';
|
|
25
24
|
import { b as isWindows } from './env.2ltrQNq0.js';
|
|
26
25
|
import { rootDir, distDir } from '../path.js';
|
|
27
26
|
import { c as createBirpc } from './index.BpSiYbpB.js';
|
|
28
|
-
import { s as stringify, p as parse$3, w as wrapSerializableConfig, f as Typechecker, R as ReportersMap, d as BenchmarkReportsMap, g as RandomSequencer, e as BaseSequencer, h as findNodeAround, i as generateCodeFrame, j as highlightCode, L as Logger, k as BlobReporter, r as readBlobs } from './index.
|
|
27
|
+
import { s as stringify, p as parse$3, w as wrapSerializableConfig, f as Typechecker, R as ReportersMap, d as BenchmarkReportsMap, g as RandomSequencer, e as BaseSequencer, h as findNodeAround, i as generateCodeFrame, j as highlightCode, L as Logger, k as BlobReporter, r as readBlobs } from './index.3x3MdmUV.js';
|
|
29
28
|
import require$$0$5 from 'zlib';
|
|
30
29
|
import require$$0$6 from 'buffer';
|
|
31
30
|
import require$$1 from 'crypto';
|
|
@@ -48,13 +47,14 @@ import { builtinModules, createRequire } from 'node:module';
|
|
|
48
47
|
import url, { fileURLToPath as fileURLToPath$1, pathToFileURL as pathToFileURL$1, URL as URL$2 } from 'node:url';
|
|
49
48
|
import assert from 'node:assert';
|
|
50
49
|
import { format as format$2, inspect } from 'node:util';
|
|
50
|
+
import c from 'picocolors';
|
|
51
51
|
import { isCI, provider as provider$1 } from 'std-env';
|
|
52
52
|
import { normalizeRequestId, cleanUrl } from 'vite-node/utils';
|
|
53
53
|
import MagicString from 'magic-string';
|
|
54
54
|
import { esmWalker } from '@vitest/utils/ast';
|
|
55
55
|
import { a as removeUndefinedValues } from './index.BJmtb_7W.js';
|
|
56
56
|
import readline from 'node:readline';
|
|
57
|
-
import { s as stripAnsi } from './utils.
|
|
57
|
+
import { s as stripAnsi } from './utils.BVMrsl6E.js';
|
|
58
58
|
|
|
59
59
|
async function getModuleGraph(ctx, projectName, id, browser = false) {
|
|
60
60
|
const graph = {};
|
|
@@ -1971,15 +1971,15 @@ var reusify_1 = reusify$1;
|
|
|
1971
1971
|
|
|
1972
1972
|
var reusify = reusify_1;
|
|
1973
1973
|
|
|
1974
|
-
function fastqueue (context, worker,
|
|
1974
|
+
function fastqueue (context, worker, _concurrency) {
|
|
1975
1975
|
if (typeof context === 'function') {
|
|
1976
|
-
|
|
1976
|
+
_concurrency = worker;
|
|
1977
1977
|
worker = context;
|
|
1978
1978
|
context = null;
|
|
1979
1979
|
}
|
|
1980
1980
|
|
|
1981
|
-
if (
|
|
1982
|
-
throw new Error('fastqueue concurrency must be greater than 1')
|
|
1981
|
+
if (!(_concurrency >= 1)) {
|
|
1982
|
+
throw new Error('fastqueue concurrency must be equal to or greater than 1')
|
|
1983
1983
|
}
|
|
1984
1984
|
|
|
1985
1985
|
var cache = reusify(Task);
|
|
@@ -1994,7 +1994,23 @@ function fastqueue (context, worker, concurrency) {
|
|
|
1994
1994
|
saturated: noop,
|
|
1995
1995
|
pause: pause,
|
|
1996
1996
|
paused: false,
|
|
1997
|
-
|
|
1997
|
+
|
|
1998
|
+
get concurrency () {
|
|
1999
|
+
return _concurrency
|
|
2000
|
+
},
|
|
2001
|
+
set concurrency (value) {
|
|
2002
|
+
if (!(value >= 1)) {
|
|
2003
|
+
throw new Error('fastqueue concurrency must be equal to or greater than 1')
|
|
2004
|
+
}
|
|
2005
|
+
_concurrency = value;
|
|
2006
|
+
|
|
2007
|
+
if (self.paused) return
|
|
2008
|
+
for (; queueHead && _running < _concurrency;) {
|
|
2009
|
+
_running++;
|
|
2010
|
+
release();
|
|
2011
|
+
}
|
|
2012
|
+
},
|
|
2013
|
+
|
|
1998
2014
|
running: running,
|
|
1999
2015
|
resume: resume,
|
|
2000
2016
|
idle: idle,
|
|
@@ -2044,7 +2060,12 @@ function fastqueue (context, worker, concurrency) {
|
|
|
2044
2060
|
function resume () {
|
|
2045
2061
|
if (!self.paused) return
|
|
2046
2062
|
self.paused = false;
|
|
2047
|
-
|
|
2063
|
+
if (queueHead === null) {
|
|
2064
|
+
_running++;
|
|
2065
|
+
release();
|
|
2066
|
+
return
|
|
2067
|
+
}
|
|
2068
|
+
for (; queueHead && _running < _concurrency;) {
|
|
2048
2069
|
_running++;
|
|
2049
2070
|
release();
|
|
2050
2071
|
}
|
|
@@ -2063,7 +2084,7 @@ function fastqueue (context, worker, concurrency) {
|
|
|
2063
2084
|
current.callback = done || noop;
|
|
2064
2085
|
current.errorHandler = errorHandler;
|
|
2065
2086
|
|
|
2066
|
-
if (_running
|
|
2087
|
+
if (_running >= _concurrency || self.paused) {
|
|
2067
2088
|
if (queueTail) {
|
|
2068
2089
|
queueTail.next = current;
|
|
2069
2090
|
queueTail = current;
|
|
@@ -2085,8 +2106,9 @@ function fastqueue (context, worker, concurrency) {
|
|
|
2085
2106
|
current.release = release;
|
|
2086
2107
|
current.value = value;
|
|
2087
2108
|
current.callback = done || noop;
|
|
2109
|
+
current.errorHandler = errorHandler;
|
|
2088
2110
|
|
|
2089
|
-
if (_running
|
|
2111
|
+
if (_running >= _concurrency || self.paused) {
|
|
2090
2112
|
if (queueHead) {
|
|
2091
2113
|
current.next = queueHead;
|
|
2092
2114
|
queueHead = current;
|
|
@@ -2106,7 +2128,7 @@ function fastqueue (context, worker, concurrency) {
|
|
|
2106
2128
|
cache.release(holder);
|
|
2107
2129
|
}
|
|
2108
2130
|
var next = queueHead;
|
|
2109
|
-
if (next) {
|
|
2131
|
+
if (next && _running <= _concurrency) {
|
|
2110
2132
|
if (!self.paused) {
|
|
2111
2133
|
if (queueTail === queueHead) {
|
|
2112
2134
|
queueTail = null;
|
|
@@ -2169,9 +2191,9 @@ function Task () {
|
|
|
2169
2191
|
};
|
|
2170
2192
|
}
|
|
2171
2193
|
|
|
2172
|
-
function queueAsPromised (context, worker,
|
|
2194
|
+
function queueAsPromised (context, worker, _concurrency) {
|
|
2173
2195
|
if (typeof context === 'function') {
|
|
2174
|
-
|
|
2196
|
+
_concurrency = worker;
|
|
2175
2197
|
worker = context;
|
|
2176
2198
|
context = null;
|
|
2177
2199
|
}
|
|
@@ -2183,7 +2205,7 @@ function queueAsPromised (context, worker, concurrency) {
|
|
|
2183
2205
|
}, cb);
|
|
2184
2206
|
}
|
|
2185
2207
|
|
|
2186
|
-
var queue = fastqueue(context, asyncWrapper,
|
|
2208
|
+
var queue = fastqueue(context, asyncWrapper, _concurrency);
|
|
2187
2209
|
|
|
2188
2210
|
var pushCb = queue.push;
|
|
2189
2211
|
var unshiftCb = queue.unshift;
|
|
@@ -2233,6 +2255,12 @@ function queueAsPromised (context, worker, concurrency) {
|
|
|
2233
2255
|
}
|
|
2234
2256
|
|
|
2235
2257
|
function drained () {
|
|
2258
|
+
if (queue.idle()) {
|
|
2259
|
+
return new Promise(function (resolve) {
|
|
2260
|
+
resolve();
|
|
2261
|
+
})
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2236
2264
|
var previousDrain = queue.drain;
|
|
2237
2265
|
|
|
2238
2266
|
var p = new Promise(function (resolve) {
|
|
@@ -7949,13 +7977,15 @@ class WebSocketReporter {
|
|
|
7949
7977
|
packs.forEach(([taskId, result]) => {
|
|
7950
7978
|
var _a;
|
|
7951
7979
|
const project = this.ctx.getProjectByTaskId(taskId);
|
|
7952
|
-
const
|
|
7953
|
-
|
|
7954
|
-
};
|
|
7980
|
+
const task = this.ctx.state.idMap.get(taskId);
|
|
7981
|
+
const isBrowser = task && task.file.pool === "browser";
|
|
7955
7982
|
(_a = result == null ? void 0 : result.errors) == null ? void 0 : _a.forEach((error) => {
|
|
7956
|
-
|
|
7957
|
-
|
|
7983
|
+
var _a2;
|
|
7984
|
+
if (isPrimitive(error)) {
|
|
7985
|
+
return;
|
|
7958
7986
|
}
|
|
7987
|
+
const stacks = isBrowser ? (_a2 = project.browser) == null ? void 0 : _a2.parseErrorStacktrace(error) : parseErrorStacktrace(error);
|
|
7988
|
+
error.stacks = stacks;
|
|
7959
7989
|
});
|
|
7960
7990
|
});
|
|
7961
7991
|
this.clients.forEach((client) => {
|
|
@@ -8329,6 +8359,7 @@ function createForksPool(ctx, { execArgv, env }) {
|
|
|
8329
8359
|
return {
|
|
8330
8360
|
name: "forks",
|
|
8331
8361
|
runTests: runWithFiles("run"),
|
|
8362
|
+
collectTests: runWithFiles("collect"),
|
|
8332
8363
|
close: () => pool.destroy()
|
|
8333
8364
|
};
|
|
8334
8365
|
}
|
|
@@ -8531,6 +8562,7 @@ See https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker for t
|
|
|
8531
8562
|
return {
|
|
8532
8563
|
name: "threads",
|
|
8533
8564
|
runTests: runWithFiles("run"),
|
|
8565
|
+
collectTests: runWithFiles("collect"),
|
|
8534
8566
|
close: () => pool.destroy()
|
|
8535
8567
|
};
|
|
8536
8568
|
}
|
|
@@ -8727,6 +8759,7 @@ See https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker for t
|
|
|
8727
8759
|
return {
|
|
8728
8760
|
name: "vmThreads",
|
|
8729
8761
|
runTests: runWithFiles("run"),
|
|
8762
|
+
collectTests: runWithFiles("collect"),
|
|
8730
8763
|
close: () => pool.destroy()
|
|
8731
8764
|
};
|
|
8732
8765
|
}
|
|
@@ -8763,7 +8796,7 @@ function createTypecheckPool(ctx) {
|
|
|
8763
8796
|
(_a = promisesMap.get(project)) == null ? void 0 : _a.resolve();
|
|
8764
8797
|
rerunTriggered.set(project, false);
|
|
8765
8798
|
if (ctx.config.watch && !ctx.runningPromise) {
|
|
8766
|
-
await ctx.report("onFinished", files);
|
|
8799
|
+
await ctx.report("onFinished", files, []);
|
|
8767
8800
|
await ctx.report("onWatcherStart", files, [
|
|
8768
8801
|
...project.config.typecheck.ignoreSourceErrors ? [] : sourceErrors,
|
|
8769
8802
|
...ctx.state.getUnhandledErrors()
|
|
@@ -8798,10 +8831,28 @@ function createTypecheckPool(ctx) {
|
|
|
8798
8831
|
await ctx.report("onCollected");
|
|
8799
8832
|
});
|
|
8800
8833
|
await checker.prepare();
|
|
8801
|
-
await checker.collectTests();
|
|
8802
|
-
checker.start();
|
|
8803
8834
|
return checker;
|
|
8804
8835
|
}
|
|
8836
|
+
async function startTypechecker(project, files) {
|
|
8837
|
+
if (project.typechecker) {
|
|
8838
|
+
return project.typechecker;
|
|
8839
|
+
}
|
|
8840
|
+
const checker = await createWorkspaceTypechecker(project, files);
|
|
8841
|
+
await checker.collectTests();
|
|
8842
|
+
await checker.start();
|
|
8843
|
+
}
|
|
8844
|
+
async function collectTests(specs) {
|
|
8845
|
+
const specsByProject = groupBy(specs, ([project]) => project.getName());
|
|
8846
|
+
for (const name in specsByProject) {
|
|
8847
|
+
const project = specsByProject[name][0][0];
|
|
8848
|
+
const files = specsByProject[name].map(([_, file]) => file);
|
|
8849
|
+
const checker = await createWorkspaceTypechecker(project, files);
|
|
8850
|
+
checker.setFiles(files);
|
|
8851
|
+
await checker.collectTests();
|
|
8852
|
+
ctx.state.collectFiles(checker.getTestFiles());
|
|
8853
|
+
await ctx.report("onCollected");
|
|
8854
|
+
}
|
|
8855
|
+
}
|
|
8805
8856
|
async function runTests(specs) {
|
|
8806
8857
|
const specsByProject = groupBy(specs, ([project]) => project.getName());
|
|
8807
8858
|
const promises = [];
|
|
@@ -8830,13 +8881,14 @@ function createTypecheckPool(ctx) {
|
|
|
8830
8881
|
}
|
|
8831
8882
|
promises.push(promise);
|
|
8832
8883
|
promisesMap.set(project, promise);
|
|
8833
|
-
|
|
8884
|
+
startTypechecker(project, files);
|
|
8834
8885
|
}
|
|
8835
8886
|
await Promise.all(promises);
|
|
8836
8887
|
}
|
|
8837
8888
|
return {
|
|
8838
8889
|
name: "typescript",
|
|
8839
8890
|
runTests,
|
|
8891
|
+
collectTests,
|
|
8840
8892
|
async close() {
|
|
8841
8893
|
const promises = ctx.projects.map(
|
|
8842
8894
|
(project) => {
|
|
@@ -8979,6 +9031,7 @@ function createVmForksPool(ctx, { execArgv, env }) {
|
|
|
8979
9031
|
return {
|
|
8980
9032
|
name: "vmForks",
|
|
8981
9033
|
runTests: runWithFiles("run"),
|
|
9034
|
+
collectTests: runWithFiles("collect"),
|
|
8982
9035
|
close: () => pool.destroy()
|
|
8983
9036
|
};
|
|
8984
9037
|
}
|
|
@@ -9054,7 +9107,7 @@ function createPool(ctx) {
|
|
|
9054
9107
|
const execArgv = process.execArgv.filter(
|
|
9055
9108
|
(execArg) => execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir")
|
|
9056
9109
|
);
|
|
9057
|
-
async function
|
|
9110
|
+
async function executeTests(method, files, invalidate) {
|
|
9058
9111
|
const options = {
|
|
9059
9112
|
execArgv: [...execArgv, ...conditions],
|
|
9060
9113
|
env: {
|
|
@@ -9088,9 +9141,9 @@ function createPool(ctx) {
|
|
|
9088
9141
|
`Custom pool "${filepath}" should return an object with "name" property`
|
|
9089
9142
|
);
|
|
9090
9143
|
}
|
|
9091
|
-
if (typeof (poolInstance == null ? void 0 : poolInstance
|
|
9144
|
+
if (typeof (poolInstance == null ? void 0 : poolInstance[method]) !== "function") {
|
|
9092
9145
|
throw new TypeError(
|
|
9093
|
-
`Custom pool "${filepath}" should return an object with "
|
|
9146
|
+
`Custom pool "${filepath}" should return an object with "${method}" method`
|
|
9094
9147
|
);
|
|
9095
9148
|
}
|
|
9096
9149
|
customPools.set(filepath, poolInstance);
|
|
@@ -9136,24 +9189,25 @@ function createPool(ctx) {
|
|
|
9136
9189
|
if (pool in factories) {
|
|
9137
9190
|
const factory = factories[pool];
|
|
9138
9191
|
pools[pool] ?? (pools[pool] = factory());
|
|
9139
|
-
return pools[pool]
|
|
9192
|
+
return pools[pool][method](specs, invalidate);
|
|
9140
9193
|
}
|
|
9141
9194
|
if (pool === "browser") {
|
|
9142
9195
|
pools[pool] ?? (pools[pool] = await (async () => {
|
|
9143
9196
|
const { createBrowserPool } = await import('@vitest/browser');
|
|
9144
9197
|
return createBrowserPool(ctx);
|
|
9145
9198
|
})());
|
|
9146
|
-
return pools[pool]
|
|
9199
|
+
return pools[pool][method](specs, invalidate);
|
|
9147
9200
|
}
|
|
9148
9201
|
const poolHandler = await resolveCustomPool(pool);
|
|
9149
9202
|
pools[_a = poolHandler.name] ?? (pools[_a] = poolHandler);
|
|
9150
|
-
return poolHandler
|
|
9203
|
+
return poolHandler[method](specs, invalidate);
|
|
9151
9204
|
})
|
|
9152
9205
|
);
|
|
9153
9206
|
}
|
|
9154
9207
|
return {
|
|
9155
9208
|
name: "default",
|
|
9156
|
-
runTests,
|
|
9209
|
+
runTests: (files, invalidates) => executeTests("runTests", files, invalidates),
|
|
9210
|
+
collectTests: (files, invalidates) => executeTests("collectTests", files, invalidates),
|
|
9157
9211
|
async close() {
|
|
9158
9212
|
await Promise.all(Object.values(pools).map((p) => {
|
|
9159
9213
|
var _a;
|
|
@@ -11512,6 +11566,7 @@ const benchmarkConfigDefaults = {
|
|
|
11512
11566
|
const defaultCoverageExcludes = [
|
|
11513
11567
|
"coverage/**",
|
|
11514
11568
|
"dist/**",
|
|
11569
|
+
"**/node_modules/**",
|
|
11515
11570
|
"**/[.]**",
|
|
11516
11571
|
"packages/*/test?(s)/**",
|
|
11517
11572
|
"**/*.d.ts",
|
|
@@ -11521,9 +11576,9 @@ const defaultCoverageExcludes = [
|
|
|
11521
11576
|
"cypress/**",
|
|
11522
11577
|
"test?(s)/**",
|
|
11523
11578
|
"test?(-*).?(c|m)[jt]s?(x)",
|
|
11524
|
-
"**/*{.,-}{test,spec}?(-d).?(c|m)[jt]s?(x)",
|
|
11579
|
+
"**/*{.,-}{test,spec,bench,benchmark}?(-d).?(c|m)[jt]s?(x)",
|
|
11525
11580
|
"**/__tests__/**",
|
|
11526
|
-
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*",
|
|
11581
|
+
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*",
|
|
11527
11582
|
"**/vitest.{workspace,projects}.[jt]s?(on)",
|
|
11528
11583
|
"**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}"
|
|
11529
11584
|
];
|
|
@@ -11614,6 +11669,13 @@ const config = {
|
|
|
11614
11669
|
};
|
|
11615
11670
|
const configDefaults = Object.freeze(config);
|
|
11616
11671
|
|
|
11672
|
+
function getWorkersCountByPercentage(percent) {
|
|
11673
|
+
var _a, _b;
|
|
11674
|
+
const maxWorkersCount = ((_b = (_a = nodeos__default).availableParallelism) == null ? void 0 : _b.call(_a)) ?? nodeos__default.cpus().length;
|
|
11675
|
+
const workersCountByPercentage = Math.round(Number.parseInt(percent) / 100 * maxWorkersCount);
|
|
11676
|
+
return Math.max(1, Math.min(maxWorkersCount, workersCountByPercentage));
|
|
11677
|
+
}
|
|
11678
|
+
|
|
11617
11679
|
class FilesStatsCache {
|
|
11618
11680
|
cache = /* @__PURE__ */ new Map();
|
|
11619
11681
|
getStats(key) {
|
|
@@ -11799,8 +11861,15 @@ function resolveApiServerConfig(options, defaultPort2) {
|
|
|
11799
11861
|
}
|
|
11800
11862
|
return api;
|
|
11801
11863
|
}
|
|
11864
|
+
function resolveInlineWorkerOption(value) {
|
|
11865
|
+
if (typeof value === "string" && value.trim().endsWith("%")) {
|
|
11866
|
+
return getWorkersCountByPercentage(value);
|
|
11867
|
+
} else {
|
|
11868
|
+
return Number(value);
|
|
11869
|
+
}
|
|
11870
|
+
}
|
|
11802
11871
|
function resolveConfig(mode, options, viteConfig, logger) {
|
|
11803
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q;
|
|
11872
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U;
|
|
11804
11873
|
if (options.dom) {
|
|
11805
11874
|
if (((_a = viteConfig.test) == null ? void 0 : _a.environment) != null && viteConfig.test.environment !== "happy-dom") {
|
|
11806
11875
|
logger.console.warn(
|
|
@@ -11852,10 +11921,10 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
11852
11921
|
throw new Error(`Cannot merge reports with --watch enabled`);
|
|
11853
11922
|
}
|
|
11854
11923
|
if (resolved.maxWorkers) {
|
|
11855
|
-
resolved.maxWorkers =
|
|
11924
|
+
resolved.maxWorkers = resolveInlineWorkerOption(resolved.maxWorkers);
|
|
11856
11925
|
}
|
|
11857
11926
|
if (resolved.minWorkers) {
|
|
11858
|
-
resolved.minWorkers =
|
|
11927
|
+
resolved.minWorkers = resolveInlineWorkerOption(resolved.minWorkers);
|
|
11859
11928
|
}
|
|
11860
11929
|
resolved.browser ?? (resolved.browser = {});
|
|
11861
11930
|
resolved.fileParallelism ?? (resolved.fileParallelism = mode !== "benchmark");
|
|
@@ -12049,6 +12118,28 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12049
12118
|
}
|
|
12050
12119
|
};
|
|
12051
12120
|
}
|
|
12121
|
+
const poolThreadsOptions = [
|
|
12122
|
+
["threads", "minThreads"],
|
|
12123
|
+
["threads", "maxThreads"],
|
|
12124
|
+
["vmThreads", "minThreads"],
|
|
12125
|
+
["vmThreads", "maxThreads"]
|
|
12126
|
+
];
|
|
12127
|
+
for (const [poolOptionKey, workerOptionKey] of poolThreadsOptions) {
|
|
12128
|
+
if ((_C = (_B = resolved.poolOptions) == null ? void 0 : _B[poolOptionKey]) == null ? void 0 : _C[workerOptionKey]) {
|
|
12129
|
+
resolved.poolOptions[poolOptionKey][workerOptionKey] = resolveInlineWorkerOption(resolved.poolOptions[poolOptionKey][workerOptionKey]);
|
|
12130
|
+
}
|
|
12131
|
+
}
|
|
12132
|
+
const poolForksOptions = [
|
|
12133
|
+
["forks", "minForks"],
|
|
12134
|
+
["forks", "maxForks"],
|
|
12135
|
+
["vmForks", "minForks"],
|
|
12136
|
+
["vmForks", "maxForks"]
|
|
12137
|
+
];
|
|
12138
|
+
for (const [poolOptionKey, workerOptionKey] of poolForksOptions) {
|
|
12139
|
+
if ((_E = (_D = resolved.poolOptions) == null ? void 0 : _D[poolOptionKey]) == null ? void 0 : _E[workerOptionKey]) {
|
|
12140
|
+
resolved.poolOptions[poolOptionKey][workerOptionKey] = resolveInlineWorkerOption(resolved.poolOptions[poolOptionKey][workerOptionKey]);
|
|
12141
|
+
}
|
|
12142
|
+
}
|
|
12052
12143
|
if (resolved.workspace) {
|
|
12053
12144
|
resolved.workspace = options.workspace && options.workspace[0] === "." ? resolve(process.cwd(), options.workspace) : resolvePath(resolved.workspace, resolved.root);
|
|
12054
12145
|
}
|
|
@@ -12167,8 +12258,8 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12167
12258
|
}
|
|
12168
12259
|
resolved.css ?? (resolved.css = {});
|
|
12169
12260
|
if (typeof resolved.css === "object") {
|
|
12170
|
-
(
|
|
12171
|
-
(
|
|
12261
|
+
(_F = resolved.css).modules ?? (_F.modules = {});
|
|
12262
|
+
(_G = resolved.css.modules).classNameStrategy ?? (_G.classNameStrategy = "stable");
|
|
12172
12263
|
}
|
|
12173
12264
|
if (resolved.cache !== false) {
|
|
12174
12265
|
let cacheDir = VitestCache.resolveCacheDir(
|
|
@@ -12195,15 +12286,15 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12195
12286
|
resolved.sequence ?? (resolved.sequence = {});
|
|
12196
12287
|
if (resolved.sequence.shuffle && typeof resolved.sequence.shuffle === "object") {
|
|
12197
12288
|
const { files, tests } = resolved.sequence.shuffle;
|
|
12198
|
-
(
|
|
12289
|
+
(_H = resolved.sequence).sequencer ?? (_H.sequencer = files ? RandomSequencer : BaseSequencer);
|
|
12199
12290
|
resolved.sequence.shuffle = tests;
|
|
12200
12291
|
}
|
|
12201
|
-
if (!((
|
|
12292
|
+
if (!((_I = resolved.sequence) == null ? void 0 : _I.sequencer)) {
|
|
12202
12293
|
resolved.sequence.sequencer = resolved.sequence.shuffle ? RandomSequencer : BaseSequencer;
|
|
12203
12294
|
}
|
|
12204
|
-
(
|
|
12295
|
+
(_J = resolved.sequence).hooks ?? (_J.hooks = "stack");
|
|
12205
12296
|
if (resolved.sequence.sequencer === RandomSequencer) {
|
|
12206
|
-
(
|
|
12297
|
+
(_K = resolved.sequence).seed ?? (_K.seed = Date.now());
|
|
12207
12298
|
}
|
|
12208
12299
|
resolved.typecheck = {
|
|
12209
12300
|
...configDefaults.typecheck,
|
|
@@ -12213,7 +12304,7 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12213
12304
|
(i) => [resolve(resolved.root, i[0]), i[1]]
|
|
12214
12305
|
);
|
|
12215
12306
|
resolved.typecheck ?? (resolved.typecheck = {});
|
|
12216
|
-
(
|
|
12307
|
+
(_L = resolved.typecheck).enabled ?? (_L.enabled = false);
|
|
12217
12308
|
if (resolved.typecheck.enabled) {
|
|
12218
12309
|
logger.console.warn(
|
|
12219
12310
|
c.yellow(
|
|
@@ -12222,11 +12313,11 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12222
12313
|
);
|
|
12223
12314
|
}
|
|
12224
12315
|
resolved.browser ?? (resolved.browser = {});
|
|
12225
|
-
(
|
|
12226
|
-
(
|
|
12227
|
-
(
|
|
12228
|
-
(
|
|
12229
|
-
(
|
|
12316
|
+
(_M = resolved.browser).enabled ?? (_M.enabled = false);
|
|
12317
|
+
(_N = resolved.browser).headless ?? (_N.headless = isCI);
|
|
12318
|
+
(_O = resolved.browser).isolate ?? (_O.isolate = true);
|
|
12319
|
+
(_P = resolved.browser).fileParallelism ?? (_P.fileParallelism = options.fileParallelism ?? mode !== "benchmark");
|
|
12320
|
+
(_Q = resolved.browser).ui ?? (_Q.ui = resolved.browser.headless === true ? false : !isCI);
|
|
12230
12321
|
if (resolved.browser.screenshotDirectory) {
|
|
12231
12322
|
resolved.browser.screenshotDirectory = resolve(
|
|
12232
12323
|
resolved.root,
|
|
@@ -12244,11 +12335,11 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12244
12335
|
));
|
|
12245
12336
|
resolved.browser.screenshotFailures = false;
|
|
12246
12337
|
} else {
|
|
12247
|
-
(
|
|
12338
|
+
(_R = resolved.browser).screenshotFailures ?? (_R.screenshotFailures = !isPreview && !resolved.browser.ui);
|
|
12248
12339
|
}
|
|
12249
|
-
(
|
|
12250
|
-
(
|
|
12251
|
-
(
|
|
12340
|
+
(_S = resolved.browser).viewport ?? (_S.viewport = {});
|
|
12341
|
+
(_T = resolved.browser.viewport).width ?? (_T.width = 414);
|
|
12342
|
+
(_U = resolved.browser.viewport).height ?? (_U.height = 896);
|
|
12252
12343
|
if (resolved.browser.enabled && provider$1 === "stackblitz") {
|
|
12253
12344
|
resolved.browser.provider = "preview";
|
|
12254
12345
|
}
|
|
@@ -12258,6 +12349,22 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12258
12349
|
) || {
|
|
12259
12350
|
port: defaultBrowserPort
|
|
12260
12351
|
};
|
|
12352
|
+
if (resolved.browser.enabled) {
|
|
12353
|
+
if (resolved.browser.ui) {
|
|
12354
|
+
resolved.includeTaskLocation ?? (resolved.includeTaskLocation = true);
|
|
12355
|
+
}
|
|
12356
|
+
} else if (resolved.ui) {
|
|
12357
|
+
resolved.includeTaskLocation ?? (resolved.includeTaskLocation = true);
|
|
12358
|
+
}
|
|
12359
|
+
const htmlReporter = toArray(resolved.reporters).some((reporter) => {
|
|
12360
|
+
if (Array.isArray(reporter)) {
|
|
12361
|
+
return reporter[0] === "html";
|
|
12362
|
+
}
|
|
12363
|
+
return false;
|
|
12364
|
+
});
|
|
12365
|
+
if (htmlReporter) {
|
|
12366
|
+
resolved.includeTaskLocation ?? (resolved.includeTaskLocation = true);
|
|
12367
|
+
}
|
|
12261
12368
|
resolved.testTransformMode ?? (resolved.testTransformMode = {});
|
|
12262
12369
|
resolved.testTimeout ?? (resolved.testTimeout = resolved.browser.enabled ? 15e3 : 5e3);
|
|
12263
12370
|
resolved.hookTimeout ?? (resolved.hookTimeout = resolved.browser.enabled ? 3e4 : 1e4);
|
|
@@ -13545,7 +13652,7 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
13545
13652
|
this.meta.watchMode = false;
|
|
13546
13653
|
},
|
|
13547
13654
|
config(viteConfig) {
|
|
13548
|
-
var _a, _b, _c;
|
|
13655
|
+
var _a, _b, _c, _d;
|
|
13549
13656
|
const defines = deleteDefineConfig(viteConfig);
|
|
13550
13657
|
const testConfig = viteConfig.test || {};
|
|
13551
13658
|
const root = testConfig.root || viteConfig.root || options.root;
|
|
@@ -13573,7 +13680,9 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
13573
13680
|
alias: testConfig.alias,
|
|
13574
13681
|
conditions: ["node"]
|
|
13575
13682
|
},
|
|
13576
|
-
esbuild: {
|
|
13683
|
+
esbuild: viteConfig.esbuild === false ? false : {
|
|
13684
|
+
// Lowest target Vitest supports is Node18
|
|
13685
|
+
target: ((_a = viteConfig.esbuild) == null ? void 0 : _a.target) || "node18",
|
|
13577
13686
|
sourcemap: "external",
|
|
13578
13687
|
// Enables using ignore hint for coverage providers with @preserve keyword
|
|
13579
13688
|
legalComments: "inline"
|
|
@@ -13598,10 +13707,10 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
13598
13707
|
}
|
|
13599
13708
|
};
|
|
13600
13709
|
config.test.defines = defines;
|
|
13601
|
-
const classNameStrategy = typeof testConfig.css !== "boolean" && ((
|
|
13710
|
+
const classNameStrategy = typeof testConfig.css !== "boolean" && ((_c = (_b = testConfig.css) == null ? void 0 : _b.modules) == null ? void 0 : _c.classNameStrategy) || "stable";
|
|
13602
13711
|
if (classNameStrategy !== "scoped") {
|
|
13603
13712
|
config.css ?? (config.css = {});
|
|
13604
|
-
(
|
|
13713
|
+
(_d = config.css).modules ?? (_d.modules = {});
|
|
13605
13714
|
if (config.css.modules) {
|
|
13606
13715
|
config.css.modules.generateScopedName = (name2, filename) => {
|
|
13607
13716
|
const root2 = project.config.root;
|
|
@@ -13957,12 +14066,12 @@ class WorkspaceProject {
|
|
|
13957
14066
|
isBrowserEnabled() {
|
|
13958
14067
|
return isBrowserEnabled(this.config);
|
|
13959
14068
|
}
|
|
13960
|
-
getSerializableConfig() {
|
|
14069
|
+
getSerializableConfig(method = "run") {
|
|
13961
14070
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
13962
14071
|
const optimizer = (_a = this.config.deps) == null ? void 0 : _a.optimizer;
|
|
13963
14072
|
const poolOptions = this.config.poolOptions;
|
|
13964
14073
|
const isolate = (_d = (_c = (_b = this.server) == null ? void 0 : _b.config) == null ? void 0 : _c.test) == null ? void 0 : _d.isolate;
|
|
13965
|
-
|
|
14074
|
+
const config = deepMerge(
|
|
13966
14075
|
{
|
|
13967
14076
|
...this.config,
|
|
13968
14077
|
poolOptions: {
|
|
@@ -14024,6 +14133,15 @@ class WorkspaceProject {
|
|
|
14024
14133
|
},
|
|
14025
14134
|
this.ctx.configOverride || {}
|
|
14026
14135
|
);
|
|
14136
|
+
if (method === "collect") {
|
|
14137
|
+
config.coverage.enabled = false;
|
|
14138
|
+
if (config.browser.provider && config.browser.provider !== "preview") {
|
|
14139
|
+
config.browser.headless = true;
|
|
14140
|
+
}
|
|
14141
|
+
config.snapshotSerializers = [];
|
|
14142
|
+
config.diff = void 0;
|
|
14143
|
+
}
|
|
14144
|
+
return config;
|
|
14027
14145
|
}
|
|
14028
14146
|
close() {
|
|
14029
14147
|
var _a, _b;
|
|
@@ -14099,13 +14217,26 @@ Package ${dependency} installed, re-run the command to start.
|
|
|
14099
14217
|
`
|
|
14100
14218
|
)
|
|
14101
14219
|
);
|
|
14102
|
-
process.exit(
|
|
14220
|
+
process.exit();
|
|
14103
14221
|
return true;
|
|
14104
14222
|
}
|
|
14105
14223
|
return false;
|
|
14106
14224
|
}
|
|
14107
14225
|
}
|
|
14108
14226
|
|
|
14227
|
+
class FilesNotFoundError extends Error {
|
|
14228
|
+
code = "VITEST_FILES_NOT_FOUND";
|
|
14229
|
+
constructor(mode) {
|
|
14230
|
+
super(`No ${mode} files found`);
|
|
14231
|
+
}
|
|
14232
|
+
}
|
|
14233
|
+
class GitNotFoundError extends Error {
|
|
14234
|
+
code = "VITEST_GIT_NOT_FOUND";
|
|
14235
|
+
constructor() {
|
|
14236
|
+
super("Could not find Git root. Have you initialized git with `git init`?");
|
|
14237
|
+
}
|
|
14238
|
+
}
|
|
14239
|
+
|
|
14109
14240
|
const WATCHER_DEBOUNCE = 100;
|
|
14110
14241
|
class Vitest {
|
|
14111
14242
|
constructor(mode, options = {}) {
|
|
@@ -14444,6 +14575,21 @@ class Vitest {
|
|
|
14444
14575
|
await this.initCoverageProvider();
|
|
14445
14576
|
await ((_b = (_a = this.coverageProvider) == null ? void 0 : _a.mergeReports) == null ? void 0 : _b.call(_a, coverages));
|
|
14446
14577
|
}
|
|
14578
|
+
async collect(filters) {
|
|
14579
|
+
this._onClose = [];
|
|
14580
|
+
await this.initBrowserProviders();
|
|
14581
|
+
const files = await this.filterTestsBySource(
|
|
14582
|
+
await this.globTestFiles(filters)
|
|
14583
|
+
);
|
|
14584
|
+
if (!files.length) {
|
|
14585
|
+
return { tests: [], errors: [] };
|
|
14586
|
+
}
|
|
14587
|
+
await this.collectFiles(files);
|
|
14588
|
+
return {
|
|
14589
|
+
tests: this.state.getFiles(),
|
|
14590
|
+
errors: this.state.getUnhandledErrors()
|
|
14591
|
+
};
|
|
14592
|
+
}
|
|
14447
14593
|
async start(filters) {
|
|
14448
14594
|
var _a, _b, _c, _d;
|
|
14449
14595
|
this._onClose = [];
|
|
@@ -14463,7 +14609,8 @@ class Vitest {
|
|
|
14463
14609
|
this.logger.printNoTestFound(filters);
|
|
14464
14610
|
if (!this.config.watch || !(this.config.changed || ((_d = this.config.related) == null ? void 0 : _d.length))) {
|
|
14465
14611
|
const exitCode = this.config.passWithNoTests ? 0 : 1;
|
|
14466
|
-
process.
|
|
14612
|
+
process.exitCode = exitCode;
|
|
14613
|
+
throw new FilesNotFoundError(this.mode);
|
|
14467
14614
|
}
|
|
14468
14615
|
}
|
|
14469
14616
|
if (files.length) {
|
|
@@ -14521,8 +14668,8 @@ class Vitest {
|
|
|
14521
14668
|
changedSince: this.config.changed
|
|
14522
14669
|
});
|
|
14523
14670
|
if (!related2) {
|
|
14524
|
-
|
|
14525
|
-
|
|
14671
|
+
process.exitCode = 1;
|
|
14672
|
+
throw new GitNotFoundError();
|
|
14526
14673
|
}
|
|
14527
14674
|
this.config.related = Array.from(new Set(related2));
|
|
14528
14675
|
}
|
|
@@ -14624,6 +14771,38 @@ class Vitest {
|
|
|
14624
14771
|
});
|
|
14625
14772
|
return await this.runningPromise;
|
|
14626
14773
|
}
|
|
14774
|
+
async collectFiles(specs) {
|
|
14775
|
+
await this.initializeDistPath();
|
|
14776
|
+
const filepaths = specs.map(([, file]) => file);
|
|
14777
|
+
this.state.collectPaths(filepaths);
|
|
14778
|
+
await this.runningPromise;
|
|
14779
|
+
this._onCancelListeners = [];
|
|
14780
|
+
this.isCancelling = false;
|
|
14781
|
+
this.runningPromise = (async () => {
|
|
14782
|
+
if (!this.pool) {
|
|
14783
|
+
this.pool = createPool(this);
|
|
14784
|
+
}
|
|
14785
|
+
const invalidates = Array.from(this.invalidates);
|
|
14786
|
+
this.invalidates.clear();
|
|
14787
|
+
this.snapshot.clear();
|
|
14788
|
+
this.state.clearErrors();
|
|
14789
|
+
await this.initializeGlobalSetup(specs);
|
|
14790
|
+
try {
|
|
14791
|
+
await this.pool.collectTests(specs, invalidates);
|
|
14792
|
+
} catch (err) {
|
|
14793
|
+
this.state.catchError(err, "Unhandled Error");
|
|
14794
|
+
}
|
|
14795
|
+
const files = this.state.getFiles();
|
|
14796
|
+
if (hasFailed(files)) {
|
|
14797
|
+
process.exitCode = 1;
|
|
14798
|
+
}
|
|
14799
|
+
})().finally(async () => {
|
|
14800
|
+
this.runningPromise = void 0;
|
|
14801
|
+
this.config.changed = false;
|
|
14802
|
+
this.config.related = void 0;
|
|
14803
|
+
});
|
|
14804
|
+
return await this.runningPromise;
|
|
14805
|
+
}
|
|
14627
14806
|
async cancelCurrentRun(reason) {
|
|
14628
14807
|
this.isCancelling = true;
|
|
14629
14808
|
await Promise.all(this._onCancelListeners.splice(0).map((listener) => listener(reason)));
|
|
@@ -14998,7 +15177,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
14998
15177
|
this.meta.watchMode = false;
|
|
14999
15178
|
},
|
|
15000
15179
|
async config(viteConfig) {
|
|
15001
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
15180
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
15002
15181
|
if (options.watch) {
|
|
15003
15182
|
options = deepMerge({}, userConfig);
|
|
15004
15183
|
}
|
|
@@ -15018,6 +15197,8 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
15018
15197
|
const config = {
|
|
15019
15198
|
root: ((_a = viteConfig.test) == null ? void 0 : _a.root) || options.root,
|
|
15020
15199
|
esbuild: viteConfig.esbuild === false ? false : {
|
|
15200
|
+
// Lowest target Vitest supports is Node18
|
|
15201
|
+
target: ((_b = viteConfig.esbuild) == null ? void 0 : _b.target) || "node18",
|
|
15021
15202
|
sourcemap: "external",
|
|
15022
15203
|
// Enables using ignore hint for coverage providers with @preserve keyword
|
|
15023
15204
|
legalComments: "inline"
|
|
@@ -15050,20 +15231,25 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
15050
15231
|
test: {
|
|
15051
15232
|
poolOptions: {
|
|
15052
15233
|
threads: {
|
|
15053
|
-
isolate: ((
|
|
15234
|
+
isolate: ((_d = (_c = options.poolOptions) == null ? void 0 : _c.threads) == null ? void 0 : _d.isolate) ?? options.isolate ?? ((_f = (_e = testConfig.poolOptions) == null ? void 0 : _e.threads) == null ? void 0 : _f.isolate) ?? ((_g = viteConfig.test) == null ? void 0 : _g.isolate)
|
|
15054
15235
|
},
|
|
15055
15236
|
forks: {
|
|
15056
|
-
isolate: ((
|
|
15237
|
+
isolate: ((_i = (_h = options.poolOptions) == null ? void 0 : _h.forks) == null ? void 0 : _i.isolate) ?? options.isolate ?? ((_k = (_j = testConfig.poolOptions) == null ? void 0 : _j.forks) == null ? void 0 : _k.isolate) ?? ((_l = viteConfig.test) == null ? void 0 : _l.isolate)
|
|
15057
15238
|
}
|
|
15058
15239
|
}
|
|
15059
15240
|
}
|
|
15060
15241
|
};
|
|
15061
|
-
if (((
|
|
15062
|
-
|
|
15242
|
+
if (((_m = userConfig.coverage) == null ? void 0 : _m.enabled) && !userConfig.coverage.exclude && userConfig.include && config.test) {
|
|
15243
|
+
config.test.coverage = {
|
|
15244
|
+
exclude: [...coverageConfigDefaults.exclude, ...userConfig.include]
|
|
15245
|
+
};
|
|
15246
|
+
}
|
|
15247
|
+
if (((_n = viteConfig.ssr) == null ? void 0 : _n.noExternal) !== true) {
|
|
15248
|
+
const inline = (_p = (_o = testConfig.server) == null ? void 0 : _o.deps) == null ? void 0 : _p.inline;
|
|
15063
15249
|
if (inline === true) {
|
|
15064
15250
|
config.ssr = { noExternal: true };
|
|
15065
15251
|
} else {
|
|
15066
|
-
const noExternal = (
|
|
15252
|
+
const noExternal = (_q = viteConfig.ssr) == null ? void 0 : _q.noExternal;
|
|
15067
15253
|
const noExternalArray = typeof noExternal !== "undefined" ? toArray(noExternal) : void 0;
|
|
15068
15254
|
const uniqueInline = inline && noExternalArray ? inline.filter((dep) => !noExternalArray.includes(dep)) : inline;
|
|
15069
15255
|
config.ssr = {
|
|
@@ -15078,10 +15264,10 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
15078
15264
|
watch.usePolling = false;
|
|
15079
15265
|
}
|
|
15080
15266
|
}
|
|
15081
|
-
const classNameStrategy = typeof testConfig.css !== "boolean" && ((
|
|
15267
|
+
const classNameStrategy = typeof testConfig.css !== "boolean" && ((_s = (_r = testConfig.css) == null ? void 0 : _r.modules) == null ? void 0 : _s.classNameStrategy) || "stable";
|
|
15082
15268
|
if (classNameStrategy !== "scoped") {
|
|
15083
15269
|
config.css ?? (config.css = {});
|
|
15084
|
-
(
|
|
15270
|
+
(_t = config.css).modules ?? (_t.modules = {});
|
|
15085
15271
|
if (config.css.modules) {
|
|
15086
15272
|
config.css.modules.generateScopedName = (name, filename) => {
|
|
15087
15273
|
const root = getRoot();
|
|
@@ -15497,21 +15683,13 @@ function registerConsoleShortcuts(ctx, stdin = process.stdin, stdout2) {
|
|
|
15497
15683
|
}
|
|
15498
15684
|
|
|
15499
15685
|
async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, vitestOptions) {
|
|
15500
|
-
var _a, _b, _c;
|
|
15501
|
-
process.env.TEST = "true";
|
|
15502
|
-
process.env.VITEST = "true";
|
|
15503
|
-
(_a = process.env).NODE_ENV ?? (_a.NODE_ENV = "test");
|
|
15504
|
-
if (options.run) {
|
|
15505
|
-
options.watch = false;
|
|
15506
|
-
}
|
|
15507
15686
|
const root = resolve(options.root || process.cwd());
|
|
15508
|
-
|
|
15509
|
-
|
|
15510
|
-
|
|
15511
|
-
|
|
15512
|
-
|
|
15513
|
-
|
|
15514
|
-
const ctx = await createVitest(mode, options, viteOverrides, vitestOptions);
|
|
15687
|
+
const ctx = await prepareVitest(
|
|
15688
|
+
mode,
|
|
15689
|
+
options,
|
|
15690
|
+
viteOverrides,
|
|
15691
|
+
vitestOptions
|
|
15692
|
+
);
|
|
15515
15693
|
if (mode === "test" && ctx.config.coverage.enabled) {
|
|
15516
15694
|
const provider = ctx.config.coverage.provider || "v8";
|
|
15517
15695
|
const requiredPackages = CoverageProviderMap[provider];
|
|
@@ -15522,11 +15700,6 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, v
|
|
|
15522
15700
|
}
|
|
15523
15701
|
}
|
|
15524
15702
|
}
|
|
15525
|
-
const environmentPackage = getEnvPackageName(ctx.config.environment);
|
|
15526
|
-
if (environmentPackage && !await ctx.packageInstaller.ensureInstalled(environmentPackage, root)) {
|
|
15527
|
-
process.exitCode = 1;
|
|
15528
|
-
return ctx;
|
|
15529
|
-
}
|
|
15530
15703
|
const stdin = (vitestOptions == null ? void 0 : vitestOptions.stdin) || process.stdin;
|
|
15531
15704
|
const stdout = (vitestOptions == null ? void 0 : vitestOptions.stdout) || process.stdout;
|
|
15532
15705
|
let stdinCleanup;
|
|
@@ -15535,9 +15708,6 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, v
|
|
|
15535
15708
|
}
|
|
15536
15709
|
ctx.onServerRestart((reason) => {
|
|
15537
15710
|
ctx.report("onServerRestart", reason);
|
|
15538
|
-
if (process.env.VITEST_CLI_WRAPPER) {
|
|
15539
|
-
process.exit(EXIT_CODE_RESTART);
|
|
15540
|
-
}
|
|
15541
15711
|
});
|
|
15542
15712
|
ctx.onAfterSetServer(() => {
|
|
15543
15713
|
if (ctx.config.standalone) {
|
|
@@ -15555,6 +15725,13 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, v
|
|
|
15555
15725
|
await ctx.start(cliFilters);
|
|
15556
15726
|
}
|
|
15557
15727
|
} catch (e) {
|
|
15728
|
+
if (e instanceof FilesNotFoundError) {
|
|
15729
|
+
return ctx;
|
|
15730
|
+
}
|
|
15731
|
+
if (e instanceof GitNotFoundError) {
|
|
15732
|
+
ctx.logger.error(e.message);
|
|
15733
|
+
return ctx;
|
|
15734
|
+
}
|
|
15558
15735
|
process.exitCode = 1;
|
|
15559
15736
|
ctx.logger.printError(e, { fullStack: true, type: "Unhandled Error" });
|
|
15560
15737
|
ctx.logger.error("\n\n");
|
|
@@ -15567,10 +15744,105 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, v
|
|
|
15567
15744
|
await ctx.close();
|
|
15568
15745
|
return ctx;
|
|
15569
15746
|
}
|
|
15747
|
+
async function prepareVitest(mode, options = {}, viteOverrides, vitestOptions) {
|
|
15748
|
+
var _a, _b, _c;
|
|
15749
|
+
process.env.TEST = "true";
|
|
15750
|
+
process.env.VITEST = "true";
|
|
15751
|
+
(_a = process.env).NODE_ENV ?? (_a.NODE_ENV = "test");
|
|
15752
|
+
if (options.run) {
|
|
15753
|
+
options.watch = false;
|
|
15754
|
+
}
|
|
15755
|
+
const root = resolve(options.root || process.cwd());
|
|
15756
|
+
if (typeof options.browser === "object" && !("enabled" in options.browser)) {
|
|
15757
|
+
options.browser.enabled = true;
|
|
15758
|
+
}
|
|
15759
|
+
if (typeof ((_b = options.typecheck) == null ? void 0 : _b.only) === "boolean") {
|
|
15760
|
+
(_c = options.typecheck).enabled ?? (_c.enabled = true);
|
|
15761
|
+
}
|
|
15762
|
+
const ctx = await createVitest(mode, options, viteOverrides, vitestOptions);
|
|
15763
|
+
const environmentPackage = getEnvPackageName(ctx.config.environment);
|
|
15764
|
+
if (environmentPackage && !await ctx.packageInstaller.ensureInstalled(environmentPackage, root)) {
|
|
15765
|
+
process.exitCode = 1;
|
|
15766
|
+
return ctx;
|
|
15767
|
+
}
|
|
15768
|
+
return ctx;
|
|
15769
|
+
}
|
|
15770
|
+
function processCollected(ctx, files, options) {
|
|
15771
|
+
let errorsPrinted = false;
|
|
15772
|
+
forEachSuite(files, (suite) => {
|
|
15773
|
+
var _a;
|
|
15774
|
+
const errors = ((_a = suite.result) == null ? void 0 : _a.errors) || [];
|
|
15775
|
+
errors.forEach((error) => {
|
|
15776
|
+
errorsPrinted = true;
|
|
15777
|
+
ctx.logger.printError(error, {
|
|
15778
|
+
project: ctx.getProjectByName(suite.file.projectName)
|
|
15779
|
+
});
|
|
15780
|
+
});
|
|
15781
|
+
});
|
|
15782
|
+
if (errorsPrinted) {
|
|
15783
|
+
return;
|
|
15784
|
+
}
|
|
15785
|
+
if (typeof options.json !== "undefined") {
|
|
15786
|
+
return processJsonOutput(files, options);
|
|
15787
|
+
}
|
|
15788
|
+
return formatCollectedAsString(files).forEach((test) => console.log(test));
|
|
15789
|
+
}
|
|
15790
|
+
function processJsonOutput(files, options) {
|
|
15791
|
+
if (typeof options.json === "boolean") {
|
|
15792
|
+
return console.log(JSON.stringify(formatCollectedAsJSON(files), null, 2));
|
|
15793
|
+
}
|
|
15794
|
+
if (typeof options.json === "string") {
|
|
15795
|
+
const jsonPath = resolve(options.root || process.cwd(), options.json);
|
|
15796
|
+
mkdirSync(dirname(jsonPath), { recursive: true });
|
|
15797
|
+
writeFileSync(jsonPath, JSON.stringify(formatCollectedAsJSON(files), null, 2));
|
|
15798
|
+
}
|
|
15799
|
+
}
|
|
15800
|
+
function forEachSuite(tasks, callback) {
|
|
15801
|
+
tasks.forEach((task) => {
|
|
15802
|
+
if (task.type === "suite") {
|
|
15803
|
+
callback(task);
|
|
15804
|
+
forEachSuite(task.tasks, callback);
|
|
15805
|
+
}
|
|
15806
|
+
});
|
|
15807
|
+
}
|
|
15808
|
+
function formatCollectedAsJSON(files) {
|
|
15809
|
+
return files.map((file) => {
|
|
15810
|
+
const tests = getTests(file).filter((test) => test.mode === "run" || test.mode === "only");
|
|
15811
|
+
return tests.map((test) => {
|
|
15812
|
+
const result = {
|
|
15813
|
+
name: getNames(test).slice(1).join(" > "),
|
|
15814
|
+
file: file.filepath
|
|
15815
|
+
};
|
|
15816
|
+
if (test.file.projectName) {
|
|
15817
|
+
result.projectName = test.file.projectName;
|
|
15818
|
+
}
|
|
15819
|
+
if (test.location) {
|
|
15820
|
+
result.location = test.location;
|
|
15821
|
+
}
|
|
15822
|
+
return result;
|
|
15823
|
+
});
|
|
15824
|
+
}).flat();
|
|
15825
|
+
}
|
|
15826
|
+
function formatCollectedAsString(files) {
|
|
15827
|
+
return files.map((file) => {
|
|
15828
|
+
const tests = getTests(file).filter((test) => test.mode === "run" || test.mode === "only");
|
|
15829
|
+
return tests.map((test) => {
|
|
15830
|
+
const name = getNames(test).join(" > ");
|
|
15831
|
+
if (test.file.projectName) {
|
|
15832
|
+
return `[${test.file.projectName}] ${name}`;
|
|
15833
|
+
}
|
|
15834
|
+
return name;
|
|
15835
|
+
});
|
|
15836
|
+
}).flat();
|
|
15837
|
+
}
|
|
15570
15838
|
|
|
15571
15839
|
var cliApi = /*#__PURE__*/Object.freeze({
|
|
15572
15840
|
__proto__: null,
|
|
15841
|
+
formatCollectedAsJSON: formatCollectedAsJSON,
|
|
15842
|
+
formatCollectedAsString: formatCollectedAsString,
|
|
15843
|
+
prepareVitest: prepareVitest,
|
|
15844
|
+
processCollected: processCollected,
|
|
15573
15845
|
startVitest: startVitest
|
|
15574
15846
|
});
|
|
15575
15847
|
|
|
15576
|
-
export { VitestPlugin as V, createMethodsRPC as a, VitestPackageInstaller as b, createVitest as c, resolveFsAllow as d, resolveApiServerConfig as e, resolveConfig as f, getFilePoolName as g, cliApi as h, registerConsoleShortcuts as r, startVitest as s };
|
|
15848
|
+
export { FilesNotFoundError as F, GitNotFoundError as G, VitestPlugin as V, createMethodsRPC as a, VitestPackageInstaller as b, createVitest as c, resolveFsAllow as d, resolveApiServerConfig as e, resolveConfig as f, getFilePoolName as g, cliApi as h, registerConsoleShortcuts as r, startVitest as s };
|