vitest 0.34.6 → 1.0.0-beta.1
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/README.md +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/child.js +21 -19
- package/dist/{chunk-api-setup.d65b007d.js → chunk-api-setup.0aeabd21.js} +1 -1
- package/dist/{chunk-install-pkg.6c4f388a.js → chunk-install-pkg.a430b45e.js} +5 -4
- package/dist/{chunk-integrations-globals.5afac659.js → chunk-integrations-globals.c3c5e678.js} +4 -3
- package/dist/cli.js +11 -6
- package/dist/config.cjs +1 -2
- package/dist/config.d.ts +2 -3
- package/dist/config.js +1 -2
- package/dist/coverage.d.ts +1 -1
- package/dist/entry-vm.js +5 -4
- package/dist/entry.js +8 -4
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/index.d.ts +9 -10
- package/dist/index.js +4 -3
- package/dist/node.d.ts +2 -2
- package/dist/node.js +7 -6
- package/dist/{reporters-5f784f42.d.ts → reporters-7bd09217.d.ts} +165 -103
- package/dist/reporters.d.ts +1 -1
- package/dist/runners.d.ts +10 -10
- package/dist/runners.js +13 -12
- package/dist/suite-543d56bd.d.ts +10 -0
- package/dist/suite.d.ts +15 -1
- package/dist/suite.js +7 -1
- package/dist/vendor-benchmark.44931cfa.js +41 -0
- package/dist/{vendor-environments.7aba93d9.js → vendor-environments.e73c5410.js} +14 -2
- package/dist/{vendor-index.b271ebe4.js → vendor-index.1ca68bd5.js} +7 -5
- package/dist/{vendor-index.3e351f42.js → vendor-index.d36f5516.js} +5 -5
- package/dist/{vendor-index.7646b3af.js → vendor-index.f7fcd5e8.js} +2 -1
- package/dist/vendor-inspector.209edf5a.js +26 -0
- package/dist/{vendor-node.a7c48fe1.js → vendor-node.bde9fb47.js} +413 -298
- package/dist/{vendor-vi.6873a1c1.js → vendor-vi.7f2b988f.js} +28 -53
- package/dist/vm.js +2 -2
- package/dist/worker.js +7 -4
- package/package.json +14 -13
- package/dist/vendor-inspector.47fc8cbb.js +0 -23
|
@@ -21,14 +21,13 @@ import { r as removeUndefinedValues, a as isWindows } from './vendor-index.29282
|
|
|
21
21
|
import { g as getCoverageProvider, C as CoverageProviderMap } from './vendor-coverage.78040316.js';
|
|
22
22
|
import { d as distDir, r as rootDir } from './vendor-paths.84fc7a99.js';
|
|
23
23
|
import v8 from 'node:v8';
|
|
24
|
-
import
|
|
25
|
-
import
|
|
24
|
+
import * as nodeos from 'node:os';
|
|
25
|
+
import EventEmitter from 'node:events';
|
|
26
|
+
import Tinypool$1, { Tinypool } from 'tinypool';
|
|
27
|
+
import { c as createBirpc } from './vendor-index.1ca68bd5.js';
|
|
26
28
|
import { g as groupBy, A as AggregateErrorPonyfill, s as slash$1, t as toArray, i as isPrimitive, d as deepMerge, n as noop$1, a as stdout } from './vendor-base.9c08bbd0.js';
|
|
27
29
|
import { MessageChannel } from 'node:worker_threads';
|
|
28
|
-
import
|
|
29
|
-
import { totalmem } from 'node:os';
|
|
30
|
-
import Tinypool from 'tinypool';
|
|
31
|
-
import { createDefer, shuffle, inspect, positionToOffset, lineSplitRE, notNullish } from '@vitest/utils';
|
|
30
|
+
import { createDefer, shuffle, inspect, positionToOffset, lineSplitRE, toArray as toArray$1, notNullish } from '@vitest/utils';
|
|
32
31
|
import { isPackageExists, resolveModule } from 'local-pkg';
|
|
33
32
|
import { isCI } from 'std-env';
|
|
34
33
|
import { R as ReportersMap, B as BenchmarkReportsMap, s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, d as divider, F as F_POINTER, e as cliTruncate } from './vendor-reporters.f6975b8d.js';
|
|
@@ -42,7 +41,7 @@ import { ancestor, simple, findNodeAround } from 'acorn-walk';
|
|
|
42
41
|
import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, hasFailed } from '@vitest/runner/utils';
|
|
43
42
|
import MagicString from 'magic-string';
|
|
44
43
|
import { stripLiteral } from 'strip-literal';
|
|
45
|
-
import { g as getEnvPackageName } from './vendor-environments.
|
|
44
|
+
import { g as getEnvPackageName } from './vendor-environments.e73c5410.js';
|
|
46
45
|
import readline from 'node:readline';
|
|
47
46
|
import require$$0$2 from 'readline';
|
|
48
47
|
|
|
@@ -61,7 +60,7 @@ function _mergeNamespaces(n, m) {
|
|
|
61
60
|
return Object.freeze(n);
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
var version$1 = "0.
|
|
63
|
+
var version$1 = "1.0.0-beta.1";
|
|
65
64
|
|
|
66
65
|
const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
|
|
67
66
|
async function ensurePackageInstalled(dependency, root) {
|
|
@@ -80,7 +79,7 @@ async function ensurePackageInstalled(dependency, root) {
|
|
|
80
79
|
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
81
80
|
});
|
|
82
81
|
if (install) {
|
|
83
|
-
await (await import('./chunk-install-pkg.
|
|
82
|
+
await (await import('./chunk-install-pkg.a430b45e.js')).installPackage(dependency, { dev: true });
|
|
84
83
|
process.stderr.write(c.yellow(`
|
|
85
84
|
Package ${dependency} installed, re-run the command to start.
|
|
86
85
|
`));
|
|
@@ -7166,7 +7165,14 @@ function createMethodsRPC(project) {
|
|
|
7166
7165
|
}
|
|
7167
7166
|
|
|
7168
7167
|
const childPath = fileURLToPath(pathToFileURL(resolve(distDir, "./child.js")).href);
|
|
7169
|
-
function
|
|
7168
|
+
function createChildProcessChannel(project) {
|
|
7169
|
+
const emitter = new EventEmitter();
|
|
7170
|
+
const cleanup = () => emitter.removeAllListeners();
|
|
7171
|
+
const events = { message: "message", response: "response" };
|
|
7172
|
+
const channel = {
|
|
7173
|
+
onMessage: (callback) => emitter.on(events.message, callback),
|
|
7174
|
+
postMessage: (message) => emitter.emit(events.response, message)
|
|
7175
|
+
};
|
|
7170
7176
|
const rpc = createBirpc(
|
|
7171
7177
|
createMethodsRPC(project),
|
|
7172
7178
|
{
|
|
@@ -7174,94 +7180,149 @@ function setupChildProcessChannel(project, fork2) {
|
|
|
7174
7180
|
serialize: v8.serialize,
|
|
7175
7181
|
deserialize: (v) => v8.deserialize(Buffer.from(v)),
|
|
7176
7182
|
post(v) {
|
|
7177
|
-
|
|
7183
|
+
emitter.emit(events.message, v);
|
|
7178
7184
|
},
|
|
7179
7185
|
on(fn) {
|
|
7180
|
-
|
|
7186
|
+
emitter.on(events.response, fn);
|
|
7181
7187
|
}
|
|
7182
7188
|
}
|
|
7183
7189
|
);
|
|
7184
7190
|
project.ctx.onCancel((reason) => rpc.onCancel(reason));
|
|
7191
|
+
return { channel, cleanup };
|
|
7185
7192
|
}
|
|
7186
7193
|
function stringifyRegex(input) {
|
|
7187
7194
|
if (typeof input === "string")
|
|
7188
7195
|
return input;
|
|
7189
7196
|
return `$$vitest:${input.toString()}`;
|
|
7190
7197
|
}
|
|
7191
|
-
function getTestConfig(ctx) {
|
|
7192
|
-
const config = ctx.getSerializableConfig();
|
|
7193
|
-
return {
|
|
7194
|
-
...config,
|
|
7195
|
-
testNamePattern: config.testNamePattern ? stringifyRegex(config.testNamePattern) : void 0
|
|
7196
|
-
};
|
|
7197
|
-
}
|
|
7198
7198
|
function createChildProcessPool(ctx, { execArgv, env }) {
|
|
7199
|
-
|
|
7200
|
-
const
|
|
7201
|
-
const
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7199
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7200
|
+
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
7201
|
+
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
7202
|
+
const maxThreads = ((_b = (_a = ctx.config.poolOptions) == null ? void 0 : _a.forks) == null ? void 0 : _b.maxForks) ?? threadsCount;
|
|
7203
|
+
const minThreads = ((_d = (_c = ctx.config.poolOptions) == null ? void 0 : _c.forks) == null ? void 0 : _d.minForks) ?? threadsCount;
|
|
7204
|
+
const options = {
|
|
7205
|
+
runtime: "child_process",
|
|
7206
|
+
filename: childPath,
|
|
7207
|
+
maxThreads,
|
|
7208
|
+
minThreads,
|
|
7209
|
+
env,
|
|
7210
|
+
execArgv,
|
|
7211
|
+
terminateTimeout: ctx.config.teardownTimeout
|
|
7212
|
+
};
|
|
7213
|
+
if (((_f = (_e = ctx.config.poolOptions) == null ? void 0 : _e.forks) == null ? void 0 : _f.isolate) ?? true) {
|
|
7214
|
+
options.isolateWorkers = true;
|
|
7215
|
+
options.concurrentTasksPerWorker = 1;
|
|
7216
|
+
}
|
|
7217
|
+
if ((_h = (_g = ctx.config.poolOptions) == null ? void 0 : _g.forks) == null ? void 0 : _h.singleFork) {
|
|
7218
|
+
options.concurrentTasksPerWorker = 1;
|
|
7219
|
+
options.maxThreads = 1;
|
|
7220
|
+
options.minThreads = 1;
|
|
7221
|
+
}
|
|
7222
|
+
const pool = new Tinypool(options);
|
|
7223
|
+
const runWithFiles = (name) => {
|
|
7224
|
+
let id = 0;
|
|
7225
|
+
async function runFiles(project, config, files, environment, invalidates = []) {
|
|
7226
|
+
ctx.state.clearFiles(project, files);
|
|
7227
|
+
const { channel, cleanup } = createChildProcessChannel(project);
|
|
7228
|
+
const workerId = ++id;
|
|
7229
|
+
const data = {
|
|
7230
|
+
config,
|
|
7231
|
+
files,
|
|
7232
|
+
invalidates,
|
|
7233
|
+
environment,
|
|
7234
|
+
workerId
|
|
7235
|
+
};
|
|
7236
|
+
try {
|
|
7237
|
+
await pool.run(data, { name, channel });
|
|
7238
|
+
} catch (error) {
|
|
7239
|
+
if (error instanceof Error && /Failed to terminate worker/.test(error.message))
|
|
7240
|
+
ctx.state.addProcessTimeoutCause(`Failed to terminate worker while running ${files.join(", ")}.`);
|
|
7241
|
+
else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message))
|
|
7242
|
+
ctx.state.cancelFiles(files, ctx.config.root);
|
|
7228
7243
|
else
|
|
7229
|
-
|
|
7230
|
-
|
|
7244
|
+
throw error;
|
|
7245
|
+
} finally {
|
|
7246
|
+
cleanup();
|
|
7247
|
+
}
|
|
7248
|
+
}
|
|
7249
|
+
const Sequencer = ctx.config.sequence.sequencer;
|
|
7250
|
+
const sequencer = new Sequencer(ctx);
|
|
7251
|
+
return async (specs, invalidates) => {
|
|
7252
|
+
var _a2, _b2;
|
|
7253
|
+
ctx.onCancel(() => pool.cancelPendingTasks());
|
|
7254
|
+
const configs = /* @__PURE__ */ new Map();
|
|
7255
|
+
const getConfig = (project) => {
|
|
7256
|
+
if (configs.has(project))
|
|
7257
|
+
return configs.get(project);
|
|
7258
|
+
const _config = project.getSerializableConfig();
|
|
7259
|
+
const config = {
|
|
7260
|
+
..._config,
|
|
7261
|
+
// v8 serialize does not support regex
|
|
7262
|
+
testNamePattern: _config.testNamePattern ? stringifyRegex(_config.testNamePattern) : void 0
|
|
7263
|
+
};
|
|
7264
|
+
configs.set(project, config);
|
|
7265
|
+
return config;
|
|
7266
|
+
};
|
|
7267
|
+
const workspaceMap = /* @__PURE__ */ new Map();
|
|
7268
|
+
for (const [project, file] of specs) {
|
|
7269
|
+
const workspaceFiles = workspaceMap.get(file) ?? [];
|
|
7270
|
+
workspaceFiles.push(project);
|
|
7271
|
+
workspaceMap.set(file, workspaceFiles);
|
|
7272
|
+
}
|
|
7273
|
+
const { shard } = ctx.config;
|
|
7274
|
+
if (shard)
|
|
7275
|
+
specs = await sequencer.shard(specs);
|
|
7276
|
+
specs = await sequencer.sort(specs);
|
|
7277
|
+
const singleFork = specs.filter(([project]) => {
|
|
7278
|
+
var _a3, _b3;
|
|
7279
|
+
return (_b3 = (_a3 = project.config.poolOptions) == null ? void 0 : _a3.forks) == null ? void 0 : _b3.singleFork;
|
|
7231
7280
|
});
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
const files2 = filesByOptions[option];
|
|
7250
|
-
if (files2 == null ? void 0 : files2.length) {
|
|
7251
|
-
const filenames = files2.map((f) => f.file);
|
|
7252
|
-
await runFiles(files2[0].project, filenames, files2[0].environment, invalidates);
|
|
7281
|
+
const multipleForks = specs.filter(([project]) => {
|
|
7282
|
+
var _a3, _b3;
|
|
7283
|
+
return !((_b3 = (_a3 = project.config.poolOptions) == null ? void 0 : _a3.forks) == null ? void 0 : _b3.singleFork);
|
|
7284
|
+
});
|
|
7285
|
+
if (multipleForks.length) {
|
|
7286
|
+
const filesByEnv = await groupFilesByEnv(multipleForks);
|
|
7287
|
+
const files = Object.values(filesByEnv).flat();
|
|
7288
|
+
const results = [];
|
|
7289
|
+
if (((_b2 = (_a2 = ctx.config.poolOptions) == null ? void 0 : _a2.forks) == null ? void 0 : _b2.isolate) ?? true) {
|
|
7290
|
+
results.push(...await Promise.allSettled(files.map(({ file, environment, project }) => runFiles(project, getConfig(project), [file], environment, invalidates))));
|
|
7291
|
+
} else {
|
|
7292
|
+
const grouped = groupBy(files, ({ project, environment }) => project.getName() + environment.name + JSON.stringify(environment.options));
|
|
7293
|
+
for (const group of Object.values(grouped)) {
|
|
7294
|
+
results.push(...await Promise.allSettled(group.map(({ file, environment, project }) => runFiles(project, getConfig(project), [file], environment, invalidates))));
|
|
7295
|
+
await new Promise((resolve2) => pool.queueSize === 0 ? resolve2() : pool.once("drain", resolve2));
|
|
7296
|
+
await pool.recycleWorkers();
|
|
7297
|
+
}
|
|
7253
7298
|
}
|
|
7299
|
+
const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
7300
|
+
if (errors.length > 0)
|
|
7301
|
+
throw new AggregateError(errors, "Errors occurred while running tests. For more information, see serialized error.");
|
|
7254
7302
|
}
|
|
7255
|
-
|
|
7256
|
-
|
|
7303
|
+
if (singleFork.length) {
|
|
7304
|
+
const filesByEnv = await groupFilesByEnv(singleFork);
|
|
7305
|
+
const envs = envsOrder.concat(
|
|
7306
|
+
Object.keys(filesByEnv).filter((env2) => !envsOrder.includes(env2))
|
|
7307
|
+
);
|
|
7308
|
+
for (const env2 of envs) {
|
|
7309
|
+
const files = filesByEnv[env2];
|
|
7310
|
+
if (!(files == null ? void 0 : files.length))
|
|
7311
|
+
continue;
|
|
7312
|
+
const filesByOptions = groupBy(files, ({ project, environment }) => project.getName() + JSON.stringify(environment.options));
|
|
7313
|
+
for (const files2 of Object.values(filesByOptions)) {
|
|
7314
|
+
await pool.recycleWorkers();
|
|
7315
|
+
const filenames = files2.map((f) => f.file);
|
|
7316
|
+
await runFiles(files2[0].project, getConfig(files2[0].project), filenames, files2[0].environment, invalidates);
|
|
7317
|
+
}
|
|
7318
|
+
}
|
|
7319
|
+
}
|
|
7320
|
+
};
|
|
7321
|
+
};
|
|
7257
7322
|
return {
|
|
7258
|
-
runTests,
|
|
7259
|
-
async
|
|
7260
|
-
|
|
7261
|
-
if (!child.killed)
|
|
7262
|
-
child.kill();
|
|
7263
|
-
});
|
|
7264
|
-
children.clear();
|
|
7323
|
+
runTests: runWithFiles("run"),
|
|
7324
|
+
close: async () => {
|
|
7325
|
+
await pool.destroy();
|
|
7265
7326
|
}
|
|
7266
7327
|
};
|
|
7267
7328
|
}
|
|
@@ -7287,31 +7348,32 @@ function createWorkerChannel$1(project) {
|
|
|
7287
7348
|
return { workerPort, port };
|
|
7288
7349
|
}
|
|
7289
7350
|
function createThreadsPool(ctx, { execArgv, env }) {
|
|
7351
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
7290
7352
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
7291
7353
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
7292
|
-
const maxThreads = ctx.config.maxThreads ?? threadsCount;
|
|
7293
|
-
const minThreads = ctx.config.minThreads ?? threadsCount;
|
|
7354
|
+
const maxThreads = ((_b = (_a = ctx.config.poolOptions) == null ? void 0 : _a.threads) == null ? void 0 : _b.maxThreads) ?? threadsCount;
|
|
7355
|
+
const minThreads = ((_d = (_c = ctx.config.poolOptions) == null ? void 0 : _c.threads) == null ? void 0 : _d.minThreads) ?? threadsCount;
|
|
7294
7356
|
const options = {
|
|
7295
7357
|
filename: workerPath$1,
|
|
7296
7358
|
// TODO: investigate further
|
|
7297
7359
|
// It seems atomics introduced V8 Fatal Error https://github.com/vitest-dev/vitest/issues/1191
|
|
7298
|
-
useAtomics: ctx.config.useAtomics ?? false,
|
|
7360
|
+
useAtomics: ((_f = (_e = ctx.config.poolOptions) == null ? void 0 : _e.threads) == null ? void 0 : _f.useAtomics) ?? false,
|
|
7299
7361
|
maxThreads,
|
|
7300
7362
|
minThreads,
|
|
7301
7363
|
env,
|
|
7302
7364
|
execArgv,
|
|
7303
7365
|
terminateTimeout: ctx.config.teardownTimeout
|
|
7304
7366
|
};
|
|
7305
|
-
if (ctx.config.isolate) {
|
|
7367
|
+
if (((_h = (_g = ctx.config.poolOptions) == null ? void 0 : _g.threads) == null ? void 0 : _h.isolate) ?? true) {
|
|
7306
7368
|
options.isolateWorkers = true;
|
|
7307
7369
|
options.concurrentTasksPerWorker = 1;
|
|
7308
7370
|
}
|
|
7309
|
-
if (ctx.config.singleThread) {
|
|
7371
|
+
if ((_j = (_i = ctx.config.poolOptions) == null ? void 0 : _i.threads) == null ? void 0 : _j.singleThread) {
|
|
7310
7372
|
options.concurrentTasksPerWorker = 1;
|
|
7311
7373
|
options.maxThreads = 1;
|
|
7312
7374
|
options.minThreads = 1;
|
|
7313
7375
|
}
|
|
7314
|
-
const pool = new Tinypool(options);
|
|
7376
|
+
const pool = new Tinypool$1(options);
|
|
7315
7377
|
const runWithFiles = (name) => {
|
|
7316
7378
|
let id = 0;
|
|
7317
7379
|
async function runFiles(project, config, files, environment, invalidates = []) {
|
|
@@ -7343,6 +7405,7 @@ function createThreadsPool(ctx, { execArgv, env }) {
|
|
|
7343
7405
|
const Sequencer = ctx.config.sequence.sequencer;
|
|
7344
7406
|
const sequencer = new Sequencer(ctx);
|
|
7345
7407
|
return async (specs, invalidates) => {
|
|
7408
|
+
var _a2, _b2;
|
|
7346
7409
|
ctx.onCancel(() => pool.cancelPendingTasks());
|
|
7347
7410
|
const configs = /* @__PURE__ */ new Map();
|
|
7348
7411
|
const getConfig = (project) => {
|
|
@@ -7362,13 +7425,19 @@ function createThreadsPool(ctx, { execArgv, env }) {
|
|
|
7362
7425
|
if (shard)
|
|
7363
7426
|
specs = await sequencer.shard(specs);
|
|
7364
7427
|
specs = await sequencer.sort(specs);
|
|
7365
|
-
const singleThreads = specs.filter(([project]) =>
|
|
7366
|
-
|
|
7428
|
+
const singleThreads = specs.filter(([project]) => {
|
|
7429
|
+
var _a3, _b3;
|
|
7430
|
+
return (_b3 = (_a3 = project.config.poolOptions) == null ? void 0 : _a3.threads) == null ? void 0 : _b3.singleThread;
|
|
7431
|
+
});
|
|
7432
|
+
const multipleThreads = specs.filter(([project]) => {
|
|
7433
|
+
var _a3, _b3;
|
|
7434
|
+
return !((_b3 = (_a3 = project.config.poolOptions) == null ? void 0 : _a3.threads) == null ? void 0 : _b3.singleThread);
|
|
7435
|
+
});
|
|
7367
7436
|
if (multipleThreads.length) {
|
|
7368
7437
|
const filesByEnv = await groupFilesByEnv(multipleThreads);
|
|
7369
7438
|
const files = Object.values(filesByEnv).flat();
|
|
7370
7439
|
const results = [];
|
|
7371
|
-
if (ctx.config.isolate) {
|
|
7440
|
+
if (((_b2 = (_a2 = ctx.config.poolOptions) == null ? void 0 : _a2.threads) == null ? void 0 : _b2.isolate) ?? true) {
|
|
7372
7441
|
results.push(...await Promise.allSettled(files.map(({ file, environment, project }) => runFiles(project, getConfig(project), [file], environment, invalidates))));
|
|
7373
7442
|
} else {
|
|
7374
7443
|
const grouped = groupBy(files, ({ project, environment }) => project.getName() + environment.name + JSON.stringify(environment.options));
|
|
@@ -7404,8 +7473,8 @@ function createThreadsPool(ctx, { execArgv, env }) {
|
|
|
7404
7473
|
return {
|
|
7405
7474
|
runTests: runWithFiles("run"),
|
|
7406
7475
|
close: async () => {
|
|
7407
|
-
var
|
|
7408
|
-
const nodeVersion = Number((
|
|
7476
|
+
var _a2;
|
|
7477
|
+
const nodeVersion = Number((_a2 = process.version.match(/v(\d+)\.(\d+)/)) == null ? void 0 : _a2[0].slice(1));
|
|
7409
7478
|
if (nodeVersion >= 16.17)
|
|
7410
7479
|
await pool.destroy();
|
|
7411
7480
|
}
|
|
@@ -7442,8 +7511,7 @@ function createBrowserPool(ctx) {
|
|
|
7442
7511
|
providers.add(provider);
|
|
7443
7512
|
const origin = `http://${((_a = ctx.config.browser.api) == null ? void 0 : _a.host) || "localhost"}:${project.browser.config.server.port}`;
|
|
7444
7513
|
const paths = files.map((file) => relative(project.config.root, file));
|
|
7445
|
-
|
|
7446
|
-
if (isolate) {
|
|
7514
|
+
if (project.config.browser.isolate) {
|
|
7447
7515
|
for (const path of paths) {
|
|
7448
7516
|
if (isCancelled) {
|
|
7449
7517
|
ctx.state.cancelFiles(files.slice(paths.indexOf(path)), ctx.config.root);
|
|
@@ -7483,6 +7551,69 @@ function createBrowserPool(ctx) {
|
|
|
7483
7551
|
};
|
|
7484
7552
|
}
|
|
7485
7553
|
|
|
7554
|
+
function getDefaultThreadsCount(config) {
|
|
7555
|
+
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
7556
|
+
return config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
7557
|
+
}
|
|
7558
|
+
function getWorkerMemoryLimit(config) {
|
|
7559
|
+
var _a, _b, _c, _d;
|
|
7560
|
+
const memoryLimit = (_b = (_a = config.poolOptions) == null ? void 0 : _a.vmThreads) == null ? void 0 : _b.memoryLimit;
|
|
7561
|
+
if (memoryLimit)
|
|
7562
|
+
return stringToBytes(memoryLimit);
|
|
7563
|
+
return 1 / (((_d = (_c = config.poolOptions) == null ? void 0 : _c.vmThreads) == null ? void 0 : _d.maxThreads) ?? getDefaultThreadsCount(config));
|
|
7564
|
+
}
|
|
7565
|
+
function stringToBytes(input, percentageReference) {
|
|
7566
|
+
if (input === null || input === void 0)
|
|
7567
|
+
return input;
|
|
7568
|
+
if (typeof input === "string") {
|
|
7569
|
+
if (Number.isNaN(Number.parseFloat(input.slice(-1)))) {
|
|
7570
|
+
let [, numericString, trailingChars] = input.match(/(.*?)([^0-9.-]+)$/i) || [];
|
|
7571
|
+
if (trailingChars && numericString) {
|
|
7572
|
+
const numericValue = Number.parseFloat(numericString);
|
|
7573
|
+
trailingChars = trailingChars.toLowerCase();
|
|
7574
|
+
switch (trailingChars) {
|
|
7575
|
+
case "%":
|
|
7576
|
+
input = numericValue / 100;
|
|
7577
|
+
break;
|
|
7578
|
+
case "kb":
|
|
7579
|
+
case "k":
|
|
7580
|
+
return numericValue * 1e3;
|
|
7581
|
+
case "kib":
|
|
7582
|
+
return numericValue * 1024;
|
|
7583
|
+
case "mb":
|
|
7584
|
+
case "m":
|
|
7585
|
+
return numericValue * 1e3 * 1e3;
|
|
7586
|
+
case "mib":
|
|
7587
|
+
return numericValue * 1024 * 1024;
|
|
7588
|
+
case "gb":
|
|
7589
|
+
case "g":
|
|
7590
|
+
return numericValue * 1e3 * 1e3 * 1e3;
|
|
7591
|
+
case "gib":
|
|
7592
|
+
return numericValue * 1024 * 1024 * 1024;
|
|
7593
|
+
}
|
|
7594
|
+
}
|
|
7595
|
+
} else {
|
|
7596
|
+
input = Number.parseFloat(input);
|
|
7597
|
+
}
|
|
7598
|
+
}
|
|
7599
|
+
if (typeof input === "number") {
|
|
7600
|
+
if (input <= 1 && input > 0) {
|
|
7601
|
+
if (percentageReference) {
|
|
7602
|
+
return Math.floor(input * percentageReference);
|
|
7603
|
+
} else {
|
|
7604
|
+
throw new Error(
|
|
7605
|
+
"For a percentage based memory limit a percentageReference must be supplied"
|
|
7606
|
+
);
|
|
7607
|
+
}
|
|
7608
|
+
} else if (input > 1) {
|
|
7609
|
+
return Math.floor(input);
|
|
7610
|
+
} else {
|
|
7611
|
+
throw new Error('Unexpected numerical input for "experimentalVmWorkerMemoryLimit"');
|
|
7612
|
+
}
|
|
7613
|
+
}
|
|
7614
|
+
return null;
|
|
7615
|
+
}
|
|
7616
|
+
|
|
7486
7617
|
const workerPath = pathToFileURL(resolve(distDir, "./vm.js")).href;
|
|
7487
7618
|
const suppressWarningsPath = resolve(rootDir, "./suppress-warnings.cjs");
|
|
7488
7619
|
function createWorkerChannel(project) {
|
|
@@ -7505,15 +7636,16 @@ function createWorkerChannel(project) {
|
|
|
7505
7636
|
return { workerPort, port };
|
|
7506
7637
|
}
|
|
7507
7638
|
function createVmThreadsPool(ctx, { execArgv, env }) {
|
|
7639
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7508
7640
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
7509
7641
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
7510
|
-
const maxThreads = ctx.config.maxThreads ?? threadsCount;
|
|
7511
|
-
const minThreads = ctx.config.minThreads ?? threadsCount;
|
|
7642
|
+
const maxThreads = ((_b = (_a = ctx.config.poolOptions) == null ? void 0 : _a.vmThreads) == null ? void 0 : _b.maxThreads) ?? threadsCount;
|
|
7643
|
+
const minThreads = ((_d = (_c = ctx.config.poolOptions) == null ? void 0 : _c.vmThreads) == null ? void 0 : _d.minThreads) ?? threadsCount;
|
|
7512
7644
|
const options = {
|
|
7513
7645
|
filename: workerPath,
|
|
7514
7646
|
// TODO: investigate further
|
|
7515
7647
|
// It seems atomics introduced V8 Fatal Error https://github.com/vitest-dev/vitest/issues/1191
|
|
7516
|
-
useAtomics: ctx.config.useAtomics ?? false,
|
|
7648
|
+
useAtomics: ((_f = (_e = ctx.config.poolOptions) == null ? void 0 : _e.vmThreads) == null ? void 0 : _f.useAtomics) ?? false,
|
|
7517
7649
|
maxThreads,
|
|
7518
7650
|
minThreads,
|
|
7519
7651
|
env,
|
|
@@ -7525,14 +7657,14 @@ function createVmThreadsPool(ctx, { execArgv, env }) {
|
|
|
7525
7657
|
...execArgv
|
|
7526
7658
|
],
|
|
7527
7659
|
terminateTimeout: ctx.config.teardownTimeout,
|
|
7528
|
-
maxMemoryLimitBeforeRecycle: ctx.config
|
|
7660
|
+
maxMemoryLimitBeforeRecycle: getMemoryLimit(ctx.config) || void 0
|
|
7529
7661
|
};
|
|
7530
|
-
if (ctx.config.singleThread) {
|
|
7662
|
+
if ((_h = (_g = ctx.config.poolOptions) == null ? void 0 : _g.vmThreads) == null ? void 0 : _h.singleThread) {
|
|
7531
7663
|
options.concurrentTasksPerWorker = 1;
|
|
7532
7664
|
options.maxThreads = 1;
|
|
7533
7665
|
options.minThreads = 1;
|
|
7534
7666
|
}
|
|
7535
|
-
const pool = new Tinypool(options);
|
|
7667
|
+
const pool = new Tinypool$1(options);
|
|
7536
7668
|
const runWithFiles = (name) => {
|
|
7537
7669
|
let id = 0;
|
|
7538
7670
|
async function runFiles(project, config, files, environment, invalidates = []) {
|
|
@@ -7587,31 +7719,40 @@ function createVmThreadsPool(ctx, { execArgv, env }) {
|
|
|
7587
7719
|
return {
|
|
7588
7720
|
runTests: runWithFiles("run"),
|
|
7589
7721
|
close: async () => {
|
|
7590
|
-
var
|
|
7591
|
-
const nodeVersion = Number((
|
|
7722
|
+
var _a2;
|
|
7723
|
+
const nodeVersion = Number((_a2 = process.version.match(/v(\d+)\.(\d+)/)) == null ? void 0 : _a2[0].slice(1));
|
|
7592
7724
|
if (nodeVersion >= 16.17)
|
|
7593
7725
|
await pool.destroy();
|
|
7594
7726
|
}
|
|
7595
7727
|
};
|
|
7596
7728
|
}
|
|
7729
|
+
function getMemoryLimit(config) {
|
|
7730
|
+
const memory = nodeos.totalmem();
|
|
7731
|
+
const limit = getWorkerMemoryLimit(config);
|
|
7732
|
+
if (typeof memory === "number") {
|
|
7733
|
+
return stringToBytes(
|
|
7734
|
+
limit,
|
|
7735
|
+
config.watch ? memory / 2 : memory
|
|
7736
|
+
);
|
|
7737
|
+
}
|
|
7738
|
+
if (limit && limit > 1)
|
|
7739
|
+
return stringToBytes(limit);
|
|
7740
|
+
return null;
|
|
7741
|
+
}
|
|
7597
7742
|
|
|
7598
7743
|
const loaderPath = pathToFileURL(resolve(distDir, "./loader.js")).href;
|
|
7599
7744
|
const suppressLoaderWarningsPath = resolve(rootDir, "./suppress-warnings.cjs");
|
|
7600
7745
|
function createPool(ctx) {
|
|
7601
7746
|
const pools = {
|
|
7602
|
-
|
|
7747
|
+
forks: null,
|
|
7603
7748
|
threads: null,
|
|
7604
7749
|
browser: null,
|
|
7605
|
-
|
|
7750
|
+
vmThreads: null
|
|
7606
7751
|
};
|
|
7607
7752
|
function getDefaultPoolName(project) {
|
|
7608
7753
|
if (project.config.browser.enabled)
|
|
7609
7754
|
return "browser";
|
|
7610
|
-
|
|
7611
|
-
return "experimentalVmThreads";
|
|
7612
|
-
if (project.config.threads)
|
|
7613
|
-
return "threads";
|
|
7614
|
-
return "child_process";
|
|
7755
|
+
return project.config.pool;
|
|
7615
7756
|
}
|
|
7616
7757
|
function getPoolName([project, file]) {
|
|
7617
7758
|
for (const [glob, pool] of project.config.poolMatchGlobs || []) {
|
|
@@ -7650,10 +7791,10 @@ function createPool(ctx) {
|
|
|
7650
7791
|
}
|
|
7651
7792
|
};
|
|
7652
7793
|
const filesByPool = {
|
|
7653
|
-
|
|
7794
|
+
forks: [],
|
|
7654
7795
|
threads: [],
|
|
7655
7796
|
browser: [],
|
|
7656
|
-
|
|
7797
|
+
vmThreads: []
|
|
7657
7798
|
};
|
|
7658
7799
|
for (const spec of files) {
|
|
7659
7800
|
const pool = getPoolName(spec);
|
|
@@ -7661,23 +7802,24 @@ function createPool(ctx) {
|
|
|
7661
7802
|
throw new Error(`Unknown pool name "${pool}" for ${spec[1]}. Available pools: ${Object.keys(filesByPool).join(", ")}`);
|
|
7662
7803
|
filesByPool[pool].push(spec);
|
|
7663
7804
|
}
|
|
7664
|
-
await Promise.all(Object.entries(filesByPool).map((
|
|
7805
|
+
await Promise.all(Object.entries(filesByPool).map((entry) => {
|
|
7806
|
+
const [pool, files2] = entry;
|
|
7665
7807
|
if (!files2.length)
|
|
7666
7808
|
return null;
|
|
7667
7809
|
if (pool === "browser") {
|
|
7668
7810
|
pools.browser ?? (pools.browser = createBrowserPool(ctx));
|
|
7669
7811
|
return pools.browser.runTests(files2, invalidate);
|
|
7670
7812
|
}
|
|
7671
|
-
if (pool === "
|
|
7672
|
-
pools.
|
|
7673
|
-
return pools.
|
|
7813
|
+
if (pool === "vmThreads") {
|
|
7814
|
+
pools.vmThreads ?? (pools.vmThreads = createVmThreadsPool(ctx, options));
|
|
7815
|
+
return pools.vmThreads.runTests(files2, invalidate);
|
|
7674
7816
|
}
|
|
7675
7817
|
if (pool === "threads") {
|
|
7676
7818
|
pools.threads ?? (pools.threads = createThreadsPool(ctx, options));
|
|
7677
7819
|
return pools.threads.runTests(files2, invalidate);
|
|
7678
7820
|
}
|
|
7679
|
-
pools.
|
|
7680
|
-
return pools.
|
|
7821
|
+
pools.forks ?? (pools.forks = createChildProcessPool(ctx, options));
|
|
7822
|
+
return pools.forks.runTests(files2, invalidate);
|
|
7681
7823
|
}));
|
|
7682
7824
|
}
|
|
7683
7825
|
return {
|
|
@@ -7930,7 +8072,7 @@ const config = {
|
|
|
7930
8072
|
watch: !isCI,
|
|
7931
8073
|
globals: false,
|
|
7932
8074
|
environment: "node",
|
|
7933
|
-
|
|
8075
|
+
pool: "threads",
|
|
7934
8076
|
clearMocks: false,
|
|
7935
8077
|
restoreMocks: false,
|
|
7936
8078
|
mockReset: false,
|
|
@@ -7939,7 +8081,6 @@ const config = {
|
|
|
7939
8081
|
testTimeout: 5e3,
|
|
7940
8082
|
hookTimeout: 1e4,
|
|
7941
8083
|
teardownTimeout: 1e4,
|
|
7942
|
-
isolate: true,
|
|
7943
8084
|
watchExclude: ["**/node_modules/**", "**/dist/**"],
|
|
7944
8085
|
forceRerunTriggers: [
|
|
7945
8086
|
"**/package.json/**",
|
|
@@ -7969,67 +8110,6 @@ const config = {
|
|
|
7969
8110
|
};
|
|
7970
8111
|
const configDefaults = Object.freeze(config);
|
|
7971
8112
|
|
|
7972
|
-
function getDefaultThreadsCount(config) {
|
|
7973
|
-
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
7974
|
-
return config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
7975
|
-
}
|
|
7976
|
-
function getWorkerMemoryLimit(config) {
|
|
7977
|
-
if (config.experimentalVmWorkerMemoryLimit)
|
|
7978
|
-
return config.experimentalVmWorkerMemoryLimit;
|
|
7979
|
-
return 1 / (config.maxThreads ?? getDefaultThreadsCount(config));
|
|
7980
|
-
}
|
|
7981
|
-
function stringToBytes(input, percentageReference) {
|
|
7982
|
-
if (input === null || input === void 0)
|
|
7983
|
-
return input;
|
|
7984
|
-
if (typeof input === "string") {
|
|
7985
|
-
if (Number.isNaN(Number.parseFloat(input.slice(-1)))) {
|
|
7986
|
-
let [, numericString, trailingChars] = input.match(/(.*?)([^0-9.-]+)$/i) || [];
|
|
7987
|
-
if (trailingChars && numericString) {
|
|
7988
|
-
const numericValue = Number.parseFloat(numericString);
|
|
7989
|
-
trailingChars = trailingChars.toLowerCase();
|
|
7990
|
-
switch (trailingChars) {
|
|
7991
|
-
case "%":
|
|
7992
|
-
input = numericValue / 100;
|
|
7993
|
-
break;
|
|
7994
|
-
case "kb":
|
|
7995
|
-
case "k":
|
|
7996
|
-
return numericValue * 1e3;
|
|
7997
|
-
case "kib":
|
|
7998
|
-
return numericValue * 1024;
|
|
7999
|
-
case "mb":
|
|
8000
|
-
case "m":
|
|
8001
|
-
return numericValue * 1e3 * 1e3;
|
|
8002
|
-
case "mib":
|
|
8003
|
-
return numericValue * 1024 * 1024;
|
|
8004
|
-
case "gb":
|
|
8005
|
-
case "g":
|
|
8006
|
-
return numericValue * 1e3 * 1e3 * 1e3;
|
|
8007
|
-
case "gib":
|
|
8008
|
-
return numericValue * 1024 * 1024 * 1024;
|
|
8009
|
-
}
|
|
8010
|
-
}
|
|
8011
|
-
} else {
|
|
8012
|
-
input = Number.parseFloat(input);
|
|
8013
|
-
}
|
|
8014
|
-
}
|
|
8015
|
-
if (typeof input === "number") {
|
|
8016
|
-
if (input <= 1 && input > 0) {
|
|
8017
|
-
if (percentageReference) {
|
|
8018
|
-
return Math.floor(input * percentageReference);
|
|
8019
|
-
} else {
|
|
8020
|
-
throw new Error(
|
|
8021
|
-
"For a percentage based memory limit a percentageReference must be supplied"
|
|
8022
|
-
);
|
|
8023
|
-
}
|
|
8024
|
-
} else if (input > 1) {
|
|
8025
|
-
return Math.floor(input);
|
|
8026
|
-
} else {
|
|
8027
|
-
throw new Error('Unexpected numerical input for "experimentalVmWorkerMemoryLimit"');
|
|
8028
|
-
}
|
|
8029
|
-
}
|
|
8030
|
-
return null;
|
|
8031
|
-
}
|
|
8032
|
-
|
|
8033
8113
|
class FilesStatsCache {
|
|
8034
8114
|
cache = /* @__PURE__ */ new Map();
|
|
8035
8115
|
getStats(key) {
|
|
@@ -8246,7 +8326,7 @@ function resolveApiServerConfig(options) {
|
|
|
8246
8326
|
return api;
|
|
8247
8327
|
}
|
|
8248
8328
|
function resolveConfig(mode, options, viteConfig) {
|
|
8249
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
8329
|
+
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;
|
|
8250
8330
|
if (options.dom) {
|
|
8251
8331
|
if (((_a = viteConfig.test) == null ? void 0 : _a.environment) != null && viteConfig.test.environment !== "happy-dom") {
|
|
8252
8332
|
console.warn(
|
|
@@ -8265,7 +8345,6 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
8265
8345
|
};
|
|
8266
8346
|
resolved.inspect = Boolean(resolved.inspect);
|
|
8267
8347
|
resolved.inspectBrk = Boolean(resolved.inspectBrk);
|
|
8268
|
-
resolved.singleThread = Boolean(resolved.singleThread);
|
|
8269
8348
|
if (viteConfig.base !== "/")
|
|
8270
8349
|
resolved.base = viteConfig.base;
|
|
8271
8350
|
if (options.shard) {
|
|
@@ -8281,9 +8360,11 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
8281
8360
|
resolved.shard = { index, count };
|
|
8282
8361
|
}
|
|
8283
8362
|
if (resolved.inspect || resolved.inspectBrk) {
|
|
8284
|
-
|
|
8363
|
+
const isSingleThread = resolved.pool === "threads" && ((_c = (_b = resolved.poolOptions) == null ? void 0 : _b.threads) == null ? void 0 : _c.singleThread);
|
|
8364
|
+
const isSingleFork = resolved.pool === "forks" && ((_e = (_d = resolved.poolOptions) == null ? void 0 : _d.forks) == null ? void 0 : _e.singleFork);
|
|
8365
|
+
if (!isSingleThread && !isSingleFork) {
|
|
8285
8366
|
const inspectOption = `--inspect${resolved.inspectBrk ? "-brk" : ""}`;
|
|
8286
|
-
throw new Error(`You cannot use ${inspectOption} without "threads
|
|
8367
|
+
throw new Error(`You cannot use ${inspectOption} without "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
|
|
8287
8368
|
}
|
|
8288
8369
|
}
|
|
8289
8370
|
if (resolved.coverage.provider === "c8")
|
|
@@ -8291,7 +8372,7 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
8291
8372
|
if (resolved.coverage.provider === "v8" && resolved.coverage.enabled && isBrowserEnabled(resolved))
|
|
8292
8373
|
throw new Error("@vitest/coverage-v8 does not work with --browser. Use @vitest/coverage-istanbul instead");
|
|
8293
8374
|
resolved.deps ?? (resolved.deps = {});
|
|
8294
|
-
(
|
|
8375
|
+
(_f = resolved.deps).moduleDirectories ?? (_f.moduleDirectories = []);
|
|
8295
8376
|
resolved.deps.moduleDirectories = resolved.deps.moduleDirectories.map((dir) => {
|
|
8296
8377
|
if (!dir.startsWith("/"))
|
|
8297
8378
|
dir = `/${dir}`;
|
|
@@ -8301,17 +8382,17 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
8301
8382
|
});
|
|
8302
8383
|
if (!resolved.deps.moduleDirectories.includes("/node_modules/"))
|
|
8303
8384
|
resolved.deps.moduleDirectories.push("/node_modules/");
|
|
8304
|
-
(
|
|
8305
|
-
(
|
|
8306
|
-
(
|
|
8307
|
-
(
|
|
8308
|
-
(
|
|
8309
|
-
(
|
|
8310
|
-
(
|
|
8311
|
-
(
|
|
8312
|
-
(
|
|
8385
|
+
(_g = resolved.deps).optimizer ?? (_g.optimizer = {});
|
|
8386
|
+
(_h = resolved.deps.optimizer).ssr ?? (_h.ssr = {});
|
|
8387
|
+
(_i = resolved.deps.optimizer.ssr).enabled ?? (_i.enabled = true);
|
|
8388
|
+
(_j = resolved.deps.optimizer).web ?? (_j.web = {});
|
|
8389
|
+
(_k = resolved.deps.optimizer.web).enabled ?? (_k.enabled = true);
|
|
8390
|
+
(_l = resolved.deps).web ?? (_l.web = {});
|
|
8391
|
+
(_m = resolved.deps.web).transformAssets ?? (_m.transformAssets = true);
|
|
8392
|
+
(_n = resolved.deps.web).transformCss ?? (_n.transformCss = true);
|
|
8393
|
+
(_o = resolved.deps.web).transformGlobPattern ?? (_o.transformGlobPattern = []);
|
|
8313
8394
|
resolved.server ?? (resolved.server = {});
|
|
8314
|
-
(
|
|
8395
|
+
(_p = resolved.server).deps ?? (_p.deps = {});
|
|
8315
8396
|
const deprecatedDepsOptions = ["inline", "external", "fallbackCJS"];
|
|
8316
8397
|
deprecatedDepsOptions.forEach((option) => {
|
|
8317
8398
|
if (resolved.deps[option] === void 0)
|
|
@@ -8334,11 +8415,11 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
8334
8415
|
if ((ssrOptions == null ? void 0 : ssrOptions.noExternal) === true && resolved.server.deps.inline == null) {
|
|
8335
8416
|
resolved.server.deps.inline = true;
|
|
8336
8417
|
} else {
|
|
8337
|
-
(
|
|
8418
|
+
(_q = resolved.server.deps).inline ?? (_q.inline = []);
|
|
8338
8419
|
resolved.server.deps.inline.push(...extraInlineDeps);
|
|
8339
8420
|
}
|
|
8340
8421
|
}
|
|
8341
|
-
(
|
|
8422
|
+
(_r = resolved.server.deps).moduleDirectories ?? (_r.moduleDirectories = []);
|
|
8342
8423
|
resolved.server.deps.moduleDirectories.push(...resolved.deps.moduleDirectories);
|
|
8343
8424
|
if (resolved.runner) {
|
|
8344
8425
|
resolved.runner = resolveModule(resolved.runner, { paths: [resolved.root] }) ?? resolve(resolved.root, resolved.runner);
|
|
@@ -8352,6 +8433,8 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
8352
8433
|
);
|
|
8353
8434
|
}
|
|
8354
8435
|
resolved.testNamePattern = resolved.testNamePattern ? resolved.testNamePattern instanceof RegExp ? resolved.testNamePattern : new RegExp(resolved.testNamePattern) : void 0;
|
|
8436
|
+
if (resolved.snapshotFormat && "plugins" in resolved.snapshotFormat)
|
|
8437
|
+
resolved.snapshotFormat.plugins = [];
|
|
8355
8438
|
const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
|
|
8356
8439
|
resolved.snapshotOptions = {
|
|
8357
8440
|
snapshotFormat: resolved.snapshotFormat || {},
|
|
@@ -8360,22 +8443,52 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
8360
8443
|
// resolved inside the worker
|
|
8361
8444
|
snapshotEnvironment: null
|
|
8362
8445
|
};
|
|
8363
|
-
const memory = totalmem();
|
|
8364
|
-
const limit = getWorkerMemoryLimit(resolved);
|
|
8365
|
-
if (typeof memory === "number") {
|
|
8366
|
-
resolved.experimentalVmWorkerMemoryLimit = stringToBytes(
|
|
8367
|
-
limit,
|
|
8368
|
-
resolved.watch ? memory / 2 : memory
|
|
8369
|
-
);
|
|
8370
|
-
} else if (limit > 1) {
|
|
8371
|
-
resolved.experimentalVmWorkerMemoryLimit = stringToBytes(limit);
|
|
8372
|
-
} else ;
|
|
8373
8446
|
if (options.resolveSnapshotPath)
|
|
8374
8447
|
delete resolved.resolveSnapshotPath;
|
|
8375
|
-
if (process.env.VITEST_MAX_THREADS)
|
|
8376
|
-
resolved.
|
|
8377
|
-
|
|
8378
|
-
|
|
8448
|
+
if (process.env.VITEST_MAX_THREADS) {
|
|
8449
|
+
resolved.poolOptions = {
|
|
8450
|
+
...resolved.poolOptions,
|
|
8451
|
+
threads: {
|
|
8452
|
+
...(_s = resolved.poolOptions) == null ? void 0 : _s.threads,
|
|
8453
|
+
maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
|
|
8454
|
+
},
|
|
8455
|
+
vmThreads: {
|
|
8456
|
+
...(_t = resolved.poolOptions) == null ? void 0 : _t.vmThreads,
|
|
8457
|
+
maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
|
|
8458
|
+
}
|
|
8459
|
+
};
|
|
8460
|
+
}
|
|
8461
|
+
if (process.env.VITEST_MIN_THREADS) {
|
|
8462
|
+
resolved.poolOptions = {
|
|
8463
|
+
...resolved.poolOptions,
|
|
8464
|
+
threads: {
|
|
8465
|
+
...(_u = resolved.poolOptions) == null ? void 0 : _u.threads,
|
|
8466
|
+
minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
|
|
8467
|
+
},
|
|
8468
|
+
vmThreads: {
|
|
8469
|
+
...(_v = resolved.poolOptions) == null ? void 0 : _v.vmThreads,
|
|
8470
|
+
minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
|
|
8471
|
+
}
|
|
8472
|
+
};
|
|
8473
|
+
}
|
|
8474
|
+
if (process.env.VITEST_MAX_FORKS) {
|
|
8475
|
+
resolved.poolOptions = {
|
|
8476
|
+
...resolved.poolOptions,
|
|
8477
|
+
forks: {
|
|
8478
|
+
...(_w = resolved.poolOptions) == null ? void 0 : _w.forks,
|
|
8479
|
+
maxForks: Number.parseInt(process.env.VITEST_MAX_FORKS)
|
|
8480
|
+
}
|
|
8481
|
+
};
|
|
8482
|
+
}
|
|
8483
|
+
if (process.env.VITEST_MIN_FORKS) {
|
|
8484
|
+
resolved.poolOptions = {
|
|
8485
|
+
...resolved.poolOptions,
|
|
8486
|
+
forks: {
|
|
8487
|
+
...(_x = resolved.poolOptions) == null ? void 0 : _x.forks,
|
|
8488
|
+
minForks: Number.parseInt(process.env.VITEST_MIN_FORKS)
|
|
8489
|
+
}
|
|
8490
|
+
};
|
|
8491
|
+
}
|
|
8379
8492
|
if (mode === "benchmark") {
|
|
8380
8493
|
resolved.benchmark = {
|
|
8381
8494
|
...benchmarkConfigDefaults,
|
|
@@ -8431,19 +8544,19 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
8431
8544
|
resolved.passWithNoTests ?? (resolved.passWithNoTests = true);
|
|
8432
8545
|
resolved.css ?? (resolved.css = {});
|
|
8433
8546
|
if (typeof resolved.css === "object") {
|
|
8434
|
-
(
|
|
8435
|
-
(
|
|
8547
|
+
(_y = resolved.css).modules ?? (_y.modules = {});
|
|
8548
|
+
(_z = resolved.css.modules).classNameStrategy ?? (_z.classNameStrategy = "stable");
|
|
8436
8549
|
}
|
|
8437
8550
|
resolved.cache ?? (resolved.cache = { dir: "" });
|
|
8438
8551
|
if (resolved.cache)
|
|
8439
8552
|
resolved.cache.dir = VitestCache.resolveCacheDir(resolved.root, resolved.cache.dir, resolved.name);
|
|
8440
8553
|
resolved.sequence ?? (resolved.sequence = {});
|
|
8441
|
-
if (!((
|
|
8554
|
+
if (!((_A = resolved.sequence) == null ? void 0 : _A.sequencer)) {
|
|
8442
8555
|
resolved.sequence.sequencer = resolved.sequence.shuffle ? RandomSequencer : BaseSequencer;
|
|
8443
8556
|
}
|
|
8444
|
-
(
|
|
8557
|
+
(_B = resolved.sequence).hooks ?? (_B.hooks = "parallel");
|
|
8445
8558
|
if (resolved.sequence.sequencer === RandomSequencer)
|
|
8446
|
-
(
|
|
8559
|
+
(_C = resolved.sequence).seed ?? (_C.seed = Date.now());
|
|
8447
8560
|
resolved.typecheck = {
|
|
8448
8561
|
...configDefaults.typecheck,
|
|
8449
8562
|
...resolved.typecheck
|
|
@@ -8454,9 +8567,10 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
8454
8567
|
resolved.exclude = resolved.typecheck.exclude;
|
|
8455
8568
|
}
|
|
8456
8569
|
resolved.browser ?? (resolved.browser = {});
|
|
8457
|
-
(
|
|
8458
|
-
(
|
|
8459
|
-
(
|
|
8570
|
+
(_D = resolved.browser).enabled ?? (_D.enabled = false);
|
|
8571
|
+
(_E = resolved.browser).headless ?? (_E.headless = isCI);
|
|
8572
|
+
(_F = resolved.browser).slowHijackESM ?? (_F.slowHijackESM = true);
|
|
8573
|
+
(_G = resolved.browser).isolate ?? (_G.isolate = true);
|
|
8460
8574
|
resolved.browser.api = resolveApiServerConfig(resolved.browser) || {
|
|
8461
8575
|
port: defaultBrowserPort
|
|
8462
8576
|
};
|
|
@@ -9021,7 +9135,7 @@ createLogUpdate(process$1.stdout);
|
|
|
9021
9135
|
|
|
9022
9136
|
createLogUpdate(process$1.stderr);
|
|
9023
9137
|
|
|
9024
|
-
var version = "0.
|
|
9138
|
+
var version = "1.0.0-beta.1";
|
|
9025
9139
|
|
|
9026
9140
|
const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_$1="ERR_INVALID_PACKAGE_CONFIG",E="ERR_INVALID_PACKAGE_TARGET",I="ERR_PACKAGE_PATH_NOT_EXPORTED",R$1=/^\d+$/,O=/^(\.{1,2}|node_modules)$/i,w=/\/|\\/;var h=(r=>(r.Export="exports",r.Import="imports",r))(h||{});const f=(r,t,e,o,c)=>{if(t==null)return [];if(typeof t=="string"){const[n,...i]=t.split(w);if(n===".."||i.some(l=>O.test(l)))throw a(E,`Invalid "${r}" target "${t}" defined in the package config`);return [c?t.replace(/\*/g,c):t]}if(Array.isArray(t))return t.flatMap(n=>f(r,n,e,o,c));if(A(t)){for(const n of Object.keys(t)){if(R$1.test(n))throw a(_$1,"Cannot contain numeric property keys");if(n==="default"||o.includes(n))return f(r,t[n],e,o,c)}return []}throw a(E,`Invalid "${r}" target "${t}"`)},s="*",m=(r,t)=>{const e=r.indexOf(s),o=t.indexOf(s);return e===o?t.length>r.length:o>e};function d$1(r,t){if(!t.includes(s)&&r.hasOwnProperty(t))return [t];let e,o;for(const c of Object.keys(r))if(c.includes(s)){const[n,i,l]=c.split(s);if(l===void 0&&t.startsWith(n)&&t.endsWith(i)){const g=t.slice(n.length,-i.length||void 0);g&&(!e||m(e,c))&&(e=c,o=g);}}return [e,o]}const p=r=>Object.keys(r).reduce((t,e)=>{const o=e===""||e[0]!==".";if(t===void 0||t===o)return o;throw a(_$1,'"exports" cannot contain some keys starting with "." and some not')},void 0),u=/^\w+:/,v=(r,t,e)=>{if(!r)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof r=="string"||Array.isArray(r)||A(r)&&p(r))&&(r={".":r});const[o,c]=d$1(r,t),n=f(h.Export,r[o],t,e,c);if(n.length===0)throw a(I,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of n)if(!i.startsWith("./")&&!u.test(i))throw a(E,`Invalid "exports" target "${i}" defined in the package config`);return n};
|
|
9027
9141
|
|
|
@@ -10022,6 +10136,7 @@ function resolveOptimizerConfig(_testOptions, viteOptions, testConfig) {
|
|
|
10022
10136
|
"vitest",
|
|
10023
10137
|
// Ideally, we shouldn't optimize react in test mode, otherwise we need to optimize _every_ dependency that uses react.
|
|
10024
10138
|
"react",
|
|
10139
|
+
"vue",
|
|
10025
10140
|
...testOptions.exclude || (viteOptions == null ? void 0 : viteOptions.exclude) || []
|
|
10026
10141
|
];
|
|
10027
10142
|
const runtime = currentInclude.filter((n) => n.endsWith("jsx-dev-runtime"));
|
|
@@ -10134,7 +10249,7 @@ async function createBrowserServer(project, configFile) {
|
|
|
10134
10249
|
});
|
|
10135
10250
|
await server.listen();
|
|
10136
10251
|
await server.watcher.close();
|
|
10137
|
-
(await import('./chunk-api-setup.
|
|
10252
|
+
(await import('./chunk-api-setup.0aeabd21.js')).setup(project, server);
|
|
10138
10253
|
return server;
|
|
10139
10254
|
}
|
|
10140
10255
|
|
|
@@ -10371,75 +10486,6 @@ function SsrReplacerPlugin() {
|
|
|
10371
10486
|
};
|
|
10372
10487
|
}
|
|
10373
10488
|
|
|
10374
|
-
async function loadGlobalSetupFiles(project) {
|
|
10375
|
-
var _a;
|
|
10376
|
-
const server = project.server;
|
|
10377
|
-
const runner = project.runner;
|
|
10378
|
-
const globalSetupFiles = toArray((_a = server.config.test) == null ? void 0 : _a.globalSetup);
|
|
10379
|
-
return Promise.all(globalSetupFiles.map((file) => loadGlobalSetupFile(file, runner)));
|
|
10380
|
-
}
|
|
10381
|
-
async function loadGlobalSetupFile(file, runner) {
|
|
10382
|
-
const m = await runner.executeFile(file);
|
|
10383
|
-
for (const exp of ["default", "setup", "teardown"]) {
|
|
10384
|
-
if (m[exp] != null && typeof m[exp] !== "function")
|
|
10385
|
-
throw new Error(`invalid export in globalSetup file ${file}: ${exp} must be a function`);
|
|
10386
|
-
}
|
|
10387
|
-
if (m.default) {
|
|
10388
|
-
return {
|
|
10389
|
-
file,
|
|
10390
|
-
setup: m.default
|
|
10391
|
-
};
|
|
10392
|
-
} else if (m.setup || m.teardown) {
|
|
10393
|
-
return {
|
|
10394
|
-
file,
|
|
10395
|
-
setup: m.setup,
|
|
10396
|
-
teardown: m.teardown
|
|
10397
|
-
};
|
|
10398
|
-
} else {
|
|
10399
|
-
throw new Error(`invalid globalSetup file ${file}. Must export setup, teardown or have a default export`);
|
|
10400
|
-
}
|
|
10401
|
-
}
|
|
10402
|
-
function GlobalSetupPlugin(project, logger) {
|
|
10403
|
-
let globalSetupFiles;
|
|
10404
|
-
return {
|
|
10405
|
-
name: "vitest:global-setup-plugin",
|
|
10406
|
-
enforce: "pre",
|
|
10407
|
-
async buildStart() {
|
|
10408
|
-
var _a, _b;
|
|
10409
|
-
if (!((_a = project.server.config.test) == null ? void 0 : _a.globalSetup))
|
|
10410
|
-
return;
|
|
10411
|
-
globalSetupFiles = await loadGlobalSetupFiles(project);
|
|
10412
|
-
try {
|
|
10413
|
-
for (const globalSetupFile of globalSetupFiles) {
|
|
10414
|
-
const teardown = await ((_b = globalSetupFile.setup) == null ? void 0 : _b.call(globalSetupFile));
|
|
10415
|
-
if (teardown == null || !!globalSetupFile.teardown)
|
|
10416
|
-
continue;
|
|
10417
|
-
if (typeof teardown !== "function")
|
|
10418
|
-
throw new Error(`invalid return value in globalSetup file ${globalSetupFile.file}. Must return a function`);
|
|
10419
|
-
globalSetupFile.teardown = teardown;
|
|
10420
|
-
}
|
|
10421
|
-
} catch (e) {
|
|
10422
|
-
logger.error(`
|
|
10423
|
-
${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
10424
|
-
await logger.printError(e);
|
|
10425
|
-
process.exit(1);
|
|
10426
|
-
}
|
|
10427
|
-
},
|
|
10428
|
-
async buildEnd() {
|
|
10429
|
-
var _a;
|
|
10430
|
-
if (globalSetupFiles == null ? void 0 : globalSetupFiles.length) {
|
|
10431
|
-
for (const globalSetupFile of globalSetupFiles.reverse()) {
|
|
10432
|
-
try {
|
|
10433
|
-
await ((_a = globalSetupFile.teardown) == null ? void 0 : _a.call(globalSetupFile));
|
|
10434
|
-
} catch (error) {
|
|
10435
|
-
logger.error(`error during global teardown of ${globalSetupFile.file}`, error);
|
|
10436
|
-
}
|
|
10437
|
-
}
|
|
10438
|
-
}
|
|
10439
|
-
}
|
|
10440
|
-
};
|
|
10441
|
-
}
|
|
10442
|
-
|
|
10443
10489
|
function VitestResolver(ctx) {
|
|
10444
10490
|
return {
|
|
10445
10491
|
name: "vitest:resolve-root",
|
|
@@ -10570,7 +10616,6 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
10570
10616
|
SsrReplacerPlugin(),
|
|
10571
10617
|
...CSSEnablerPlugin(project),
|
|
10572
10618
|
CoverageTransform(project.ctx),
|
|
10573
|
-
GlobalSetupPlugin(project, project.ctx.logger),
|
|
10574
10619
|
MocksPlugin(),
|
|
10575
10620
|
VitestResolver(project.ctx),
|
|
10576
10621
|
VitestOptimizer()
|
|
@@ -10592,6 +10637,33 @@ async function createViteServer(inlineConfig) {
|
|
|
10592
10637
|
return server;
|
|
10593
10638
|
}
|
|
10594
10639
|
|
|
10640
|
+
async function loadGlobalSetupFiles(project) {
|
|
10641
|
+
var _a;
|
|
10642
|
+
const globalSetupFiles = toArray$1((_a = project.server.config.test) == null ? void 0 : _a.globalSetup);
|
|
10643
|
+
return Promise.all(globalSetupFiles.map((file) => loadGlobalSetupFile(file, project.runner)));
|
|
10644
|
+
}
|
|
10645
|
+
async function loadGlobalSetupFile(file, runner) {
|
|
10646
|
+
const m = await runner.executeFile(file);
|
|
10647
|
+
for (const exp of ["default", "setup", "teardown"]) {
|
|
10648
|
+
if (m[exp] != null && typeof m[exp] !== "function")
|
|
10649
|
+
throw new Error(`invalid export in globalSetup file ${file}: ${exp} must be a function`);
|
|
10650
|
+
}
|
|
10651
|
+
if (m.default) {
|
|
10652
|
+
return {
|
|
10653
|
+
file,
|
|
10654
|
+
setup: m.default
|
|
10655
|
+
};
|
|
10656
|
+
} else if (m.setup || m.teardown) {
|
|
10657
|
+
return {
|
|
10658
|
+
file,
|
|
10659
|
+
setup: m.setup,
|
|
10660
|
+
teardown: m.teardown
|
|
10661
|
+
};
|
|
10662
|
+
} else {
|
|
10663
|
+
throw new Error(`invalid globalSetup file ${file}. Must export setup, teardown or have a default export`);
|
|
10664
|
+
}
|
|
10665
|
+
}
|
|
10666
|
+
|
|
10595
10667
|
async function initializeProject(workspacePath, ctx, options) {
|
|
10596
10668
|
const project = new WorkspaceProject(workspacePath, ctx);
|
|
10597
10669
|
const configFile = options.extends ? resolve(dirname(options.workspaceConfigPath), options.extends) : typeof workspacePath === "number" || workspacePath.endsWith("/") ? false : workspacePath;
|
|
@@ -10626,12 +10698,53 @@ class WorkspaceProject {
|
|
|
10626
10698
|
closingPromise;
|
|
10627
10699
|
browserProvider;
|
|
10628
10700
|
testFilesList = [];
|
|
10701
|
+
_globalSetupInit = false;
|
|
10702
|
+
_globalSetups = [];
|
|
10629
10703
|
getName() {
|
|
10630
10704
|
return this.config.name || "";
|
|
10631
10705
|
}
|
|
10632
10706
|
isCore() {
|
|
10633
10707
|
return this.ctx.getCoreWorkspaceProject() === this;
|
|
10634
10708
|
}
|
|
10709
|
+
async initializeGlobalSetup() {
|
|
10710
|
+
var _a;
|
|
10711
|
+
if (this._globalSetupInit)
|
|
10712
|
+
return;
|
|
10713
|
+
this._globalSetupInit = true;
|
|
10714
|
+
this._globalSetups = await loadGlobalSetupFiles(this);
|
|
10715
|
+
try {
|
|
10716
|
+
for (const globalSetupFile of this._globalSetups) {
|
|
10717
|
+
const teardown = await ((_a = globalSetupFile.setup) == null ? void 0 : _a.call(globalSetupFile));
|
|
10718
|
+
if (teardown == null || !!globalSetupFile.teardown)
|
|
10719
|
+
continue;
|
|
10720
|
+
if (typeof teardown !== "function")
|
|
10721
|
+
throw new Error(`invalid return value in globalSetup file ${globalSetupFile.file}. Must return a function`);
|
|
10722
|
+
globalSetupFile.teardown = teardown;
|
|
10723
|
+
}
|
|
10724
|
+
} catch (e) {
|
|
10725
|
+
this.logger.error(`
|
|
10726
|
+
${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
10727
|
+
await this.logger.printError(e);
|
|
10728
|
+
process.exit(1);
|
|
10729
|
+
}
|
|
10730
|
+
}
|
|
10731
|
+
async teardownGlobalSetup() {
|
|
10732
|
+
var _a;
|
|
10733
|
+
if (!this._globalSetupInit || !this._globalSetups.length)
|
|
10734
|
+
return;
|
|
10735
|
+
for (const globalSetupFile of this._globalSetups.reverse()) {
|
|
10736
|
+
try {
|
|
10737
|
+
await ((_a = globalSetupFile.teardown) == null ? void 0 : _a.call(globalSetupFile));
|
|
10738
|
+
} catch (error) {
|
|
10739
|
+
this.logger.error(`error during global teardown of ${globalSetupFile.file}`, error);
|
|
10740
|
+
await this.logger.printError(error);
|
|
10741
|
+
process.exitCode = 1;
|
|
10742
|
+
}
|
|
10743
|
+
}
|
|
10744
|
+
}
|
|
10745
|
+
get logger() {
|
|
10746
|
+
return this.ctx.logger;
|
|
10747
|
+
}
|
|
10635
10748
|
// it's possible that file path was imported with different queries (?raw, ?url, etc)
|
|
10636
10749
|
getModulesByFilepath(file) {
|
|
10637
10750
|
var _a;
|
|
@@ -10821,6 +10934,8 @@ class WorkspaceProject {
|
|
|
10821
10934
|
{
|
|
10822
10935
|
...this.config,
|
|
10823
10936
|
coverage: this.ctx.config.coverage,
|
|
10937
|
+
pool: this.ctx.config.pool,
|
|
10938
|
+
poolOptions: this.ctx.config.poolOptions,
|
|
10824
10939
|
reporters: [],
|
|
10825
10940
|
deps: {
|
|
10826
10941
|
...this.config.deps,
|
|
@@ -10859,7 +10974,8 @@ class WorkspaceProject {
|
|
|
10859
10974
|
this.closingPromise = Promise.all([
|
|
10860
10975
|
this.server.close(),
|
|
10861
10976
|
(_a = this.typechecker) == null ? void 0 : _a.stop(),
|
|
10862
|
-
(_b = this.browser) == null ? void 0 : _b.close()
|
|
10977
|
+
(_b = this.browser) == null ? void 0 : _b.close(),
|
|
10978
|
+
this.teardownGlobalSetup()
|
|
10863
10979
|
].filter(Boolean));
|
|
10864
10980
|
}
|
|
10865
10981
|
return this.closingPromise;
|
|
@@ -11046,9 +11162,7 @@ class Vitest {
|
|
|
11046
11162
|
"allowOnly",
|
|
11047
11163
|
"sequence",
|
|
11048
11164
|
"testTimeout",
|
|
11049
|
-
"
|
|
11050
|
-
"singleThread",
|
|
11051
|
-
"isolate",
|
|
11165
|
+
"pool",
|
|
11052
11166
|
"globals",
|
|
11053
11167
|
"mode"
|
|
11054
11168
|
];
|
|
@@ -11188,6 +11302,9 @@ class Vitest {
|
|
|
11188
11302
|
return [];
|
|
11189
11303
|
return Array.from(projects).map((project) => [project, file]);
|
|
11190
11304
|
}
|
|
11305
|
+
async initializeGlobalSetup(paths) {
|
|
11306
|
+
await Promise.all(paths.map(async ([project]) => project.initializeGlobalSetup()));
|
|
11307
|
+
}
|
|
11191
11308
|
async runFiles(paths) {
|
|
11192
11309
|
const filepaths = paths.map(([, file]) => file);
|
|
11193
11310
|
this.state.collectPaths(filepaths);
|
|
@@ -11202,6 +11319,7 @@ class Vitest {
|
|
|
11202
11319
|
this.invalidates.clear();
|
|
11203
11320
|
this.snapshot.clear();
|
|
11204
11321
|
this.state.clearErrors();
|
|
11322
|
+
await this.initializeGlobalSetup(paths);
|
|
11205
11323
|
try {
|
|
11206
11324
|
await this.pool.runTests(paths, invalidates);
|
|
11207
11325
|
} catch (err) {
|
|
@@ -11610,7 +11728,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
11610
11728
|
try {
|
|
11611
11729
|
await ctx.setServer(options, server, userConfig);
|
|
11612
11730
|
if (options.api && options.watch)
|
|
11613
|
-
(await import('./chunk-api-setup.
|
|
11731
|
+
(await import('./chunk-api-setup.0aeabd21.js')).setup(ctx);
|
|
11614
11732
|
} catch (err) {
|
|
11615
11733
|
await ctx.logger.printError(err, { fullStack: true });
|
|
11616
11734
|
process.exit(1);
|
|
@@ -11620,7 +11738,6 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
11620
11738
|
}
|
|
11621
11739
|
},
|
|
11622
11740
|
SsrReplacerPlugin(),
|
|
11623
|
-
GlobalSetupPlugin(ctx, ctx.logger),
|
|
11624
11741
|
...CSSEnablerPlugin(ctx),
|
|
11625
11742
|
CoverageTransform(ctx),
|
|
11626
11743
|
options.ui ? await UIPlugin() : null,
|
|
@@ -18055,8 +18172,6 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
|
|
|
18055
18172
|
options.browser = { enabled: true, name: options.browser };
|
|
18056
18173
|
if (typeof options.browser === "object" && !("enabled" in options.browser))
|
|
18057
18174
|
options.browser.enabled = true;
|
|
18058
|
-
if ("threads" in options && options.experimentalVmThreads)
|
|
18059
|
-
throw new Error('Cannot use both "threads" (or "no-threads") and "experimentalVmThreads" at the same time.');
|
|
18060
18175
|
const ctx = await createVitest(mode, options, viteOverrides);
|
|
18061
18176
|
if (mode === "test" && ctx.config.coverage.enabled) {
|
|
18062
18177
|
const provider = ctx.config.coverage.provider || "v8";
|