vitest 1.3.1 → 1.5.0
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/dist/browser.d.ts +4 -1
- package/dist/browser.js +1 -1
- package/dist/chunks/{integrations-globals.THajbSRg.js → integrations-globals.2J_Aii2q.js} +4 -4
- package/dist/chunks/{runtime-console.Iloo9fIt.js → runtime-console.kbFEN7E-.js} +16 -8
- package/dist/chunks/{runtime-runBaseTests.9RbsHRbU.js → runtime-runBaseTests.3fVSWBsC.js} +12 -10
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +7 -7
- package/dist/config.cjs +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -0
- package/dist/coverage.d.ts +1 -1
- package/dist/environments.d.ts +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -4
- package/dist/node.d.ts +2 -2
- package/dist/node.js +7 -7
- package/dist/{reporters-MmQN-57K.d.ts → reporters-LqC_WI4d.d.ts} +233 -173
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +4 -4
- package/dist/runners.d.ts +2 -1
- package/dist/runners.js +10 -5
- package/dist/{suite-UrZdHRff.d.ts → suite-ynYMzeLu.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +6 -0
- package/dist/vendor/{base.Z38YsPLm.js → base.BjeeYg4o.js} +2 -2
- package/dist/vendor/{base.N3JkKp7j.js → base.Xt0Omgh7.js} +9 -3
- package/dist/vendor/{cac.wWT9ELdg.js → cac.qnW6GNL2.js} +258 -129
- package/dist/vendor/{constants.K-Wf1PUy.js → constants.5J7I254_.js} +2 -1
- package/dist/vendor/{execute.27Kk4lQF.js → execute.2_yoIC01.js} +1 -1
- package/dist/vendor/{index.9hqYxJUw.js → index.-ITFwqG_.js} +1 -1
- package/dist/vendor/{index.JZMafwT-.js → index.12jbrDSD.js} +1 -1
- package/dist/vendor/{index.c1V_jzyZ.js → index.kSaPvGW6.js} +69 -26
- package/dist/vendor/inspector.IgLX3ur5.js +54 -0
- package/dist/vendor/{setup-common.snyQUvE3.js → setup-common.A1De6efh.js} +8 -1
- package/dist/vendor/utils.0uYuCbzo.js +49 -0
- package/dist/vendor/{vi.C5mroSoP.js → vi.Fxjax7rQ.js} +37 -21
- package/dist/vendor/{vm.o1IruPAo.js → vm.I_IsyNig.js} +3 -3
- package/dist/worker.js +4 -26
- package/dist/workers/forks.js +5 -5
- package/dist/workers/runVmTests.js +11 -5
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +10 -10
- package/dist/workers/vmThreads.js +9 -9
- package/dist/workers.d.ts +6 -3
- package/dist/workers.js +10 -9
- package/package.json +12 -12
- package/dist/vendor/utils.GbToHGHI.js +0 -41
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { dirname, resolve, relative, normalize, join, basename, toNamespacedPath } from 'pathe';
|
|
1
|
+
import { dirname, resolve, relative, normalize, join, basename, toNamespacedPath, isAbsolute } from 'pathe';
|
|
2
2
|
import require$$0$3, { EventEmitter as EventEmitter$2 } from 'events';
|
|
3
3
|
import c from 'picocolors';
|
|
4
4
|
import { b as removeUndefinedValues, c as isWindows } from './index.ir9i0ywP.js';
|
|
5
|
-
import { f as Typechecker, R as ReportersMap, e as BenchmarkReportsMap, g as RandomSequencer, B as BaseSequencer, h as generateCodeFrame, i as highlightCode, j as divider, L as Logger, s as stripAnsi } from './index.
|
|
6
|
-
import { A as API_PATH, c as configFiles, d as defaultPort, e as extraInlineDeps, a as defaultBrowserPort, E as EXIT_CODE_RESTART, w as workspacesFiles, C as CONFIG_NAMES } from './constants.
|
|
5
|
+
import { w as wrapSerializableConfig, f as Typechecker, R as ReportersMap, e as BenchmarkReportsMap, g as RandomSequencer, B as BaseSequencer, h as generateCodeFrame, i as highlightCode, j as divider, L as Logger, s as stripAnsi } from './index.kSaPvGW6.js';
|
|
6
|
+
import { A as API_PATH, c as configFiles, d as defaultPort, e as extraInlineDeps, a as defaultBrowserPort, b as defaultInspectPort, E as EXIT_CODE_RESTART, w as workspacesFiles, C as CONFIG_NAMES } from './constants.5J7I254_.js';
|
|
7
7
|
import { g as getCoverageProvider, C as CoverageProviderMap } from './coverage.E7sG1b3r.js';
|
|
8
8
|
import { g as getEnvPackageName } from './index.GVFv9dZ0.js';
|
|
9
9
|
import { isFileServingAllowed, loadConfigFromFile, searchForWorkspaceRoot, version as version$1, createServer, mergeConfig } from 'vite';
|
|
@@ -11,6 +11,7 @@ import path$8 from 'node:path';
|
|
|
11
11
|
import url, { fileURLToPath } from 'node:url';
|
|
12
12
|
import process$1 from 'node:process';
|
|
13
13
|
import fs$8, { promises, existsSync } from 'node:fs';
|
|
14
|
+
import { MessageChannel, isMainThread } from 'node:worker_threads';
|
|
14
15
|
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers.jjO7Zipk.js';
|
|
15
16
|
import require$$0 from 'os';
|
|
16
17
|
import p from 'path';
|
|
@@ -32,13 +33,12 @@ import require$$4 from 'tls';
|
|
|
32
33
|
import require$$7 from 'url';
|
|
33
34
|
import { createDefer, toArray as toArray$1, notNullish } from '@vitest/utils';
|
|
34
35
|
import { parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
35
|
-
import { b as isPrimitive, c as groupBy, A as AggregateErrorPonyfill, a as slash$1, t as toArray, d as deepMerge,
|
|
36
|
+
import { n as noop$2, b as isPrimitive, c as groupBy, A as AggregateErrorPonyfill, a as slash$1, t as toArray, d as deepMerge, w as wildcardPatternToRegExp, e as stdout } from './base.Xt0Omgh7.js';
|
|
36
37
|
import v8 from 'node:v8';
|
|
37
38
|
import * as nodeos from 'node:os';
|
|
38
39
|
import nodeos__default from 'node:os';
|
|
39
40
|
import EventEmitter$3 from 'node:events';
|
|
40
41
|
import Tinypool$1, { Tinypool } from 'tinypool';
|
|
41
|
-
import { MessageChannel } from 'node:worker_threads';
|
|
42
42
|
import { hasFailed, getTests } from '@vitest/runner/utils';
|
|
43
43
|
import { resolveModule, isPackageExists } from 'local-pkg';
|
|
44
44
|
import { isCI, provider as provider$1 } from 'std-env';
|
|
@@ -728,7 +728,7 @@ class CAC extends EventEmitter$2 {
|
|
|
728
728
|
|
|
729
729
|
const cac = (name = "") => new CAC(name);
|
|
730
730
|
|
|
731
|
-
var version = "1.
|
|
731
|
+
var version = "1.5.0";
|
|
732
732
|
|
|
733
733
|
/*
|
|
734
734
|
How it works:
|
|
@@ -8327,6 +8327,13 @@ function setup(vitestOrWorkspace, _server) {
|
|
|
8327
8327
|
getConfig() {
|
|
8328
8328
|
return vitestOrWorkspace.config;
|
|
8329
8329
|
},
|
|
8330
|
+
async getBrowserFileSourceMap(id) {
|
|
8331
|
+
var _a2, _b;
|
|
8332
|
+
if (!("ctx" in vitestOrWorkspace))
|
|
8333
|
+
return void 0;
|
|
8334
|
+
const mod = (_a2 = vitestOrWorkspace.browser) == null ? void 0 : _a2.moduleGraph.getModuleById(id);
|
|
8335
|
+
return (_b = mod == null ? void 0 : mod.transformResult) == null ? void 0 : _b.map;
|
|
8336
|
+
},
|
|
8330
8337
|
async getTransformResult(id) {
|
|
8331
8338
|
const result = await ctx.vitenode.transformRequest(id);
|
|
8332
8339
|
if (result) {
|
|
@@ -8377,7 +8384,7 @@ function setup(vitestOrWorkspace, _server) {
|
|
|
8377
8384
|
{
|
|
8378
8385
|
post: (msg) => ws.send(msg),
|
|
8379
8386
|
on: (fn) => ws.on("message", fn),
|
|
8380
|
-
eventNames: ["onUserConsoleLog", "onFinished", "onFinishedReportCoverage", "onCollected", "onCancel"],
|
|
8387
|
+
eventNames: ["onUserConsoleLog", "onFinished", "onFinishedReportCoverage", "onCollected", "onCancel", "onTaskUpdate"],
|
|
8381
8388
|
serialize: (data) => stringify(data, stringifyReplace),
|
|
8382
8389
|
deserialize: parse$3,
|
|
8383
8390
|
onTimeoutError(functionName) {
|
|
@@ -8403,8 +8410,8 @@ class WebSocketReporter {
|
|
|
8403
8410
|
if (this.clients.size === 0)
|
|
8404
8411
|
return;
|
|
8405
8412
|
this.clients.forEach((client) => {
|
|
8406
|
-
var _a;
|
|
8407
|
-
(_a = client.onCollected) == null ? void 0 : _a.call(client, files);
|
|
8413
|
+
var _a, _b, _c;
|
|
8414
|
+
(_c = (_b = (_a = client.onCollected) == null ? void 0 : _a.call(client, files)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$2);
|
|
8408
8415
|
});
|
|
8409
8416
|
}
|
|
8410
8417
|
async onTaskUpdate(packs) {
|
|
@@ -8422,26 +8429,26 @@ class WebSocketReporter {
|
|
|
8422
8429
|
});
|
|
8423
8430
|
});
|
|
8424
8431
|
this.clients.forEach((client) => {
|
|
8425
|
-
var _a;
|
|
8426
|
-
(_a = client.onTaskUpdate) == null ? void 0 : _a.call(client, packs);
|
|
8432
|
+
var _a, _b, _c;
|
|
8433
|
+
(_c = (_b = (_a = client.onTaskUpdate) == null ? void 0 : _a.call(client, packs)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$2);
|
|
8427
8434
|
});
|
|
8428
8435
|
}
|
|
8429
8436
|
onFinished(files, errors) {
|
|
8430
8437
|
this.clients.forEach((client) => {
|
|
8431
|
-
var _a;
|
|
8432
|
-
(_a = client.onFinished) == null ? void 0 : _a.call(client, files, errors);
|
|
8438
|
+
var _a, _b, _c;
|
|
8439
|
+
(_c = (_b = (_a = client.onFinished) == null ? void 0 : _a.call(client, files, errors)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$2);
|
|
8433
8440
|
});
|
|
8434
8441
|
}
|
|
8435
8442
|
onFinishedReportCoverage() {
|
|
8436
8443
|
this.clients.forEach((client) => {
|
|
8437
|
-
var _a;
|
|
8438
|
-
(_a = client.onFinishedReportCoverage) == null ? void 0 : _a.call(client);
|
|
8444
|
+
var _a, _b, _c;
|
|
8445
|
+
(_c = (_b = (_a = client.onFinishedReportCoverage) == null ? void 0 : _a.call(client)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$2);
|
|
8439
8446
|
});
|
|
8440
8447
|
}
|
|
8441
8448
|
onUserConsoleLog(log) {
|
|
8442
8449
|
this.clients.forEach((client) => {
|
|
8443
|
-
var _a;
|
|
8444
|
-
(_a = client.onUserConsoleLog) == null ? void 0 : _a.call(client, log);
|
|
8450
|
+
var _a, _b, _c;
|
|
8451
|
+
(_c = (_b = (_a = client.onUserConsoleLog) == null ? void 0 : _a.call(client, log)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$2);
|
|
8445
8452
|
});
|
|
8446
8453
|
}
|
|
8447
8454
|
}
|
|
@@ -8586,11 +8593,6 @@ function createChildProcessChannel$1(project) {
|
|
|
8586
8593
|
project.ctx.onCancel((reason) => rpc.onCancel(reason));
|
|
8587
8594
|
return { channel, cleanup };
|
|
8588
8595
|
}
|
|
8589
|
-
function stringifyRegex$1(input) {
|
|
8590
|
-
if (typeof input === "string")
|
|
8591
|
-
return input;
|
|
8592
|
-
return `$$vitest:${input.toString()}`;
|
|
8593
|
-
}
|
|
8594
8596
|
function createForksPool(ctx, { execArgv, env }) {
|
|
8595
8597
|
var _a;
|
|
8596
8598
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
@@ -8657,11 +8659,7 @@ function createForksPool(ctx, { execArgv, env }) {
|
|
|
8657
8659
|
if (configs.has(project))
|
|
8658
8660
|
return configs.get(project);
|
|
8659
8661
|
const _config = project.getSerializableConfig();
|
|
8660
|
-
const config =
|
|
8661
|
-
..._config,
|
|
8662
|
-
// v8 serialize does not support regex
|
|
8663
|
-
testNamePattern: _config.testNamePattern ? stringifyRegex$1(_config.testNamePattern) : void 0
|
|
8664
|
-
};
|
|
8662
|
+
const config = wrapSerializableConfig(_config);
|
|
8665
8663
|
configs.set(project, config);
|
|
8666
8664
|
return config;
|
|
8667
8665
|
};
|
|
@@ -9242,11 +9240,6 @@ function createChildProcessChannel(project) {
|
|
|
9242
9240
|
project.ctx.onCancel((reason) => rpc.onCancel(reason));
|
|
9243
9241
|
return { channel, cleanup };
|
|
9244
9242
|
}
|
|
9245
|
-
function stringifyRegex(input) {
|
|
9246
|
-
if (typeof input === "string")
|
|
9247
|
-
return input;
|
|
9248
|
-
return `$$vitest:${input.toString()}`;
|
|
9249
|
-
}
|
|
9250
9243
|
function createVmForksPool(ctx, { execArgv, env }) {
|
|
9251
9244
|
var _a;
|
|
9252
9245
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
@@ -9315,11 +9308,7 @@ function createVmForksPool(ctx, { execArgv, env }) {
|
|
|
9315
9308
|
if (configs.has(project))
|
|
9316
9309
|
return configs.get(project);
|
|
9317
9310
|
const _config = project.getSerializableConfig();
|
|
9318
|
-
const config =
|
|
9319
|
-
..._config,
|
|
9320
|
-
// v8 serialize does not support regex
|
|
9321
|
-
testNamePattern: _config.testNamePattern ? stringifyRegex(_config.testNamePattern) : void 0
|
|
9322
|
-
};
|
|
9311
|
+
const config = wrapSerializableConfig(_config);
|
|
9323
9312
|
configs.set(project, config);
|
|
9324
9313
|
return config;
|
|
9325
9314
|
};
|
|
@@ -9706,6 +9695,7 @@ const coverageConfigDefaults = {
|
|
|
9706
9695
|
reporter: [["text", {}], ["html", {}], ["clover", {}], ["json", {}]],
|
|
9707
9696
|
extension: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte", ".marko"],
|
|
9708
9697
|
allowExternal: false,
|
|
9698
|
+
ignoreEmptyLines: false,
|
|
9709
9699
|
processingConcurrency: Math.min(20, ((_b = (_a = nodeos__default).availableParallelism) == null ? void 0 : _b.call(_a)) ?? nodeos__default.cpus().length)
|
|
9710
9700
|
};
|
|
9711
9701
|
const fakeTimersDefaults = {
|
|
@@ -9871,7 +9861,7 @@ class VitestCache {
|
|
|
9871
9861
|
return this.stats.getStats(key);
|
|
9872
9862
|
}
|
|
9873
9863
|
static resolveCacheDir(root, dir, projectName) {
|
|
9874
|
-
const baseDir = slash$1(dir || "node_modules/.vitest");
|
|
9864
|
+
const baseDir = slash$1(dir || "node_modules/.vite/vitest");
|
|
9875
9865
|
return projectName ? resolve(root, baseDir, crypto.createHash("md5").update(projectName, "utf-8").digest("hex")) : resolve(root, baseDir);
|
|
9876
9866
|
}
|
|
9877
9867
|
static async clearCache(options) {
|
|
@@ -9898,6 +9888,18 @@ function resolvePath(path, root) {
|
|
|
9898
9888
|
resolveModule(path, { paths: [root] }) ?? resolve(root, path)
|
|
9899
9889
|
);
|
|
9900
9890
|
}
|
|
9891
|
+
function parseInspector(inspect) {
|
|
9892
|
+
if (typeof inspect === "boolean" || inspect === void 0)
|
|
9893
|
+
return {};
|
|
9894
|
+
if (typeof inspect === "number")
|
|
9895
|
+
return { port: inspect };
|
|
9896
|
+
if (inspect.match(/https?:\//))
|
|
9897
|
+
throw new Error(`Inspector host cannot be a URL. Use "host:port" instead of "${inspect}"`);
|
|
9898
|
+
const [host, port] = inspect.split(":");
|
|
9899
|
+
if (!port)
|
|
9900
|
+
return { host };
|
|
9901
|
+
return { host, port: Number(port) || defaultInspectPort };
|
|
9902
|
+
}
|
|
9901
9903
|
function resolveApiServerConfig(options) {
|
|
9902
9904
|
let api;
|
|
9903
9905
|
if (options.ui && !options.api)
|
|
@@ -9927,7 +9929,7 @@ function resolveApiServerConfig(options) {
|
|
|
9927
9929
|
return api;
|
|
9928
9930
|
}
|
|
9929
9931
|
function resolveConfig(mode, options, viteConfig) {
|
|
9930
|
-
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;
|
|
9932
|
+
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;
|
|
9931
9933
|
if (options.dom) {
|
|
9932
9934
|
if (((_a = viteConfig.test) == null ? void 0 : _a.environment) != null && viteConfig.test.environment !== "happy-dom") {
|
|
9933
9935
|
console.warn(
|
|
@@ -9944,10 +9946,16 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
9944
9946
|
root: viteConfig.root,
|
|
9945
9947
|
mode
|
|
9946
9948
|
};
|
|
9947
|
-
resolved.inspect
|
|
9948
|
-
resolved.
|
|
9949
|
+
const inspector = resolved.inspect || resolved.inspectBrk;
|
|
9950
|
+
resolved.inspector = {
|
|
9951
|
+
...resolved.inspector,
|
|
9952
|
+
...parseInspector(inspector),
|
|
9953
|
+
enabled: !!inspector,
|
|
9954
|
+
waitForDebugger: ((_b = options.inspector) == null ? void 0 : _b.waitForDebugger) ?? !!resolved.inspectBrk
|
|
9955
|
+
};
|
|
9949
9956
|
if (viteConfig.base !== "/")
|
|
9950
9957
|
resolved.base = viteConfig.base;
|
|
9958
|
+
resolved.clearScreen = resolved.clearScreen ?? viteConfig.clearScreen ?? true;
|
|
9951
9959
|
if (options.shard) {
|
|
9952
9960
|
if (resolved.watch)
|
|
9953
9961
|
throw new Error("You cannot use --shard option with enabled watch");
|
|
@@ -9964,14 +9972,14 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
9964
9972
|
resolved.maxWorkers = Number(resolved.maxWorkers);
|
|
9965
9973
|
if (resolved.minWorkers)
|
|
9966
9974
|
resolved.minWorkers = Number(resolved.minWorkers);
|
|
9967
|
-
resolved.fileParallelism ?? (resolved.fileParallelism =
|
|
9975
|
+
resolved.fileParallelism ?? (resolved.fileParallelism = mode !== "benchmark");
|
|
9968
9976
|
if (!resolved.fileParallelism) {
|
|
9969
9977
|
resolved.maxWorkers = 1;
|
|
9970
9978
|
resolved.minWorkers = 1;
|
|
9971
9979
|
}
|
|
9972
9980
|
if (resolved.inspect || resolved.inspectBrk) {
|
|
9973
|
-
const isSingleThread = resolved.pool === "threads" && ((
|
|
9974
|
-
const isSingleFork = resolved.pool === "forks" && ((
|
|
9981
|
+
const isSingleThread = resolved.pool === "threads" && ((_d = (_c = resolved.poolOptions) == null ? void 0 : _c.threads) == null ? void 0 : _d.singleThread);
|
|
9982
|
+
const isSingleFork = resolved.pool === "forks" && ((_f = (_e = resolved.poolOptions) == null ? void 0 : _e.forks) == null ? void 0 : _f.singleFork);
|
|
9975
9983
|
if (resolved.fileParallelism && !isSingleThread && !isSingleFork) {
|
|
9976
9984
|
const inspectOption = `--inspect${resolved.inspectBrk ? "-brk" : ""}`;
|
|
9977
9985
|
throw new Error(`You cannot use ${inspectOption} without "--no-file-parallelism", "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
|
|
@@ -9981,8 +9989,13 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
9981
9989
|
throw new Error('"coverage.provider: c8" is not supported anymore. Use "coverage.provider: v8" instead');
|
|
9982
9990
|
if (resolved.coverage.provider === "v8" && resolved.coverage.enabled && isBrowserEnabled(resolved))
|
|
9983
9991
|
throw new Error("@vitest/coverage-v8 does not work with --browser. Use @vitest/coverage-istanbul instead");
|
|
9992
|
+
if (resolved.coverage.enabled && resolved.coverage.reportsDirectory) {
|
|
9993
|
+
const reportsDirectory = resolve(resolved.root, resolved.coverage.reportsDirectory);
|
|
9994
|
+
if (reportsDirectory === resolved.root || reportsDirectory === process.cwd())
|
|
9995
|
+
throw new Error(`You cannot set "coverage.reportsDirectory" as ${reportsDirectory}. Vitest needs to be able to remove this directory before test run`);
|
|
9996
|
+
}
|
|
9984
9997
|
resolved.deps ?? (resolved.deps = {});
|
|
9985
|
-
(
|
|
9998
|
+
(_g = resolved.deps).moduleDirectories ?? (_g.moduleDirectories = []);
|
|
9986
9999
|
resolved.deps.moduleDirectories = resolved.deps.moduleDirectories.map((dir) => {
|
|
9987
10000
|
if (!dir.startsWith("/"))
|
|
9988
10001
|
dir = `/${dir}`;
|
|
@@ -9992,17 +10005,17 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
9992
10005
|
});
|
|
9993
10006
|
if (!resolved.deps.moduleDirectories.includes("/node_modules/"))
|
|
9994
10007
|
resolved.deps.moduleDirectories.push("/node_modules/");
|
|
9995
|
-
(
|
|
9996
|
-
(
|
|
9997
|
-
(
|
|
9998
|
-
(
|
|
9999
|
-
(
|
|
10000
|
-
(
|
|
10001
|
-
(
|
|
10002
|
-
(
|
|
10003
|
-
(
|
|
10008
|
+
(_h = resolved.deps).optimizer ?? (_h.optimizer = {});
|
|
10009
|
+
(_i = resolved.deps.optimizer).ssr ?? (_i.ssr = {});
|
|
10010
|
+
(_j = resolved.deps.optimizer.ssr).enabled ?? (_j.enabled = true);
|
|
10011
|
+
(_k = resolved.deps.optimizer).web ?? (_k.web = {});
|
|
10012
|
+
(_l = resolved.deps.optimizer.web).enabled ?? (_l.enabled = true);
|
|
10013
|
+
(_m = resolved.deps).web ?? (_m.web = {});
|
|
10014
|
+
(_n = resolved.deps.web).transformAssets ?? (_n.transformAssets = true);
|
|
10015
|
+
(_o = resolved.deps.web).transformCss ?? (_o.transformCss = true);
|
|
10016
|
+
(_p = resolved.deps.web).transformGlobPattern ?? (_p.transformGlobPattern = []);
|
|
10004
10017
|
resolved.server ?? (resolved.server = {});
|
|
10005
|
-
(
|
|
10018
|
+
(_q = resolved.server).deps ?? (_q.deps = {});
|
|
10006
10019
|
const deprecatedDepsOptions = ["inline", "external", "fallbackCJS"];
|
|
10007
10020
|
deprecatedDepsOptions.forEach((option) => {
|
|
10008
10021
|
if (resolved.deps[option] === void 0)
|
|
@@ -10027,11 +10040,11 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10027
10040
|
if ((ssrOptions == null ? void 0 : ssrOptions.noExternal) === true && resolved.server.deps.inline == null) {
|
|
10028
10041
|
resolved.server.deps.inline = true;
|
|
10029
10042
|
} else {
|
|
10030
|
-
(
|
|
10043
|
+
(_r = resolved.server.deps).inline ?? (_r.inline = []);
|
|
10031
10044
|
resolved.server.deps.inline.push(...extraInlineDeps);
|
|
10032
10045
|
}
|
|
10033
10046
|
}
|
|
10034
|
-
(
|
|
10047
|
+
(_s = resolved.server.deps).moduleDirectories ?? (_s.moduleDirectories = []);
|
|
10035
10048
|
resolved.server.deps.moduleDirectories.push(...resolved.deps.moduleDirectories);
|
|
10036
10049
|
if (resolved.runner)
|
|
10037
10050
|
resolved.runner = resolvePath(resolved.runner, resolved.root);
|
|
@@ -10059,11 +10072,11 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10059
10072
|
resolved.poolOptions = {
|
|
10060
10073
|
...resolved.poolOptions,
|
|
10061
10074
|
threads: {
|
|
10062
|
-
...(
|
|
10075
|
+
...(_t = resolved.poolOptions) == null ? void 0 : _t.threads,
|
|
10063
10076
|
maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
|
|
10064
10077
|
},
|
|
10065
10078
|
vmThreads: {
|
|
10066
|
-
...(
|
|
10079
|
+
...(_u = resolved.poolOptions) == null ? void 0 : _u.vmThreads,
|
|
10067
10080
|
maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
|
|
10068
10081
|
}
|
|
10069
10082
|
};
|
|
@@ -10072,11 +10085,11 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10072
10085
|
resolved.poolOptions = {
|
|
10073
10086
|
...resolved.poolOptions,
|
|
10074
10087
|
threads: {
|
|
10075
|
-
...(
|
|
10088
|
+
...(_v = resolved.poolOptions) == null ? void 0 : _v.threads,
|
|
10076
10089
|
minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
|
|
10077
10090
|
},
|
|
10078
10091
|
vmThreads: {
|
|
10079
|
-
...(
|
|
10092
|
+
...(_w = resolved.poolOptions) == null ? void 0 : _w.vmThreads,
|
|
10080
10093
|
minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
|
|
10081
10094
|
}
|
|
10082
10095
|
};
|
|
@@ -10085,11 +10098,11 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10085
10098
|
resolved.poolOptions = {
|
|
10086
10099
|
...resolved.poolOptions,
|
|
10087
10100
|
forks: {
|
|
10088
|
-
...(
|
|
10101
|
+
...(_x = resolved.poolOptions) == null ? void 0 : _x.forks,
|
|
10089
10102
|
maxForks: Number.parseInt(process.env.VITEST_MAX_FORKS)
|
|
10090
10103
|
},
|
|
10091
10104
|
vmForks: {
|
|
10092
|
-
...(
|
|
10105
|
+
...(_y = resolved.poolOptions) == null ? void 0 : _y.vmForks,
|
|
10093
10106
|
maxForks: Number.parseInt(process.env.VITEST_MAX_FORKS)
|
|
10094
10107
|
}
|
|
10095
10108
|
};
|
|
@@ -10098,11 +10111,11 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10098
10111
|
resolved.poolOptions = {
|
|
10099
10112
|
...resolved.poolOptions,
|
|
10100
10113
|
forks: {
|
|
10101
|
-
...(
|
|
10114
|
+
...(_z = resolved.poolOptions) == null ? void 0 : _z.forks,
|
|
10102
10115
|
minForks: Number.parseInt(process.env.VITEST_MIN_FORKS)
|
|
10103
10116
|
},
|
|
10104
10117
|
vmForks: {
|
|
10105
|
-
...(
|
|
10118
|
+
...(_A = resolved.poolOptions) == null ? void 0 : _A.vmForks,
|
|
10106
10119
|
minForks: Number.parseInt(process.env.VITEST_MIN_FORKS)
|
|
10107
10120
|
}
|
|
10108
10121
|
};
|
|
@@ -10194,33 +10207,47 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10194
10207
|
resolved.passWithNoTests ?? (resolved.passWithNoTests = true);
|
|
10195
10208
|
resolved.css ?? (resolved.css = {});
|
|
10196
10209
|
if (typeof resolved.css === "object") {
|
|
10197
|
-
(
|
|
10198
|
-
(
|
|
10210
|
+
(_B = resolved.css).modules ?? (_B.modules = {});
|
|
10211
|
+
(_C = resolved.css.modules).classNameStrategy ?? (_C.classNameStrategy = "stable");
|
|
10212
|
+
}
|
|
10213
|
+
if (resolved.cache !== false) {
|
|
10214
|
+
let cacheDir = VitestCache.resolveCacheDir("", resolve(viteConfig.cacheDir, "vitest"), resolved.name);
|
|
10215
|
+
if (resolved.cache && resolved.cache.dir) {
|
|
10216
|
+
console.warn(
|
|
10217
|
+
c.yellow(
|
|
10218
|
+
`${c.inverse(c.yellow(" Vitest "))} "cache.dir" is deprecated, use Vite's "cacheDir" instead if you want to change the cache director. Note caches will be written to "cacheDir/vitest"`
|
|
10219
|
+
)
|
|
10220
|
+
);
|
|
10221
|
+
cacheDir = VitestCache.resolveCacheDir(resolved.root, resolved.cache.dir, resolved.name);
|
|
10222
|
+
}
|
|
10223
|
+
resolved.cache = { dir: cacheDir };
|
|
10199
10224
|
}
|
|
10200
|
-
resolved.cache ?? (resolved.cache = { dir: "" });
|
|
10201
|
-
if (resolved.cache)
|
|
10202
|
-
resolved.cache.dir = VitestCache.resolveCacheDir(resolved.root, resolved.cache.dir, resolved.name);
|
|
10203
10225
|
resolved.sequence ?? (resolved.sequence = {});
|
|
10204
|
-
if (
|
|
10226
|
+
if (resolved.sequence.shuffle && typeof resolved.sequence.shuffle === "object") {
|
|
10227
|
+
const { files, tests } = resolved.sequence.shuffle;
|
|
10228
|
+
(_D = resolved.sequence).sequencer ?? (_D.sequencer = files ? RandomSequencer : BaseSequencer);
|
|
10229
|
+
resolved.sequence.shuffle = tests;
|
|
10230
|
+
}
|
|
10231
|
+
if (!((_E = resolved.sequence) == null ? void 0 : _E.sequencer)) {
|
|
10205
10232
|
resolved.sequence.sequencer = resolved.sequence.shuffle ? RandomSequencer : BaseSequencer;
|
|
10206
10233
|
}
|
|
10207
|
-
(
|
|
10234
|
+
(_F = resolved.sequence).hooks ?? (_F.hooks = "parallel");
|
|
10208
10235
|
if (resolved.sequence.sequencer === RandomSequencer)
|
|
10209
|
-
(
|
|
10236
|
+
(_G = resolved.sequence).seed ?? (_G.seed = Date.now());
|
|
10210
10237
|
resolved.typecheck = {
|
|
10211
10238
|
...configDefaults.typecheck,
|
|
10212
10239
|
...resolved.typecheck
|
|
10213
10240
|
};
|
|
10214
10241
|
resolved.environmentMatchGlobs = (resolved.environmentMatchGlobs || []).map((i) => [resolve(resolved.root, i[0]), i[1]]);
|
|
10215
10242
|
resolved.typecheck ?? (resolved.typecheck = {});
|
|
10216
|
-
(
|
|
10243
|
+
(_H = resolved.typecheck).enabled ?? (_H.enabled = false);
|
|
10217
10244
|
if (resolved.typecheck.enabled)
|
|
10218
10245
|
console.warn(c.yellow("Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
|
|
10219
10246
|
resolved.browser ?? (resolved.browser = {});
|
|
10220
|
-
(
|
|
10221
|
-
(
|
|
10222
|
-
(
|
|
10223
|
-
(
|
|
10247
|
+
(_I = resolved.browser).enabled ?? (_I.enabled = false);
|
|
10248
|
+
(_J = resolved.browser).headless ?? (_J.headless = isCI);
|
|
10249
|
+
(_K = resolved.browser).slowHijackESM ?? (_K.slowHijackESM = false);
|
|
10250
|
+
(_L = resolved.browser).isolate ?? (_L.isolate = true);
|
|
10224
10251
|
if (resolved.browser.enabled && provider$1 === "stackblitz")
|
|
10225
10252
|
resolved.browser.provider = "none";
|
|
10226
10253
|
resolved.browser.api = resolveApiServerConfig(resolved.browser) || {
|
|
@@ -10974,24 +11001,40 @@ async function loadGlobalSetupFile(file, runner) {
|
|
|
10974
11001
|
}
|
|
10975
11002
|
|
|
10976
11003
|
async function initializeProject(workspacePath, ctx, options) {
|
|
10977
|
-
var _a;
|
|
10978
11004
|
const project = new WorkspaceProject(workspacePath, ctx, options);
|
|
10979
11005
|
const configFile = options.extends ? resolve(dirname(options.workspaceConfigPath), options.extends) : typeof workspacePath === "number" || workspacePath.endsWith("/") ? false : workspacePath;
|
|
10980
11006
|
const root = options.root || (typeof workspacePath === "number" ? void 0 : workspacePath.endsWith("/") ? workspacePath : dirname(workspacePath));
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
|
|
10986
|
-
|
|
10987
|
-
|
|
10988
|
-
|
|
10989
|
-
|
|
10990
|
-
|
|
10991
|
-
|
|
10992
|
-
|
|
10993
|
-
|
|
10994
|
-
|
|
11007
|
+
return new Promise((resolve2, reject) => {
|
|
11008
|
+
var _a;
|
|
11009
|
+
const resolution = createDefer();
|
|
11010
|
+
let configResolved = false;
|
|
11011
|
+
const config = {
|
|
11012
|
+
...options,
|
|
11013
|
+
root,
|
|
11014
|
+
logLevel: "error",
|
|
11015
|
+
configFile,
|
|
11016
|
+
// this will make "mode": "test" | "benchmark" inside defineConfig
|
|
11017
|
+
mode: ((_a = options.test) == null ? void 0 : _a.mode) || options.mode || ctx.config.mode,
|
|
11018
|
+
plugins: [
|
|
11019
|
+
{
|
|
11020
|
+
name: "vitest:workspace:resolve",
|
|
11021
|
+
configResolved() {
|
|
11022
|
+
configResolved = true;
|
|
11023
|
+
resolve2(() => resolution);
|
|
11024
|
+
}
|
|
11025
|
+
},
|
|
11026
|
+
...options.plugins || [],
|
|
11027
|
+
WorkspaceVitestPlugin(project, { ...options, root, workspacePath })
|
|
11028
|
+
]
|
|
11029
|
+
};
|
|
11030
|
+
createViteServer(config).then(() => resolution.resolve(project)).catch((err) => {
|
|
11031
|
+
if (configResolved)
|
|
11032
|
+
resolution.reject(err);
|
|
11033
|
+
else
|
|
11034
|
+
reject(err);
|
|
11035
|
+
});
|
|
11036
|
+
return project;
|
|
11037
|
+
});
|
|
10995
11038
|
}
|
|
10996
11039
|
class WorkspaceProject {
|
|
10997
11040
|
constructor(path, ctx, options) {
|
|
@@ -11153,7 +11196,7 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
11153
11196
|
isInSourceTestFile(code) {
|
|
11154
11197
|
return code.includes("import.meta.vitest");
|
|
11155
11198
|
}
|
|
11156
|
-
filterFiles(testFiles, filters
|
|
11199
|
+
filterFiles(testFiles, filters, dir) {
|
|
11157
11200
|
if (filters.length && process.platform === "win32")
|
|
11158
11201
|
filters = filters.map((f) => toNamespacedPath(f));
|
|
11159
11202
|
if (filters.length) {
|
|
@@ -11161,6 +11204,10 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
11161
11204
|
const testFile = relative(dir, t).toLocaleLowerCase();
|
|
11162
11205
|
return filters.some((f) => {
|
|
11163
11206
|
const relativePath = f.endsWith("/") ? join(relative(dir, f), "/") : relative(dir, f);
|
|
11207
|
+
if (isAbsolute(f)) {
|
|
11208
|
+
if (relativePath === ".." || relativePath === "../" || relativePath.startsWith("../.."))
|
|
11209
|
+
return true;
|
|
11210
|
+
}
|
|
11164
11211
|
return testFile.includes(f.toLocaleLowerCase()) || testFile.includes(relativePath.toLocaleLowerCase());
|
|
11165
11212
|
});
|
|
11166
11213
|
});
|
|
@@ -11188,7 +11235,14 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
11188
11235
|
return project;
|
|
11189
11236
|
}
|
|
11190
11237
|
async setServer(options, server) {
|
|
11191
|
-
this.config = resolveConfig(
|
|
11238
|
+
this.config = resolveConfig(
|
|
11239
|
+
this.ctx.mode,
|
|
11240
|
+
{
|
|
11241
|
+
...options,
|
|
11242
|
+
coverage: this.ctx.config.coverage
|
|
11243
|
+
},
|
|
11244
|
+
server.config
|
|
11245
|
+
);
|
|
11192
11246
|
this.server = server;
|
|
11193
11247
|
this.vitenode = new ViteNodeServer(server, this.config.server);
|
|
11194
11248
|
const node = this.vitenode;
|
|
@@ -11208,13 +11262,12 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
11208
11262
|
return isBrowserEnabled(this.config);
|
|
11209
11263
|
}
|
|
11210
11264
|
getSerializableConfig() {
|
|
11211
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
11265
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
11212
11266
|
const optimizer = (_a = this.config.deps) == null ? void 0 : _a.optimizer;
|
|
11213
11267
|
const poolOptions = this.config.poolOptions;
|
|
11214
11268
|
const isolate = (_d = (_c = (_b = this.server) == null ? void 0 : _b.config) == null ? void 0 : _c.test) == null ? void 0 : _d.isolate;
|
|
11215
11269
|
return deepMerge({
|
|
11216
11270
|
...this.config,
|
|
11217
|
-
coverage: this.ctx.config.coverage,
|
|
11218
11271
|
poolOptions: {
|
|
11219
11272
|
forks: {
|
|
11220
11273
|
singleFork: ((_e = poolOptions == null ? void 0 : poolOptions.forks) == null ? void 0 : _e.singleFork) ?? ((_g = (_f = this.ctx.config.poolOptions) == null ? void 0 : _f.forks) == null ? void 0 : _g.singleFork) ?? false,
|
|
@@ -11257,7 +11310,13 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
11257
11310
|
},
|
|
11258
11311
|
inspect: this.ctx.config.inspect,
|
|
11259
11312
|
inspectBrk: this.ctx.config.inspectBrk,
|
|
11260
|
-
|
|
11313
|
+
inspector: this.ctx.config.inspector,
|
|
11314
|
+
alias: [],
|
|
11315
|
+
includeTaskLocation: this.config.includeTaskLocation ?? this.ctx.config.includeTaskLocation,
|
|
11316
|
+
env: {
|
|
11317
|
+
...(_v = this.server) == null ? void 0 : _v.config.env,
|
|
11318
|
+
...this.config.env
|
|
11319
|
+
}
|
|
11261
11320
|
}, this.ctx.configOverride || {});
|
|
11262
11321
|
}
|
|
11263
11322
|
close() {
|
|
@@ -11343,12 +11402,12 @@ class Vitest {
|
|
|
11343
11402
|
cache = void 0;
|
|
11344
11403
|
reporters = void 0;
|
|
11345
11404
|
coverageProvider;
|
|
11346
|
-
browserProvider;
|
|
11347
11405
|
logger;
|
|
11348
11406
|
pool;
|
|
11349
11407
|
vitenode = void 0;
|
|
11350
11408
|
invalidates = /* @__PURE__ */ new Set();
|
|
11351
11409
|
changedTests = /* @__PURE__ */ new Set();
|
|
11410
|
+
watchedTests = /* @__PURE__ */ new Set();
|
|
11352
11411
|
filenamePattern;
|
|
11353
11412
|
runningPromise;
|
|
11354
11413
|
closingPromise;
|
|
@@ -11426,11 +11485,14 @@ class Vitest {
|
|
|
11426
11485
|
}
|
|
11427
11486
|
await Promise.all(this._onSetServer.map((fn) => fn()));
|
|
11428
11487
|
const projects = await this.resolveWorkspace(cliOptions);
|
|
11429
|
-
this.projects = projects;
|
|
11430
11488
|
this.resolvedProjects = projects;
|
|
11431
|
-
|
|
11432
|
-
|
|
11433
|
-
|
|
11489
|
+
this.projects = projects;
|
|
11490
|
+
const filters = toArray(resolved.project).map((s) => wildcardPatternToRegExp(s));
|
|
11491
|
+
if (filters.length > 0) {
|
|
11492
|
+
this.projects = this.projects.filter(
|
|
11493
|
+
(p) => filters.some((pattern) => pattern.test(p.getName()))
|
|
11494
|
+
);
|
|
11495
|
+
}
|
|
11434
11496
|
if (!this.coreWorkspaceProject)
|
|
11435
11497
|
this.coreWorkspaceProject = WorkspaceProject.createBasicProject(this);
|
|
11436
11498
|
if (this.config.testNamePattern)
|
|
@@ -11543,17 +11605,37 @@ class Vitest {
|
|
|
11543
11605
|
acc[name] = cliOptions[name];
|
|
11544
11606
|
return acc;
|
|
11545
11607
|
}, {});
|
|
11546
|
-
const
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11608
|
+
const cwd = process.cwd();
|
|
11609
|
+
const projects = [];
|
|
11610
|
+
try {
|
|
11611
|
+
for (const filepath of filteredWorkspaces) {
|
|
11612
|
+
if (this.server.config.configFile === filepath) {
|
|
11613
|
+
const project = await this.createCoreProject();
|
|
11614
|
+
projects.push(() => Promise.resolve(project));
|
|
11615
|
+
continue;
|
|
11616
|
+
}
|
|
11617
|
+
const dir = filepath.endsWith("/") ? filepath.slice(0, -1) : dirname(filepath);
|
|
11618
|
+
if (isMainThread)
|
|
11619
|
+
process.chdir(dir);
|
|
11620
|
+
projects.push(await initializeProject(filepath, this, { workspaceConfigPath, test: cliOverrides }));
|
|
11621
|
+
}
|
|
11622
|
+
} finally {
|
|
11623
|
+
if (isMainThread)
|
|
11624
|
+
process.chdir(cwd);
|
|
11625
|
+
}
|
|
11626
|
+
const projectPromises = [];
|
|
11551
11627
|
projectsOptions.forEach((options, index) => {
|
|
11552
|
-
|
|
11628
|
+
projectPromises.push(initializeProject(index, this, mergeConfig(options, { workspaceConfigPath, test: cliOverrides })));
|
|
11553
11629
|
});
|
|
11554
|
-
if (!projects.length)
|
|
11630
|
+
if (!projects.length && !projectPromises.length)
|
|
11555
11631
|
return [await this.createCoreProject()];
|
|
11556
|
-
const
|
|
11632
|
+
const resolvedProjectsReceivers = [
|
|
11633
|
+
...projects,
|
|
11634
|
+
...await Promise.all(projectPromises)
|
|
11635
|
+
];
|
|
11636
|
+
const resolvedProjects = await Promise.all(
|
|
11637
|
+
resolvedProjectsReceivers.map((receiver) => receiver())
|
|
11638
|
+
);
|
|
11557
11639
|
const names = /* @__PURE__ */ new Set();
|
|
11558
11640
|
for (const project of resolvedProjects) {
|
|
11559
11641
|
const name = project.getName();
|
|
@@ -11597,8 +11679,6 @@ class Vitest {
|
|
|
11597
11679
|
process.exit(exitCode);
|
|
11598
11680
|
}
|
|
11599
11681
|
}
|
|
11600
|
-
this.config.changed = false;
|
|
11601
|
-
this.config.related = void 0;
|
|
11602
11682
|
if (files.length) {
|
|
11603
11683
|
await this.cache.stats.populateStats(this.config.root, files);
|
|
11604
11684
|
await this.runFiles(files, true);
|
|
@@ -11709,6 +11789,8 @@ class Vitest {
|
|
|
11709
11789
|
await this.reportCoverage(allTestsRun);
|
|
11710
11790
|
this.runningPromise = void 0;
|
|
11711
11791
|
this.isFirstRun = false;
|
|
11792
|
+
this.config.changed = false;
|
|
11793
|
+
this.config.related = void 0;
|
|
11712
11794
|
});
|
|
11713
11795
|
return await this.runningPromise;
|
|
11714
11796
|
}
|
|
@@ -11774,6 +11856,12 @@ class Vitest {
|
|
|
11774
11856
|
if (this.restartsCount !== currentCount)
|
|
11775
11857
|
return;
|
|
11776
11858
|
this._rerunTimer = setTimeout(async () => {
|
|
11859
|
+
if (this.watchedTests.size) {
|
|
11860
|
+
this.changedTests.forEach((test) => {
|
|
11861
|
+
if (!this.watchedTests.has(test))
|
|
11862
|
+
this.changedTests.delete(test);
|
|
11863
|
+
});
|
|
11864
|
+
}
|
|
11777
11865
|
if (this.changedTests.size === 0) {
|
|
11778
11866
|
this.invalidates.clear();
|
|
11779
11867
|
return;
|
|
@@ -11802,6 +11890,14 @@ class Vitest {
|
|
|
11802
11890
|
return project.getModulesByFilepath(filepath).size;
|
|
11803
11891
|
});
|
|
11804
11892
|
}
|
|
11893
|
+
/**
|
|
11894
|
+
* Watch only the specified tests. If no tests are provided, all tests will be watched.
|
|
11895
|
+
*/
|
|
11896
|
+
watchTests(tests) {
|
|
11897
|
+
this.watchedTests = new Set(
|
|
11898
|
+
tests.map((test) => slash$1(test))
|
|
11899
|
+
);
|
|
11900
|
+
}
|
|
11805
11901
|
unregisterWatcher = noop$2;
|
|
11806
11902
|
registerWatcher() {
|
|
11807
11903
|
const updateLastChanged = (filepath) => {
|
|
@@ -11902,14 +11998,14 @@ class Vitest {
|
|
|
11902
11998
|
if (!i.file)
|
|
11903
11999
|
return;
|
|
11904
12000
|
const heedsRerun = this.handleFileChanged(i.file);
|
|
11905
|
-
if (heedsRerun)
|
|
12001
|
+
if (heedsRerun.length)
|
|
11906
12002
|
rerun = true;
|
|
11907
12003
|
});
|
|
11908
12004
|
}
|
|
11909
12005
|
if (rerun)
|
|
11910
12006
|
files.push(filepath);
|
|
11911
12007
|
}
|
|
11912
|
-
return files;
|
|
12008
|
+
return Array.from(new Set(files));
|
|
11913
12009
|
}
|
|
11914
12010
|
async reportCoverage(allTestsRun) {
|
|
11915
12011
|
if (!this.config.coverage.reportOnFailure && this.state.getCountOfFailedTests() > 0)
|
|
@@ -11945,6 +12041,7 @@ class Vitest {
|
|
|
11945
12041
|
results.filter((r) => r.status === "rejected").forEach((err) => {
|
|
11946
12042
|
this.logger.error("error during close", err.reason);
|
|
11947
12043
|
});
|
|
12044
|
+
this.logger.logUpdate.done();
|
|
11948
12045
|
});
|
|
11949
12046
|
})();
|
|
11950
12047
|
}
|
|
@@ -12041,8 +12138,8 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
12041
12138
|
const testConfig = deepMerge(
|
|
12042
12139
|
{},
|
|
12043
12140
|
configDefaults,
|
|
12044
|
-
|
|
12045
|
-
|
|
12141
|
+
removeUndefinedValues(viteConfig.test ?? {}),
|
|
12142
|
+
options
|
|
12046
12143
|
);
|
|
12047
12144
|
testConfig.api = resolveApiServerConfig(testConfig);
|
|
12048
12145
|
const defines = deleteDefineConfig(viteConfig);
|
|
@@ -19058,7 +19155,9 @@ const cliOptionsConfig = {
|
|
|
19058
19155
|
if (typeof browser === "boolean")
|
|
19059
19156
|
return { enabled: browser };
|
|
19060
19157
|
if (browser === "true" || browser === "false")
|
|
19061
|
-
return { enabled: browser
|
|
19158
|
+
return { enabled: browser === "true" };
|
|
19159
|
+
if (browser === "yes" || browser === "no")
|
|
19160
|
+
return { enabled: browser === "yes" };
|
|
19062
19161
|
if (typeof browser === "string")
|
|
19063
19162
|
return { enabled: true, name: browser };
|
|
19064
19163
|
return browser;
|
|
@@ -19190,7 +19289,16 @@ const cliOptionsConfig = {
|
|
|
19190
19289
|
argument: "<options>",
|
|
19191
19290
|
subcommands: {
|
|
19192
19291
|
shuffle: {
|
|
19193
|
-
description: "Run tests in a random order. Enabling this option will impact Vitest's cache and have a performance impact. May be useful to find tests that accidentally depend on another run previously (default: false)"
|
|
19292
|
+
description: "Run files and tests in a random order. Enabling this option will impact Vitest's cache and have a performance impact. May be useful to find tests that accidentally depend on another run previously (default: false)",
|
|
19293
|
+
argument: "",
|
|
19294
|
+
subcommands: {
|
|
19295
|
+
files: {
|
|
19296
|
+
description: "Run files in a random order. Long running tests will not start earlier if you enable this option. (default: false)"
|
|
19297
|
+
},
|
|
19298
|
+
tests: {
|
|
19299
|
+
description: "Run tests in a random oder (default: false)"
|
|
19300
|
+
}
|
|
19301
|
+
}
|
|
19194
19302
|
},
|
|
19195
19303
|
concurrent: {
|
|
19196
19304
|
description: "Make tests run in parallel (default: false)"
|
|
@@ -19210,11 +19318,28 @@ const cliOptionsConfig = {
|
|
|
19210
19318
|
}
|
|
19211
19319
|
},
|
|
19212
19320
|
inspect: {
|
|
19213
|
-
description: "Enable Node.js inspector"
|
|
19321
|
+
description: "Enable Node.js inspector (default: 127.0.0.1:9229)",
|
|
19322
|
+
argument: "[[host:]port]",
|
|
19323
|
+
transform(portOrEnabled) {
|
|
19324
|
+
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes")
|
|
19325
|
+
return true;
|
|
19326
|
+
if (portOrEnabled === "false" || portOrEnabled === "no")
|
|
19327
|
+
return false;
|
|
19328
|
+
return portOrEnabled;
|
|
19329
|
+
}
|
|
19214
19330
|
},
|
|
19215
19331
|
inspectBrk: {
|
|
19216
|
-
description: "Enable Node.js inspector
|
|
19332
|
+
description: "Enable Node.js inspector and break before the test starts",
|
|
19333
|
+
argument: "[[host:]port]",
|
|
19334
|
+
transform(portOrEnabled) {
|
|
19335
|
+
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes")
|
|
19336
|
+
return true;
|
|
19337
|
+
if (portOrEnabled === "false" || portOrEnabled === "no")
|
|
19338
|
+
return false;
|
|
19339
|
+
return portOrEnabled;
|
|
19340
|
+
}
|
|
19217
19341
|
},
|
|
19342
|
+
inspector: null,
|
|
19218
19343
|
testTimeout: {
|
|
19219
19344
|
description: "Default timeout of a test in milliseconds (default: 5000)",
|
|
19220
19345
|
argument: "<timeout>"
|
|
@@ -19279,8 +19404,9 @@ const cliOptionsConfig = {
|
|
|
19279
19404
|
}
|
|
19280
19405
|
},
|
|
19281
19406
|
project: {
|
|
19282
|
-
description: "The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: --project=1 --project=2",
|
|
19283
|
-
argument: "<name>"
|
|
19407
|
+
description: "The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: --project=1 --project=2. You can also filter projects using wildcards like --project=packages*",
|
|
19408
|
+
argument: "<name>",
|
|
19409
|
+
array: true
|
|
19284
19410
|
},
|
|
19285
19411
|
slowTestThreshold: {
|
|
19286
19412
|
description: "Threshold in milliseconds for a test to be considered slow (default: 300)",
|
|
@@ -19295,14 +19421,13 @@ const cliOptionsConfig = {
|
|
|
19295
19421
|
argument: "",
|
|
19296
19422
|
// allow only boolean
|
|
19297
19423
|
subcommands: {
|
|
19298
|
-
dir:
|
|
19299
|
-
description: "Path to the cache directory",
|
|
19300
|
-
argument: "<path>",
|
|
19301
|
-
normalize: true
|
|
19302
|
-
}
|
|
19424
|
+
dir: null
|
|
19303
19425
|
},
|
|
19426
|
+
default: true,
|
|
19304
19427
|
// cache can only be "false" or an object
|
|
19305
19428
|
transform(cache) {
|
|
19429
|
+
if (typeof cache !== "boolean" && cache)
|
|
19430
|
+
throw new Error("--cache.dir is deprecated");
|
|
19306
19431
|
if (cache)
|
|
19307
19432
|
return {};
|
|
19308
19433
|
return cache;
|
|
@@ -19325,6 +19450,9 @@ const cliOptionsConfig = {
|
|
|
19325
19450
|
description: "Removes colors from the console output",
|
|
19326
19451
|
alias: "no-color"
|
|
19327
19452
|
},
|
|
19453
|
+
clearScreen: {
|
|
19454
|
+
description: "Clear terminal screen when re-running tests during watch mode (default: true)"
|
|
19455
|
+
},
|
|
19328
19456
|
// disable CLI options
|
|
19329
19457
|
cliExclude: null,
|
|
19330
19458
|
server: null,
|
|
@@ -19355,7 +19483,8 @@ const cliOptionsConfig = {
|
|
|
19355
19483
|
css: null,
|
|
19356
19484
|
poolMatchGlobs: null,
|
|
19357
19485
|
deps: null,
|
|
19358
|
-
name: null
|
|
19486
|
+
name: null,
|
|
19487
|
+
includeTaskLocation: null
|
|
19359
19488
|
};
|
|
19360
19489
|
|
|
19361
19490
|
function addCommand(cli, name, option) {
|