vitest 1.0.4 → 1.1.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/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/child.js +3 -4
- package/dist/chunks/{integrations-globals.8mr2ENps.js → integrations-globals.nOa2-o57.js} +2 -2
- package/dist/cli.js +12 -4
- package/dist/config.cjs +1 -0
- package/dist/config.d.ts +25 -24
- package/dist/config.js +1 -0
- package/dist/coverage.d.ts +1 -1
- package/dist/entry-vm.js +2 -2
- package/dist/entry.js +2 -2
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -2
- package/dist/execute.d.ts +10 -2
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/node.d.ts +2 -2
- package/dist/node.js +3 -3
- package/dist/{reporters-OH1c16Kq.d.ts → reporters-O4LBziQ_.d.ts} +34 -1
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +1 -1
- package/dist/runners.d.ts +3 -4
- package/dist/runners.js +19 -14
- package/dist/{suite-9ReVEt_h.d.ts → suite-dF4WyktM.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/vendor/{environments.v4R4vGad.js → environments.QJtma9XQ.js} +6 -7
- package/dist/vendor/{execute.1R_t2FPL.js → execute.vStuEOaI.js} +30 -8
- package/dist/vendor/{index.uQelX_YY.js → index.n6c6aC2Y.js} +1 -1
- package/dist/vendor/{loader.zIj6SiI8.js → loader.L9CYwKn1.js} +1 -1
- package/dist/vendor/{node.vEetZgP7.js → node.d5m7SYoI.js} +109 -87
- package/dist/vendor/{reporters.r0gTYN3L.js → reporters.oUR9etwS.js} +12 -5
- package/dist/vendor/{vi.pk4NToBt.js → vi.ciwVQ0al.js} +7 -3
- package/dist/vm.js +3 -4
- package/dist/worker.js +3 -4
- package/package.json +8 -8
|
@@ -39,12 +39,12 @@ import { isCI, provider as provider$1 } from 'std-env';
|
|
|
39
39
|
import ge from 'module';
|
|
40
40
|
import { ancestor, simple, findNodeAround } from 'acorn-walk';
|
|
41
41
|
import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, hasFailed } from '@vitest/runner/utils';
|
|
42
|
-
import { R as ReportersMap, B as BenchmarkReportsMap, s as stripAnsi, a as ansiStyles, b as sliceAnsi, d as divider, F as F_POINTER, c as cliTruncate } from './reporters.
|
|
42
|
+
import { R as ReportersMap, B as BenchmarkReportsMap, s as stripAnsi, a as ansiStyles, b as sliceAnsi, d as divider, F as F_POINTER, c as cliTruncate } from './reporters.oUR9etwS.js';
|
|
43
43
|
import crypto, { createHash } from 'node:crypto';
|
|
44
44
|
import require$$0$3 from 'assert';
|
|
45
45
|
import MagicString from 'magic-string';
|
|
46
46
|
import { stripLiteral } from 'strip-literal';
|
|
47
|
-
import { g as getEnvPackageName } from './environments.
|
|
47
|
+
import { g as getEnvPackageName } from './environments.QJtma9XQ.js';
|
|
48
48
|
import readline from 'node:readline';
|
|
49
49
|
import require$$0$4 from 'readline';
|
|
50
50
|
|
|
@@ -63,7 +63,7 @@ function _mergeNamespaces(n, m) {
|
|
|
63
63
|
return Object.freeze(n);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
var version$1 = "1.
|
|
66
|
+
var version$1 = "1.1.1";
|
|
67
67
|
|
|
68
68
|
const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
|
|
69
69
|
async function ensurePackageInstalled(dependency, root) {
|
|
@@ -3251,11 +3251,12 @@ function stringifyRegex(input) {
|
|
|
3251
3251
|
return `$$vitest:${input.toString()}`;
|
|
3252
3252
|
}
|
|
3253
3253
|
function createChildProcessPool(ctx, { execArgv, env, forksPath }) {
|
|
3254
|
-
var _a
|
|
3254
|
+
var _a;
|
|
3255
3255
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
3256
3256
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
3257
|
-
const
|
|
3258
|
-
const
|
|
3257
|
+
const poolOptions = ((_a = ctx.config.poolOptions) == null ? void 0 : _a.forks) ?? {};
|
|
3258
|
+
const maxThreads = poolOptions.maxForks ?? ctx.config.maxWorkers ?? threadsCount;
|
|
3259
|
+
const minThreads = poolOptions.minForks ?? ctx.config.minWorkers ?? threadsCount;
|
|
3259
3260
|
const options = {
|
|
3260
3261
|
runtime: "child_process",
|
|
3261
3262
|
filename: forksPath,
|
|
@@ -3263,17 +3264,16 @@ function createChildProcessPool(ctx, { execArgv, env, forksPath }) {
|
|
|
3263
3264
|
minThreads,
|
|
3264
3265
|
env,
|
|
3265
3266
|
execArgv: [
|
|
3266
|
-
...
|
|
3267
|
+
...poolOptions.execArgv ?? [],
|
|
3267
3268
|
...execArgv
|
|
3268
3269
|
],
|
|
3269
|
-
terminateTimeout: ctx.config.teardownTimeout
|
|
3270
|
+
terminateTimeout: ctx.config.teardownTimeout,
|
|
3271
|
+
concurrentTasksPerWorker: 1
|
|
3270
3272
|
};
|
|
3271
|
-
|
|
3273
|
+
const isolated = poolOptions.isolate ?? true;
|
|
3274
|
+
if (isolated)
|
|
3272
3275
|
options.isolateWorkers = true;
|
|
3273
|
-
|
|
3274
|
-
}
|
|
3275
|
-
if ((_j = (_i = ctx.config.poolOptions) == null ? void 0 : _i.forks) == null ? void 0 : _j.singleFork) {
|
|
3276
|
-
options.concurrentTasksPerWorker = 1;
|
|
3276
|
+
if (poolOptions.singleFork || !ctx.config.fileParallelism) {
|
|
3277
3277
|
options.maxThreads = 1;
|
|
3278
3278
|
options.minThreads = 1;
|
|
3279
3279
|
}
|
|
@@ -3299,7 +3299,7 @@ function createChildProcessPool(ctx, { execArgv, env, forksPath }) {
|
|
|
3299
3299
|
if (error instanceof Error && /Failed to terminate worker/.test(error.message))
|
|
3300
3300
|
ctx.state.addProcessTimeoutCause(`Failed to terminate worker while running ${files.join(", ")}.`);
|
|
3301
3301
|
else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message))
|
|
3302
|
-
ctx.state.cancelFiles(files, ctx.config.root, project.
|
|
3302
|
+
ctx.state.cancelFiles(files, ctx.config.root, project.config.name);
|
|
3303
3303
|
else
|
|
3304
3304
|
throw error;
|
|
3305
3305
|
} finally {
|
|
@@ -3307,7 +3307,6 @@ function createChildProcessPool(ctx, { execArgv, env, forksPath }) {
|
|
|
3307
3307
|
}
|
|
3308
3308
|
}
|
|
3309
3309
|
return async (specs, invalidates) => {
|
|
3310
|
-
var _a2, _b2;
|
|
3311
3310
|
ctx.onCancel(() => pool.cancelPendingTasks());
|
|
3312
3311
|
const configs = /* @__PURE__ */ new Map();
|
|
3313
3312
|
const getConfig = (project) => {
|
|
@@ -3329,18 +3328,18 @@ function createChildProcessPool(ctx, { execArgv, env, forksPath }) {
|
|
|
3329
3328
|
workspaceMap.set(file, workspaceFiles);
|
|
3330
3329
|
}
|
|
3331
3330
|
const singleFork = specs.filter(([project]) => {
|
|
3332
|
-
var
|
|
3333
|
-
return (
|
|
3331
|
+
var _a2, _b;
|
|
3332
|
+
return (_b = (_a2 = project.config.poolOptions) == null ? void 0 : _a2.forks) == null ? void 0 : _b.singleFork;
|
|
3334
3333
|
});
|
|
3335
3334
|
const multipleForks = specs.filter(([project]) => {
|
|
3336
|
-
var
|
|
3337
|
-
return !((
|
|
3335
|
+
var _a2, _b;
|
|
3336
|
+
return !((_b = (_a2 = project.config.poolOptions) == null ? void 0 : _a2.forks) == null ? void 0 : _b.singleFork);
|
|
3338
3337
|
});
|
|
3339
3338
|
if (multipleForks.length) {
|
|
3340
3339
|
const filesByEnv = await groupFilesByEnv(multipleForks);
|
|
3341
3340
|
const files = Object.values(filesByEnv).flat();
|
|
3342
3341
|
const results = [];
|
|
3343
|
-
if (
|
|
3342
|
+
if (isolated) {
|
|
3344
3343
|
results.push(...await Promise.allSettled(files.map(({ file, environment, project }) => runFiles(project, getConfig(project), [file], environment, invalidates))));
|
|
3345
3344
|
} else {
|
|
3346
3345
|
const grouped = groupBy(files, ({ project, environment }) => project.getName() + environment.name + JSON.stringify(environment.options));
|
|
@@ -3402,31 +3401,31 @@ function createWorkerChannel$1(project) {
|
|
|
3402
3401
|
return { workerPort, port };
|
|
3403
3402
|
}
|
|
3404
3403
|
function createThreadsPool(ctx, { execArgv, env, workerPath }) {
|
|
3405
|
-
var _a
|
|
3404
|
+
var _a;
|
|
3406
3405
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
3407
3406
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
3408
|
-
const
|
|
3409
|
-
const
|
|
3407
|
+
const poolOptions = ((_a = ctx.config.poolOptions) == null ? void 0 : _a.threads) ?? {};
|
|
3408
|
+
const maxThreads = poolOptions.maxThreads ?? ctx.config.maxWorkers ?? threadsCount;
|
|
3409
|
+
const minThreads = poolOptions.minThreads ?? ctx.config.minWorkers ?? threadsCount;
|
|
3410
3410
|
const options = {
|
|
3411
3411
|
filename: workerPath,
|
|
3412
3412
|
// TODO: investigate further
|
|
3413
3413
|
// It seems atomics introduced V8 Fatal Error https://github.com/vitest-dev/vitest/issues/1191
|
|
3414
|
-
useAtomics:
|
|
3414
|
+
useAtomics: poolOptions.useAtomics ?? false,
|
|
3415
3415
|
maxThreads,
|
|
3416
3416
|
minThreads,
|
|
3417
3417
|
env,
|
|
3418
3418
|
execArgv: [
|
|
3419
|
-
...
|
|
3419
|
+
...poolOptions.execArgv ?? [],
|
|
3420
3420
|
...execArgv
|
|
3421
3421
|
],
|
|
3422
|
-
terminateTimeout: ctx.config.teardownTimeout
|
|
3422
|
+
terminateTimeout: ctx.config.teardownTimeout,
|
|
3423
|
+
concurrentTasksPerWorker: 1
|
|
3423
3424
|
};
|
|
3424
|
-
|
|
3425
|
+
const isolated = poolOptions.isolate ?? true;
|
|
3426
|
+
if (isolated)
|
|
3425
3427
|
options.isolateWorkers = true;
|
|
3426
|
-
|
|
3427
|
-
}
|
|
3428
|
-
if ((_l = (_k = ctx.config.poolOptions) == null ? void 0 : _k.threads) == null ? void 0 : _l.singleThread) {
|
|
3429
|
-
options.concurrentTasksPerWorker = 1;
|
|
3428
|
+
if (poolOptions.singleThread || !ctx.config.fileParallelism) {
|
|
3430
3429
|
options.maxThreads = 1;
|
|
3431
3430
|
options.minThreads = 1;
|
|
3432
3431
|
}
|
|
@@ -3453,7 +3452,7 @@ function createThreadsPool(ctx, { execArgv, env, workerPath }) {
|
|
|
3453
3452
|
if (error instanceof Error && /Failed to terminate worker/.test(error.message))
|
|
3454
3453
|
ctx.state.addProcessTimeoutCause(`Failed to terminate worker while running ${files.join(", ")}.`);
|
|
3455
3454
|
else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message))
|
|
3456
|
-
ctx.state.cancelFiles(files, ctx.config.root, project.
|
|
3455
|
+
ctx.state.cancelFiles(files, ctx.config.root, project.config.name);
|
|
3457
3456
|
else
|
|
3458
3457
|
throw error;
|
|
3459
3458
|
} finally {
|
|
@@ -3462,7 +3461,6 @@ function createThreadsPool(ctx, { execArgv, env, workerPath }) {
|
|
|
3462
3461
|
}
|
|
3463
3462
|
}
|
|
3464
3463
|
return async (specs, invalidates) => {
|
|
3465
|
-
var _a2, _b2;
|
|
3466
3464
|
ctx.onCancel(() => pool.cancelPendingTasks());
|
|
3467
3465
|
const configs = /* @__PURE__ */ new Map();
|
|
3468
3466
|
const getConfig = (project) => {
|
|
@@ -3479,18 +3477,18 @@ function createThreadsPool(ctx, { execArgv, env, workerPath }) {
|
|
|
3479
3477
|
workspaceMap.set(file, workspaceFiles);
|
|
3480
3478
|
}
|
|
3481
3479
|
const singleThreads = specs.filter(([project]) => {
|
|
3482
|
-
var
|
|
3483
|
-
return (
|
|
3480
|
+
var _a2, _b;
|
|
3481
|
+
return (_b = (_a2 = project.config.poolOptions) == null ? void 0 : _a2.threads) == null ? void 0 : _b.singleThread;
|
|
3484
3482
|
});
|
|
3485
3483
|
const multipleThreads = specs.filter(([project]) => {
|
|
3486
|
-
var
|
|
3487
|
-
return !((
|
|
3484
|
+
var _a2, _b;
|
|
3485
|
+
return !((_b = (_a2 = project.config.poolOptions) == null ? void 0 : _a2.threads) == null ? void 0 : _b.singleThread);
|
|
3488
3486
|
});
|
|
3489
3487
|
if (multipleThreads.length) {
|
|
3490
3488
|
const filesByEnv = await groupFilesByEnv(multipleThreads);
|
|
3491
3489
|
const files = Object.values(filesByEnv).flat();
|
|
3492
3490
|
const results = [];
|
|
3493
|
-
if (
|
|
3491
|
+
if (isolated) {
|
|
3494
3492
|
results.push(...await Promise.allSettled(files.map(({ file, environment, project }) => runFiles(project, getConfig(project), [file], environment, invalidates))));
|
|
3495
3493
|
} else {
|
|
3496
3494
|
const grouped = groupBy(files, ({ project, environment }) => project.getName() + environment.name + JSON.stringify(environment.options));
|
|
@@ -3568,7 +3566,7 @@ function createBrowserPool(ctx) {
|
|
|
3568
3566
|
if (project.config.browser.isolate) {
|
|
3569
3567
|
for (const path of paths) {
|
|
3570
3568
|
if (isCancelled) {
|
|
3571
|
-
ctx.state.cancelFiles(files.slice(paths.indexOf(path)), ctx.config.root, project.
|
|
3569
|
+
ctx.state.cancelFiles(files.slice(paths.indexOf(path)), ctx.config.root, project.config.name);
|
|
3572
3570
|
break;
|
|
3573
3571
|
}
|
|
3574
3572
|
const url = new URL("/", origin);
|
|
@@ -3690,16 +3688,17 @@ function createWorkerChannel(project) {
|
|
|
3690
3688
|
return { workerPort, port };
|
|
3691
3689
|
}
|
|
3692
3690
|
function createVmThreadsPool(ctx, { execArgv, env, vmPath }) {
|
|
3693
|
-
var _a
|
|
3691
|
+
var _a;
|
|
3694
3692
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
3695
3693
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
3696
|
-
const
|
|
3697
|
-
const
|
|
3694
|
+
const poolOptions = ((_a = ctx.config.poolOptions) == null ? void 0 : _a.vmThreads) ?? {};
|
|
3695
|
+
const maxThreads = poolOptions.maxThreads ?? ctx.config.maxWorkers ?? threadsCount;
|
|
3696
|
+
const minThreads = poolOptions.minThreads ?? ctx.config.minWorkers ?? threadsCount;
|
|
3698
3697
|
const options = {
|
|
3699
3698
|
filename: vmPath,
|
|
3700
3699
|
// TODO: investigate further
|
|
3701
3700
|
// It seems atomics introduced V8 Fatal Error https://github.com/vitest-dev/vitest/issues/1191
|
|
3702
|
-
useAtomics:
|
|
3701
|
+
useAtomics: poolOptions.useAtomics ?? false,
|
|
3703
3702
|
maxThreads,
|
|
3704
3703
|
minThreads,
|
|
3705
3704
|
env,
|
|
@@ -3708,14 +3707,14 @@ function createVmThreadsPool(ctx, { execArgv, env, vmPath }) {
|
|
|
3708
3707
|
"--experimental-vm-modules",
|
|
3709
3708
|
"--require",
|
|
3710
3709
|
suppressWarningsPath,
|
|
3711
|
-
...
|
|
3710
|
+
...poolOptions.execArgv ?? [],
|
|
3712
3711
|
...execArgv
|
|
3713
3712
|
],
|
|
3714
3713
|
terminateTimeout: ctx.config.teardownTimeout,
|
|
3714
|
+
concurrentTasksPerWorker: 1,
|
|
3715
3715
|
maxMemoryLimitBeforeRecycle: getMemoryLimit(ctx.config) || void 0
|
|
3716
3716
|
};
|
|
3717
|
-
if (
|
|
3718
|
-
options.concurrentTasksPerWorker = 1;
|
|
3717
|
+
if (poolOptions.singleThread || !ctx.config.fileParallelism) {
|
|
3719
3718
|
options.maxThreads = 1;
|
|
3720
3719
|
options.minThreads = 1;
|
|
3721
3720
|
}
|
|
@@ -3742,7 +3741,7 @@ function createVmThreadsPool(ctx, { execArgv, env, vmPath }) {
|
|
|
3742
3741
|
if (error instanceof Error && /Failed to terminate worker/.test(error.message))
|
|
3743
3742
|
ctx.state.addProcessTimeoutCause(`Failed to terminate worker while running ${files.join(", ")}.`);
|
|
3744
3743
|
else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message))
|
|
3745
|
-
ctx.state.cancelFiles(files, ctx.config.root, project.
|
|
3744
|
+
ctx.state.cancelFiles(files, ctx.config.root, project.config.name);
|
|
3746
3745
|
else
|
|
3747
3746
|
throw error;
|
|
3748
3747
|
} finally {
|
|
@@ -3751,6 +3750,7 @@ function createVmThreadsPool(ctx, { execArgv, env, vmPath }) {
|
|
|
3751
3750
|
}
|
|
3752
3751
|
}
|
|
3753
3752
|
return async (specs, invalidates) => {
|
|
3753
|
+
ctx.onCancel(() => pool.cancelPendingTasks());
|
|
3754
3754
|
const configs = /* @__PURE__ */ new Map();
|
|
3755
3755
|
const getConfig = (project) => {
|
|
3756
3756
|
if (configs.has(project))
|
|
@@ -4351,7 +4351,7 @@ function createTypecheckPool(ctx) {
|
|
|
4351
4351
|
setTimeout(() => {
|
|
4352
4352
|
resolve(false);
|
|
4353
4353
|
clearInterval(_i);
|
|
4354
|
-
}, 500);
|
|
4354
|
+
}, 500).unref();
|
|
4355
4355
|
});
|
|
4356
4356
|
const triggered = await _p;
|
|
4357
4357
|
if (project.typechecker && !triggered) {
|
|
@@ -4750,6 +4750,7 @@ const fakeTimersDefaults = {
|
|
|
4750
4750
|
};
|
|
4751
4751
|
const config = {
|
|
4752
4752
|
allowOnly: !isCI,
|
|
4753
|
+
isolate: true,
|
|
4753
4754
|
watch: !isCI,
|
|
4754
4755
|
globals: false,
|
|
4755
4756
|
environment: "node",
|
|
@@ -4978,6 +4979,11 @@ const extraInlineDeps = [
|
|
|
4978
4979
|
// Nuxt
|
|
4979
4980
|
"@nuxt/test-utils"
|
|
4980
4981
|
];
|
|
4982
|
+
function resolvePath(path, root) {
|
|
4983
|
+
return normalize(
|
|
4984
|
+
resolveModule(path, { paths: [root] }) ?? resolve(root, path)
|
|
4985
|
+
);
|
|
4986
|
+
}
|
|
4981
4987
|
function resolveApiServerConfig(options) {
|
|
4982
4988
|
let api;
|
|
4983
4989
|
if (options.ui && !options.api)
|
|
@@ -5040,12 +5046,17 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
5040
5046
|
throw new Error("--shard <index> must be a positive number less then <count>");
|
|
5041
5047
|
resolved.shard = { index, count };
|
|
5042
5048
|
}
|
|
5049
|
+
resolved.fileParallelism ?? (resolved.fileParallelism = true);
|
|
5050
|
+
if (!resolved.fileParallelism) {
|
|
5051
|
+
resolved.maxWorkers = 1;
|
|
5052
|
+
resolved.minWorkers = 1;
|
|
5053
|
+
}
|
|
5043
5054
|
if (resolved.inspect || resolved.inspectBrk) {
|
|
5044
5055
|
const isSingleThread = resolved.pool === "threads" && ((_c = (_b = resolved.poolOptions) == null ? void 0 : _b.threads) == null ? void 0 : _c.singleThread);
|
|
5045
5056
|
const isSingleFork = resolved.pool === "forks" && ((_e = (_d = resolved.poolOptions) == null ? void 0 : _d.forks) == null ? void 0 : _e.singleFork);
|
|
5046
|
-
if (!isSingleThread && !isSingleFork) {
|
|
5057
|
+
if (resolved.fileParallelism && !isSingleThread && !isSingleFork) {
|
|
5047
5058
|
const inspectOption = `--inspect${resolved.inspectBrk ? "-brk" : ""}`;
|
|
5048
|
-
throw new Error(`You cannot use ${inspectOption} without "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
|
|
5059
|
+
throw new Error(`You cannot use ${inspectOption} without "--no-file-parallelism", "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
|
|
5049
5060
|
}
|
|
5050
5061
|
}
|
|
5051
5062
|
if (resolved.coverage.provider === "c8")
|
|
@@ -5091,6 +5102,8 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
5091
5102
|
if (resolved.server.deps[option] === void 0)
|
|
5092
5103
|
resolved.server.deps[option] = resolved.deps[option];
|
|
5093
5104
|
});
|
|
5105
|
+
if (resolved.cliExclude)
|
|
5106
|
+
resolved.exclude.push(...resolved.cliExclude);
|
|
5094
5107
|
if (resolved.server.deps.inline !== true) {
|
|
5095
5108
|
const ssrOptions = viteConfig.ssr;
|
|
5096
5109
|
if ((ssrOptions == null ? void 0 : ssrOptions.noExternal) === true && resolved.server.deps.inline == null) {
|
|
@@ -5102,9 +5115,8 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
5102
5115
|
}
|
|
5103
5116
|
(_r = resolved.server.deps).moduleDirectories ?? (_r.moduleDirectories = []);
|
|
5104
5117
|
resolved.server.deps.moduleDirectories.push(...resolved.deps.moduleDirectories);
|
|
5105
|
-
if (resolved.runner)
|
|
5106
|
-
resolved.runner =
|
|
5107
|
-
}
|
|
5118
|
+
if (resolved.runner)
|
|
5119
|
+
resolved.runner = resolvePath(resolved.runner, resolved.root);
|
|
5108
5120
|
resolved.testNamePattern = resolved.testNamePattern ? resolved.testNamePattern instanceof RegExp ? resolved.testNamePattern : new RegExp(resolved.testNamePattern) : void 0;
|
|
5109
5121
|
if (resolved.snapshotFormat && "plugins" in resolved.snapshotFormat)
|
|
5110
5122
|
resolved.snapshotFormat.plugins = [];
|
|
@@ -5164,17 +5176,14 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
5164
5176
|
}
|
|
5165
5177
|
};
|
|
5166
5178
|
}
|
|
5167
|
-
if (
|
|
5168
|
-
resolved.
|
|
5169
|
-
resolveModule(resolved.pool, { paths: [resolved.root] }) ?? resolve(resolved.root, resolved.pool)
|
|
5170
|
-
);
|
|
5179
|
+
if (resolved.workspace) {
|
|
5180
|
+
resolved.workspace = options.workspace && options.workspace[0] === "." ? resolve(process.cwd(), options.workspace) : resolvePath(resolved.workspace, resolved.root);
|
|
5171
5181
|
}
|
|
5182
|
+
if (!builtinPools.includes(resolved.pool))
|
|
5183
|
+
resolved.pool = resolvePath(resolved.pool, resolved.root);
|
|
5172
5184
|
resolved.poolMatchGlobs = (resolved.poolMatchGlobs || []).map(([glob, pool]) => {
|
|
5173
|
-
if (!builtinPools.includes(pool))
|
|
5174
|
-
pool =
|
|
5175
|
-
resolveModule(pool, { paths: [resolved.root] }) ?? resolve(resolved.root, pool)
|
|
5176
|
-
);
|
|
5177
|
-
}
|
|
5185
|
+
if (!builtinPools.includes(pool))
|
|
5186
|
+
pool = resolvePath(pool, resolved.root);
|
|
5178
5187
|
return [glob, pool];
|
|
5179
5188
|
});
|
|
5180
5189
|
if (mode === "benchmark") {
|
|
@@ -5199,14 +5208,10 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
5199
5208
|
resolved.benchmark.outputFile = options.outputFile;
|
|
5200
5209
|
}
|
|
5201
5210
|
resolved.setupFiles = toArray(resolved.setupFiles || []).map(
|
|
5202
|
-
(file) =>
|
|
5203
|
-
resolveModule(file, { paths: [resolved.root] }) ?? resolve(resolved.root, file)
|
|
5204
|
-
)
|
|
5211
|
+
(file) => resolvePath(file, resolved.root)
|
|
5205
5212
|
);
|
|
5206
5213
|
resolved.globalSetup = toArray(resolved.globalSetup || []).map(
|
|
5207
|
-
(file) =>
|
|
5208
|
-
resolveModule(file, { paths: [resolved.root] }) ?? resolve(resolved.root, file)
|
|
5209
|
-
)
|
|
5214
|
+
(file) => resolvePath(file, resolved.root)
|
|
5210
5215
|
);
|
|
5211
5216
|
resolved.coverage.exclude.push(...resolved.setupFiles.map((file) => `${resolved.coverage.allowExternal ? "**/" : ""}${relative(resolved.root, file)}`));
|
|
5212
5217
|
resolved.forceRerunTriggers = [
|
|
@@ -5214,9 +5219,7 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
5214
5219
|
...resolved.setupFiles
|
|
5215
5220
|
];
|
|
5216
5221
|
if (resolved.diff) {
|
|
5217
|
-
resolved.diff =
|
|
5218
|
-
resolveModule(resolved.diff, { paths: [resolved.root] }) ?? resolve(resolved.root, resolved.diff)
|
|
5219
|
-
);
|
|
5222
|
+
resolved.diff = resolvePath(resolved.diff, resolved.root);
|
|
5220
5223
|
resolved.forceRerunTriggers.push(resolved.diff);
|
|
5221
5224
|
}
|
|
5222
5225
|
resolved.api = resolveApiServerConfig(options);
|
|
@@ -6476,7 +6479,7 @@ createLogUpdate(process$2.stdout);
|
|
|
6476
6479
|
|
|
6477
6480
|
createLogUpdate(process$2.stderr);
|
|
6478
6481
|
|
|
6479
|
-
var version = "1.
|
|
6482
|
+
var version = "1.1.1";
|
|
6480
6483
|
|
|
6481
6484
|
async function printError(error, project, options) {
|
|
6482
6485
|
const { showCodeFrame = true, fullStack = false, type } = options;
|
|
@@ -7340,7 +7343,7 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
7340
7343
|
let name = testConfig.name;
|
|
7341
7344
|
if (!name) {
|
|
7342
7345
|
if (typeof options.workspacePath === "string")
|
|
7343
|
-
name =
|
|
7346
|
+
name = basename(options.workspacePath.endsWith("/") ? options.workspacePath.slice(0, -1) : dirname(options.workspacePath));
|
|
7344
7347
|
else
|
|
7345
7348
|
name = options.workspacePath.toString();
|
|
7346
7349
|
}
|
|
@@ -7461,16 +7464,17 @@ async function loadGlobalSetupFile(file, runner) {
|
|
|
7461
7464
|
}
|
|
7462
7465
|
|
|
7463
7466
|
async function initializeProject(workspacePath, ctx, options) {
|
|
7467
|
+
var _a;
|
|
7464
7468
|
const project = new WorkspaceProject(workspacePath, ctx);
|
|
7465
7469
|
const configFile = options.extends ? resolve(dirname(options.workspaceConfigPath), options.extends) : typeof workspacePath === "number" || workspacePath.endsWith("/") ? false : workspacePath;
|
|
7466
|
-
const root = options.root || (typeof workspacePath === "number" ? void 0 : dirname(workspacePath));
|
|
7470
|
+
const root = options.root || (typeof workspacePath === "number" ? void 0 : workspacePath.endsWith("/") ? workspacePath : dirname(workspacePath));
|
|
7467
7471
|
const config = {
|
|
7468
7472
|
...options,
|
|
7469
7473
|
root,
|
|
7470
7474
|
logLevel: "error",
|
|
7471
7475
|
configFile,
|
|
7472
7476
|
// this will make "mode": "test" | "benchmark" inside defineConfig
|
|
7473
|
-
mode: options.mode || ctx.config.mode,
|
|
7477
|
+
mode: ((_a = options.test) == null ? void 0 : _a.mode) || options.mode || ctx.config.mode,
|
|
7474
7478
|
plugins: [
|
|
7475
7479
|
...options.plugins || [],
|
|
7476
7480
|
WorkspaceVitestPlugin(project, { ...options, root, workspacePath })
|
|
@@ -7739,9 +7743,8 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
7739
7743
|
this.closingPromise = Promise.all([
|
|
7740
7744
|
this.server.close(),
|
|
7741
7745
|
(_a = this.typechecker) == null ? void 0 : _a.stop(),
|
|
7742
|
-
(_b = this.browser) == null ? void 0 : _b.close()
|
|
7743
|
-
|
|
7744
|
-
].filter(Boolean));
|
|
7746
|
+
(_b = this.browser) == null ? void 0 : _b.close()
|
|
7747
|
+
].filter(Boolean)).then(() => this._provided = {});
|
|
7745
7748
|
}
|
|
7746
7749
|
return this.closingPromise;
|
|
7747
7750
|
}
|
|
@@ -7882,15 +7885,22 @@ class Vitest {
|
|
|
7882
7885
|
const projectName = task.projectName || ((_a = task == null ? void 0 : task.file) == null ? void 0 : _a.projectName);
|
|
7883
7886
|
return this.projects.find((p) => p.getName() === projectName) || this.getCoreWorkspaceProject() || this.projects[0];
|
|
7884
7887
|
}
|
|
7885
|
-
async
|
|
7888
|
+
async getWorkspaceConfigPath() {
|
|
7889
|
+
if (this.config.workspace)
|
|
7890
|
+
return this.config.workspace;
|
|
7886
7891
|
const configDir = this.server.config.configFile ? dirname(this.server.config.configFile) : this.config.root;
|
|
7887
7892
|
const rootFiles = await promises.readdir(configDir);
|
|
7888
7893
|
const workspaceConfigName = workspacesFiles.find((configFile) => {
|
|
7889
7894
|
return rootFiles.includes(configFile);
|
|
7890
7895
|
});
|
|
7891
7896
|
if (!workspaceConfigName)
|
|
7897
|
+
return null;
|
|
7898
|
+
return join(configDir, workspaceConfigName);
|
|
7899
|
+
}
|
|
7900
|
+
async resolveWorkspace(cliOptions) {
|
|
7901
|
+
const workspaceConfigPath = await this.getWorkspaceConfigPath();
|
|
7902
|
+
if (!workspaceConfigPath)
|
|
7892
7903
|
return [await this.createCoreProject()];
|
|
7893
|
-
const workspaceConfigPath = join(configDir, workspaceConfigName);
|
|
7894
7904
|
const workspaceModule = await this.runner.executeFile(workspaceConfigPath);
|
|
7895
7905
|
if (!workspaceModule.default || !Array.isArray(workspaceModule.default))
|
|
7896
7906
|
throw new Error(`Workspace config file ${workspaceConfigPath} must export a default array of project paths.`);
|
|
@@ -7929,7 +7939,7 @@ class Vitest {
|
|
|
7929
7939
|
return filepath;
|
|
7930
7940
|
}));
|
|
7931
7941
|
const workspacesByFolder = resolvedWorkspacesPaths.reduce((configByFolder, filepath) => {
|
|
7932
|
-
const dir = dirname(filepath);
|
|
7942
|
+
const dir = filepath.endsWith("/") ? filepath.slice(0, -1) : dirname(filepath);
|
|
7933
7943
|
configByFolder[dir] ?? (configByFolder[dir] = []);
|
|
7934
7944
|
configByFolder[dir].push(filepath);
|
|
7935
7945
|
return configByFolder;
|
|
@@ -7947,8 +7957,12 @@ class Vitest {
|
|
|
7947
7957
|
"testTimeout",
|
|
7948
7958
|
"pool",
|
|
7949
7959
|
"globals",
|
|
7950
|
-
"
|
|
7951
|
-
"
|
|
7960
|
+
"expandSnapshotDiff",
|
|
7961
|
+
"retry",
|
|
7962
|
+
"testNamePattern",
|
|
7963
|
+
"passWithNoTests",
|
|
7964
|
+
"bail",
|
|
7965
|
+
"isolate"
|
|
7952
7966
|
];
|
|
7953
7967
|
const cliOverrides = overridesOptions.reduce((acc, name) => {
|
|
7954
7968
|
if (name in cliOptions)
|
|
@@ -8433,7 +8447,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
8433
8447
|
this.meta.watchMode = false;
|
|
8434
8448
|
},
|
|
8435
8449
|
async config(viteConfig) {
|
|
8436
|
-
var _a, _b, _c, _d;
|
|
8450
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
8437
8451
|
if (options.watch) {
|
|
8438
8452
|
options = deepMerge({}, userConfig);
|
|
8439
8453
|
}
|
|
@@ -8444,13 +8458,18 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
8444
8458
|
removeUndefinedValues(viteConfig.test ?? {})
|
|
8445
8459
|
);
|
|
8446
8460
|
testConfig.api = resolveApiServerConfig(testConfig);
|
|
8461
|
+
testConfig.poolOptions ?? (testConfig.poolOptions = {});
|
|
8462
|
+
(_a = testConfig.poolOptions).threads ?? (_a.threads = {});
|
|
8463
|
+
(_b = testConfig.poolOptions).forks ?? (_b.forks = {});
|
|
8464
|
+
testConfig.poolOptions.threads.isolate = ((_d = (_c = options.poolOptions) == null ? void 0 : _c.threads) == null ? void 0 : _d.isolate) ?? options.isolate ?? testConfig.poolOptions.threads.isolate ?? ((_e = viteConfig.test) == null ? void 0 : _e.isolate);
|
|
8465
|
+
testConfig.poolOptions.forks.isolate = ((_g = (_f = options.poolOptions) == null ? void 0 : _f.forks) == null ? void 0 : _g.isolate) ?? options.isolate ?? testConfig.poolOptions.forks.isolate ?? ((_h = viteConfig.test) == null ? void 0 : _h.isolate);
|
|
8447
8466
|
const defines = deleteDefineConfig(viteConfig);
|
|
8448
8467
|
options.defines = defines;
|
|
8449
8468
|
let open = false;
|
|
8450
8469
|
if (testConfig.ui && testConfig.open)
|
|
8451
8470
|
open = testConfig.uiBase ?? "/__vitest__/";
|
|
8452
8471
|
const config = {
|
|
8453
|
-
root: ((
|
|
8472
|
+
root: ((_i = viteConfig.test) == null ? void 0 : _i.root) || options.root,
|
|
8454
8473
|
esbuild: viteConfig.esbuild === false ? false : {
|
|
8455
8474
|
sourcemap: "external",
|
|
8456
8475
|
// Enables using ignore hint for coverage providers with @preserve keyword
|
|
@@ -8474,16 +8493,19 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
8474
8493
|
fs: {
|
|
8475
8494
|
allow: resolveFsAllow(getRoot(), testConfig.config)
|
|
8476
8495
|
}
|
|
8496
|
+
},
|
|
8497
|
+
test: {
|
|
8498
|
+
poolOptions: testConfig.poolOptions
|
|
8477
8499
|
}
|
|
8478
8500
|
};
|
|
8479
8501
|
if (process.platform === "darwin" && process.env.VITE_TEST_WATCHER_DEBUG) {
|
|
8480
8502
|
config.server.watch.useFsEvents = false;
|
|
8481
8503
|
config.server.watch.usePolling = false;
|
|
8482
8504
|
}
|
|
8483
|
-
const classNameStrategy = typeof testConfig.css !== "boolean" && ((
|
|
8505
|
+
const classNameStrategy = typeof testConfig.css !== "boolean" && ((_k = (_j = testConfig.css) == null ? void 0 : _j.modules) == null ? void 0 : _k.classNameStrategy) || "stable";
|
|
8484
8506
|
if (classNameStrategy !== "scoped") {
|
|
8485
8507
|
config.css ?? (config.css = {});
|
|
8486
|
-
(
|
|
8508
|
+
(_l = config.css).modules ?? (_l.modules = {});
|
|
8487
8509
|
if (config.css.modules) {
|
|
8488
8510
|
config.css.modules.generateScopedName = (name, filename) => {
|
|
8489
8511
|
const root = getRoot();
|
|
@@ -1949,7 +1949,7 @@ let JsonReporter$1 = class JsonReporter {
|
|
|
1949
1949
|
success,
|
|
1950
1950
|
testResults
|
|
1951
1951
|
};
|
|
1952
|
-
await this.writeReport(JSON.stringify(result
|
|
1952
|
+
await this.writeReport(JSON.stringify(result));
|
|
1953
1953
|
}
|
|
1954
1954
|
async onFinished(files = this.ctx.state.getFiles()) {
|
|
1955
1955
|
await this.logTasks(files);
|
|
@@ -2253,13 +2253,13 @@ class JUnitReporter {
|
|
|
2253
2253
|
var _a;
|
|
2254
2254
|
await this.logger.log('<?xml version="1.0" encoding="UTF-8" ?>');
|
|
2255
2255
|
const transformed = files.map((file) => {
|
|
2256
|
-
var _a2;
|
|
2256
|
+
var _a2, _b;
|
|
2257
2257
|
const tasks = file.tasks.flatMap((task) => flattenTasks$1(task));
|
|
2258
2258
|
const stats2 = tasks.reduce((stats3, task) => {
|
|
2259
|
-
var _a3,
|
|
2259
|
+
var _a3, _b2;
|
|
2260
2260
|
return {
|
|
2261
2261
|
passed: stats3.passed + Number(((_a3 = task.result) == null ? void 0 : _a3.state) === "pass"),
|
|
2262
|
-
failures: stats3.failures + Number(((
|
|
2262
|
+
failures: stats3.failures + Number(((_b2 = task.result) == null ? void 0 : _b2.state) === "fail"),
|
|
2263
2263
|
skipped: stats3.skipped + Number(task.mode === "skip" || task.mode === "todo")
|
|
2264
2264
|
};
|
|
2265
2265
|
}, {
|
|
@@ -2267,7 +2267,14 @@ class JUnitReporter {
|
|
|
2267
2267
|
failures: 0,
|
|
2268
2268
|
skipped: 0
|
|
2269
2269
|
});
|
|
2270
|
-
|
|
2270
|
+
const suites = getSuites(file);
|
|
2271
|
+
for (const suite of suites) {
|
|
2272
|
+
if ((_a2 = suite.result) == null ? void 0 : _a2.errors) {
|
|
2273
|
+
tasks.push(suite);
|
|
2274
|
+
stats2.failures += 1;
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
if (tasks.length === 0 && ((_b = file.result) == null ? void 0 : _b.state) === "fail") {
|
|
2271
2278
|
stats2.failures = 1;
|
|
2272
2279
|
tasks.push({
|
|
2273
2280
|
id: file.id,
|
|
@@ -3406,7 +3406,7 @@ function createVitest() {
|
|
|
3406
3406
|
_mocker.queueMock(
|
|
3407
3407
|
path,
|
|
3408
3408
|
importer,
|
|
3409
|
-
factory ? () => factory(() => _mocker.importActual(path, importer)) : void 0
|
|
3409
|
+
factory ? () => factory(() => _mocker.importActual(path, importer, _mocker.getMockContext().callstack)) : void 0
|
|
3410
3410
|
);
|
|
3411
3411
|
},
|
|
3412
3412
|
unmock(path) {
|
|
@@ -3417,14 +3417,18 @@ function createVitest() {
|
|
|
3417
3417
|
_mocker.queueMock(
|
|
3418
3418
|
path,
|
|
3419
3419
|
importer,
|
|
3420
|
-
factory ? () => factory(() => _mocker.importActual(path, importer)) : void 0
|
|
3420
|
+
factory ? () => factory(() => _mocker.importActual(path, importer, _mocker.getMockContext().callstack)) : void 0
|
|
3421
3421
|
);
|
|
3422
3422
|
},
|
|
3423
3423
|
doUnmock(path) {
|
|
3424
3424
|
_mocker.queueUnmock(path, getImporter());
|
|
3425
3425
|
},
|
|
3426
3426
|
async importActual(path) {
|
|
3427
|
-
return _mocker.importActual(
|
|
3427
|
+
return _mocker.importActual(
|
|
3428
|
+
path,
|
|
3429
|
+
getImporter(),
|
|
3430
|
+
_mocker.getMockContext().callstack
|
|
3431
|
+
);
|
|
3428
3432
|
},
|
|
3429
3433
|
async importMock(path) {
|
|
3430
3434
|
return _mocker.importMock(path, getImporter());
|
package/dist/vm.js
CHANGED
|
@@ -7,13 +7,12 @@ import { c as createBirpc } from './vendor/index.cAUulNDf.js';
|
|
|
7
7
|
import { resolve } from 'pathe';
|
|
8
8
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
9
9
|
import { distDir } from './paths.js';
|
|
10
|
-
import { l as loadEnvironment } from './vendor/loader.
|
|
11
|
-
import { b as startVitestExecutor } from './vendor/execute.
|
|
10
|
+
import { l as loadEnvironment } from './vendor/loader.L9CYwKn1.js';
|
|
11
|
+
import { b as startVitestExecutor } from './vendor/execute.vStuEOaI.js';
|
|
12
12
|
import { createCustomConsole } from './chunks/runtime-console.hf2msWA9.js';
|
|
13
13
|
import { c as createSafeRpc } from './vendor/rpc.Bl-ysZIr.js';
|
|
14
|
-
import './vendor/environments.
|
|
14
|
+
import './vendor/environments.QJtma9XQ.js';
|
|
15
15
|
import 'node:console';
|
|
16
|
-
import 'local-pkg';
|
|
17
16
|
import 'vite-node/utils';
|
|
18
17
|
import '@vitest/utils/error';
|
|
19
18
|
import 'node:fs';
|
package/dist/worker.js
CHANGED
|
@@ -2,15 +2,14 @@ import { performance } from 'node:perf_hooks';
|
|
|
2
2
|
import { c as createBirpc } from './vendor/index.cAUulNDf.js';
|
|
3
3
|
import { workerId } from 'tinypool';
|
|
4
4
|
import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
|
|
5
|
-
import { l as loadEnvironment } from './vendor/loader.
|
|
6
|
-
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor/execute.
|
|
5
|
+
import { l as loadEnvironment } from './vendor/loader.L9CYwKn1.js';
|
|
6
|
+
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor/execute.vStuEOaI.js';
|
|
7
7
|
import { s as setupInspect } from './vendor/inspector.lFAeuaAt.js';
|
|
8
8
|
import { r as rpcDone, c as createSafeRpc } from './vendor/rpc.Bl-ysZIr.js';
|
|
9
9
|
import 'pathe';
|
|
10
10
|
import 'vite-node/client';
|
|
11
|
-
import './vendor/environments.
|
|
11
|
+
import './vendor/environments.QJtma9XQ.js';
|
|
12
12
|
import 'node:console';
|
|
13
|
-
import 'local-pkg';
|
|
14
13
|
import 'node:url';
|
|
15
14
|
import 'node:vm';
|
|
16
15
|
import 'vite-node/utils';
|