vitest 2.2.0-beta.1 → 3.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/dist/browser.d.ts +8 -8
- package/dist/browser.js +1 -1
- package/dist/chunks/{RandomSequencer.CMRlh2v4.js → RandomSequencer.gisBJ77r.js} +11 -3
- package/dist/chunks/{base.BS0HhLXd.js → base.CkcgFVQd.js} +8 -3
- package/dist/chunks/{benchmark.geERunq4.d.ts → benchmark.CFFwLv-O.d.ts} +2 -2
- package/dist/chunks/{cac.Z91LBqmg.js → cac.CWCZimpS.js} +7 -7
- package/dist/chunks/{cli-api.DVJJMJHj.js → cli-api.BKUOv0Nc.js} +928 -661
- package/dist/chunks/{config.CPguQ7J1.d.ts → config.BTPBhmK5.d.ts} +1 -1
- package/dist/chunks/{creator.IIqd8RWT.js → creator.DcAcUhMD.js} +1 -4
- package/dist/chunks/{globals.BCGEw6ON.js → globals.DJTzb7B3.js} +2 -2
- package/dist/chunks/{index.DD5eTY2y.js → index.BqHViJW9.js} +1 -1
- package/dist/chunks/{index.BjjsHdBb.js → index.CkOJwybT.js} +1 -1
- package/dist/chunks/{index.DLRzErGF.js → index.DKe7vK-G.js} +708 -548
- package/dist/chunks/{index.CqYx2Nsr.js → index.DQboAxJm.js} +23 -14
- package/dist/chunks/{inspector.70d6emsh.js → inspector.DKLceBVD.js} +1 -1
- package/dist/chunks/{reporters.B_9uUTGW.d.ts → reporters.BZbwTvrM.d.ts} +1252 -1234
- package/dist/chunks/{resolveConfig.CQIc6fe7.js → resolveConfig.3rGGWga5.js} +88 -56
- package/dist/chunks/{runBaseTests.B7hcVT-s.js → runBaseTests.C6huCAng.js} +6 -6
- package/dist/chunks/{setup-common.BfGt8K-K.js → setup-common.B5ClyS48.js} +1 -1
- package/dist/chunks/{suite.B2jumIFP.d.ts → suite.BJU7kdY9.d.ts} +4 -4
- package/dist/chunks/{utils.DNoFbBUZ.js → utils.CMUTX-p8.js} +20 -23
- package/dist/chunks/{vi.BlPttogV.js → vi.CZKezqeD.js} +18 -13
- package/dist/chunks/{vite.Bvms8Xir.d.ts → vite.DIfmneq0.d.ts} +1 -1
- package/dist/chunks/{vm.Zr4qWzDJ.js → vm.DGhTouO3.js} +10 -1
- package/dist/chunks/{worker.9VY11NZs.d.ts → worker.CmzGeuVD.d.ts} +3 -3
- package/dist/chunks/{worker.Qz1UB4Fv.d.ts → worker.umPNbBNk.d.ts} +1 -1
- package/dist/cli.js +1 -1
- package/dist/config.cjs +1 -10
- package/dist/config.d.ts +11 -11
- package/dist/config.js +1 -10
- package/dist/coverage.d.ts +7 -7
- package/dist/coverage.js +4 -4
- package/dist/execute.d.ts +3 -3
- package/dist/index.d.ts +26 -17
- package/dist/index.js +2 -2
- package/dist/node.d.ts +16 -20
- package/dist/node.js +7 -7
- package/dist/reporters.d.ts +7 -7
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +3 -4
- package/dist/runners.js +9 -14
- package/dist/suite.d.ts +2 -2
- package/dist/worker.js +1 -1
- package/dist/workers/forks.js +1 -1
- package/dist/workers/runVmTests.js +6 -6
- package/dist/workers/threads.js +1 -1
- package/dist/workers/vmForks.js +1 -1
- package/dist/workers/vmThreads.js +1 -1
- package/dist/workers.d.ts +3 -3
- package/dist/workers.js +3 -3
- package/package.json +22 -22
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { slash, createDefer, toArray } from '@vitest/utils';
|
|
2
|
-
import a, { win32, resolve as resolve$1 } from 'node:path';
|
|
3
2
|
import fs, { statSync, realpathSync, promises as promises$1 } from 'node:fs';
|
|
4
3
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { builtinModules, createRequire } from 'node:module';
|
|
5
|
+
import a, { win32, resolve as resolve$1 } from 'node:path';
|
|
5
6
|
import process$1 from 'node:process';
|
|
6
|
-
import { builtinModules } from 'node:module';
|
|
7
|
-
import { relative, resolve, dirname, isAbsolute, join, normalize } from 'pathe';
|
|
8
7
|
import { fileURLToPath as fileURLToPath$1, pathToFileURL as pathToFileURL$1, URL as URL$1 } from 'node:url';
|
|
8
|
+
import { relative, resolve, dirname, isAbsolute, join, normalize } from 'pathe';
|
|
9
9
|
import assert from 'node:assert';
|
|
10
10
|
import v8 from 'node:v8';
|
|
11
11
|
import { format, inspect } from 'node:util';
|
|
@@ -13,7 +13,7 @@ import c from 'tinyrainbow';
|
|
|
13
13
|
import { e as extraInlineDeps, d as defaultPort, a as defaultBrowserPort, b as defaultInspectPort } from './constants.fzPh7AOq.js';
|
|
14
14
|
import * as nodeos from 'node:os';
|
|
15
15
|
import nodeos__default from 'node:os';
|
|
16
|
-
import { h as hash, w as wrapSerializableConfig, T as Typechecker, i as isWindows, R as RandomSequencer, B as BaseSequencer } from './RandomSequencer.
|
|
16
|
+
import { h as hash, w as wrapSerializableConfig, T as Typechecker, i as isWindows, R as RandomSequencer, B as BaseSequencer } from './RandomSequencer.gisBJ77r.js';
|
|
17
17
|
import { isCI, provider } from 'std-env';
|
|
18
18
|
import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
|
|
19
19
|
import require$$0 from 'util';
|
|
@@ -4167,10 +4167,15 @@ function escapeRegExp(s) {
|
|
|
4167
4167
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4168
4168
|
}
|
|
4169
4169
|
function wildcardPatternToRegExp(pattern) {
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4170
|
+
const negated = pattern.startsWith("!");
|
|
4171
|
+
if (negated) {
|
|
4172
|
+
pattern = pattern.slice(1);
|
|
4173
|
+
}
|
|
4174
|
+
let regexp = `${pattern.split("*").map(escapeRegExp).join(".*")}$`;
|
|
4175
|
+
if (negated) {
|
|
4176
|
+
regexp = `(?!${regexp})`;
|
|
4177
|
+
}
|
|
4178
|
+
return new RegExp(`^${regexp}`, "i");
|
|
4174
4179
|
}
|
|
4175
4180
|
|
|
4176
4181
|
class FilesStatsCache {
|
|
@@ -4180,7 +4185,7 @@ class FilesStatsCache {
|
|
|
4180
4185
|
}
|
|
4181
4186
|
async populateStats(root, specs) {
|
|
4182
4187
|
const promises = specs.map((spec) => {
|
|
4183
|
-
const key = `${spec[0].
|
|
4188
|
+
const key = `${spec[0].name}:${relative(root, spec[1])}`;
|
|
4184
4189
|
return this.updateStats(spec[1], key);
|
|
4185
4190
|
});
|
|
4186
4191
|
await Promise.all(promises);
|
|
@@ -6378,6 +6383,16 @@ function resolvePathSync(id, options) {
|
|
|
6378
6383
|
function _resolve(path, options = {}) {
|
|
6379
6384
|
if (options.platform === "auto" || !options.platform)
|
|
6380
6385
|
options.platform = process$1.platform === "win32" ? "win32" : "posix";
|
|
6386
|
+
if (process$1.versions.pnp) {
|
|
6387
|
+
const paths = options.paths || [];
|
|
6388
|
+
if (paths.length === 0)
|
|
6389
|
+
paths.push(process$1.cwd());
|
|
6390
|
+
const targetRequire = createRequire(import.meta.url);
|
|
6391
|
+
try {
|
|
6392
|
+
return targetRequire.resolve(path, { paths });
|
|
6393
|
+
} catch {
|
|
6394
|
+
}
|
|
6395
|
+
}
|
|
6381
6396
|
const modulePath = resolvePathSync(path, {
|
|
6382
6397
|
url: options.paths
|
|
6383
6398
|
});
|
|
@@ -6388,7 +6403,7 @@ function _resolve(path, options = {}) {
|
|
|
6388
6403
|
function resolveModule(name, options = {}) {
|
|
6389
6404
|
try {
|
|
6390
6405
|
return _resolve(name, options);
|
|
6391
|
-
} catch
|
|
6406
|
+
} catch {
|
|
6392
6407
|
return void 0;
|
|
6393
6408
|
}
|
|
6394
6409
|
}
|
|
@@ -6481,16 +6496,7 @@ const coverageConfigDefaults = {
|
|
|
6481
6496
|
};
|
|
6482
6497
|
const fakeTimersDefaults = {
|
|
6483
6498
|
loopLimit: 1e4,
|
|
6484
|
-
shouldClearNativeTimers: true
|
|
6485
|
-
toFake: [
|
|
6486
|
-
"setTimeout",
|
|
6487
|
-
"clearTimeout",
|
|
6488
|
-
"setInterval",
|
|
6489
|
-
"clearInterval",
|
|
6490
|
-
"setImmediate",
|
|
6491
|
-
"clearImmediate",
|
|
6492
|
-
"Date"
|
|
6493
|
-
]
|
|
6499
|
+
shouldClearNativeTimers: true
|
|
6494
6500
|
};
|
|
6495
6501
|
const config = {
|
|
6496
6502
|
allowOnly: !isCI,
|
|
@@ -6552,13 +6558,14 @@ function getTransformMode(patterns, filename) {
|
|
|
6552
6558
|
async function groupFilesByEnv(files) {
|
|
6553
6559
|
const filesWithEnv = await Promise.all(
|
|
6554
6560
|
files.map(async (spec) => {
|
|
6555
|
-
const
|
|
6556
|
-
const
|
|
6557
|
-
const
|
|
6561
|
+
const filepath = spec.moduleId;
|
|
6562
|
+
const { testLocations } = spec;
|
|
6563
|
+
const project = spec.project;
|
|
6564
|
+
const code = await promises$1.readFile(filepath, "utf-8");
|
|
6558
6565
|
let env = code.match(/@(?:vitest|jest)-environment\s+([\w-]+)\b/)?.[1];
|
|
6559
6566
|
if (!env) {
|
|
6560
6567
|
for (const [glob, target] of project.config.environmentMatchGlobs || []) {
|
|
6561
|
-
if (mm.isMatch(
|
|
6568
|
+
if (mm.isMatch(filepath, glob, { cwd: project.config.root })) {
|
|
6562
6569
|
env = target;
|
|
6563
6570
|
break;
|
|
6564
6571
|
}
|
|
@@ -6567,7 +6574,7 @@ async function groupFilesByEnv(files) {
|
|
|
6567
6574
|
env ||= project.config.environment || "node";
|
|
6568
6575
|
const transformMode = getTransformMode(
|
|
6569
6576
|
project.config.testTransformMode,
|
|
6570
|
-
|
|
6577
|
+
filepath
|
|
6571
6578
|
);
|
|
6572
6579
|
let envOptionsJson = code.match(/@(?:vitest|jest)-environment-options\s+(.+)/)?.[1];
|
|
6573
6580
|
if (envOptionsJson?.endsWith("*/")) {
|
|
@@ -6581,7 +6588,10 @@ async function groupFilesByEnv(files) {
|
|
|
6581
6588
|
options: envOptions ? { [envKey]: envOptions } : null
|
|
6582
6589
|
};
|
|
6583
6590
|
return {
|
|
6584
|
-
file
|
|
6591
|
+
file: {
|
|
6592
|
+
filepath,
|
|
6593
|
+
testLocations
|
|
6594
|
+
},
|
|
6585
6595
|
project,
|
|
6586
6596
|
environment
|
|
6587
6597
|
};
|
|
@@ -6601,14 +6611,14 @@ function createMethodsRPC(project, options = {}) {
|
|
|
6601
6611
|
},
|
|
6602
6612
|
resolveSnapshotPath(testPath) {
|
|
6603
6613
|
return ctx.snapshot.resolvePath(testPath, {
|
|
6604
|
-
config: project.
|
|
6614
|
+
config: project.serializedConfig
|
|
6605
6615
|
});
|
|
6606
6616
|
},
|
|
6607
6617
|
async getSourceMap(id, force) {
|
|
6608
6618
|
if (force) {
|
|
6609
|
-
const mod = project.
|
|
6619
|
+
const mod = project.vite.moduleGraph.getModuleById(id);
|
|
6610
6620
|
if (mod) {
|
|
6611
|
-
project.
|
|
6621
|
+
project.vite.moduleGraph.invalidateModule(mod);
|
|
6612
6622
|
}
|
|
6613
6623
|
}
|
|
6614
6624
|
const r = await project.vitenode.transformRequest(id);
|
|
@@ -6758,7 +6768,8 @@ function createForksPool(ctx, { execArgv, env }) {
|
|
|
6758
6768
|
const runWithFiles = (name) => {
|
|
6759
6769
|
let id = 0;
|
|
6760
6770
|
async function runFiles(project, config, files, environment, invalidates = []) {
|
|
6761
|
-
|
|
6771
|
+
const paths = files.map((f) => f.filepath);
|
|
6772
|
+
ctx.state.clearFiles(project, paths);
|
|
6762
6773
|
const { channel, cleanup } = createChildProcessChannel$1(project);
|
|
6763
6774
|
const workerId = ++id;
|
|
6764
6775
|
const data = {
|
|
@@ -6769,7 +6780,7 @@ function createForksPool(ctx, { execArgv, env }) {
|
|
|
6769
6780
|
invalidates,
|
|
6770
6781
|
environment,
|
|
6771
6782
|
workerId,
|
|
6772
|
-
projectName: project.
|
|
6783
|
+
projectName: project.name,
|
|
6773
6784
|
providedContext: project.getProvidedContext()
|
|
6774
6785
|
};
|
|
6775
6786
|
try {
|
|
@@ -6777,10 +6788,10 @@ function createForksPool(ctx, { execArgv, env }) {
|
|
|
6777
6788
|
} catch (error) {
|
|
6778
6789
|
if (error instanceof Error && /Failed to terminate worker/.test(error.message)) {
|
|
6779
6790
|
ctx.state.addProcessTimeoutCause(
|
|
6780
|
-
`Failed to terminate worker while running ${
|
|
6791
|
+
`Failed to terminate worker while running ${paths.join(", ")}.`
|
|
6781
6792
|
);
|
|
6782
6793
|
} else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message)) {
|
|
6783
|
-
ctx.state.cancelFiles(
|
|
6794
|
+
ctx.state.cancelFiles(paths, project);
|
|
6784
6795
|
} else {
|
|
6785
6796
|
throw error;
|
|
6786
6797
|
}
|
|
@@ -6827,7 +6838,7 @@ function createForksPool(ctx, { execArgv, env }) {
|
|
|
6827
6838
|
} else {
|
|
6828
6839
|
const grouped = groupBy(
|
|
6829
6840
|
files,
|
|
6830
|
-
({ project, environment }) => project.
|
|
6841
|
+
({ project, environment }) => project.name + environment.name + JSON.stringify(environment.options)
|
|
6831
6842
|
);
|
|
6832
6843
|
for (const group of Object.values(grouped)) {
|
|
6833
6844
|
results.push(
|
|
@@ -6869,7 +6880,7 @@ function createForksPool(ctx, { execArgv, env }) {
|
|
|
6869
6880
|
}
|
|
6870
6881
|
const filesByOptions = groupBy(
|
|
6871
6882
|
files,
|
|
6872
|
-
({ project, environment }) => project.
|
|
6883
|
+
({ project, environment }) => project.name + JSON.stringify(environment.options)
|
|
6873
6884
|
);
|
|
6874
6885
|
for (const files2 of Object.values(filesByOptions)) {
|
|
6875
6886
|
await pool.recycleWorkers();
|
|
@@ -6944,7 +6955,8 @@ function createThreadsPool(ctx, { execArgv, env }) {
|
|
|
6944
6955
|
const runWithFiles = (name) => {
|
|
6945
6956
|
let id = 0;
|
|
6946
6957
|
async function runFiles(project, config, files, environment, invalidates = []) {
|
|
6947
|
-
|
|
6958
|
+
const paths = files.map((f) => f.filepath);
|
|
6959
|
+
ctx.state.clearFiles(project, paths);
|
|
6948
6960
|
const { workerPort, port } = createWorkerChannel$1(project);
|
|
6949
6961
|
const workerId = ++id;
|
|
6950
6962
|
const data = {
|
|
@@ -6956,7 +6968,7 @@ function createThreadsPool(ctx, { execArgv, env }) {
|
|
|
6956
6968
|
invalidates,
|
|
6957
6969
|
environment,
|
|
6958
6970
|
workerId,
|
|
6959
|
-
projectName: project.
|
|
6971
|
+
projectName: project.name,
|
|
6960
6972
|
providedContext: project.getProvidedContext()
|
|
6961
6973
|
};
|
|
6962
6974
|
try {
|
|
@@ -6964,13 +6976,13 @@ function createThreadsPool(ctx, { execArgv, env }) {
|
|
|
6964
6976
|
} catch (error) {
|
|
6965
6977
|
if (error instanceof Error && /Failed to terminate worker/.test(error.message)) {
|
|
6966
6978
|
ctx.state.addProcessTimeoutCause(
|
|
6967
|
-
`Failed to terminate worker while running ${
|
|
6979
|
+
`Failed to terminate worker while running ${paths.join(
|
|
6968
6980
|
", "
|
|
6969
6981
|
)}.
|
|
6970
6982
|
See https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker for troubleshooting.`
|
|
6971
6983
|
);
|
|
6972
6984
|
} else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message)) {
|
|
6973
|
-
ctx.state.cancelFiles(
|
|
6985
|
+
ctx.state.cancelFiles(paths, project);
|
|
6974
6986
|
} else {
|
|
6975
6987
|
throw error;
|
|
6976
6988
|
}
|
|
@@ -7017,7 +7029,7 @@ See https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker for t
|
|
|
7017
7029
|
} else {
|
|
7018
7030
|
const grouped = groupBy(
|
|
7019
7031
|
files,
|
|
7020
|
-
({ project, environment }) => project.
|
|
7032
|
+
({ project, environment }) => project.name + environment.name + JSON.stringify(environment.options)
|
|
7021
7033
|
);
|
|
7022
7034
|
for (const group of Object.values(grouped)) {
|
|
7023
7035
|
results.push(
|
|
@@ -7059,7 +7071,7 @@ See https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker for t
|
|
|
7059
7071
|
}
|
|
7060
7072
|
const filesByOptions = groupBy(
|
|
7061
7073
|
files,
|
|
7062
|
-
({ project, environment }) => project.
|
|
7074
|
+
({ project, environment }) => project.name + JSON.stringify(environment.options)
|
|
7063
7075
|
);
|
|
7064
7076
|
for (const files2 of Object.values(filesByOptions)) {
|
|
7065
7077
|
await pool.recycleWorkers();
|
|
@@ -7154,10 +7166,10 @@ function createTypecheckPool(ctx) {
|
|
|
7154
7166
|
for (const name in specsByProject) {
|
|
7155
7167
|
const project = specsByProject[name][0].project;
|
|
7156
7168
|
const files = specsByProject[name].map((spec) => spec.moduleId);
|
|
7157
|
-
const checker = await createWorkspaceTypechecker(project
|
|
7169
|
+
const checker = await createWorkspaceTypechecker(project, files);
|
|
7158
7170
|
checker.setFiles(files);
|
|
7159
7171
|
await checker.collectTests();
|
|
7160
|
-
ctx.state.collectFiles(project
|
|
7172
|
+
ctx.state.collectFiles(project, checker.getTestFiles());
|
|
7161
7173
|
await ctx.report("onCollected");
|
|
7162
7174
|
}
|
|
7163
7175
|
}
|
|
@@ -7332,7 +7344,8 @@ function createVmForksPool(ctx, { execArgv, env }) {
|
|
|
7332
7344
|
const runWithFiles = (name) => {
|
|
7333
7345
|
let id = 0;
|
|
7334
7346
|
async function runFiles(project, config, files, environment, invalidates = []) {
|
|
7335
|
-
|
|
7347
|
+
const paths = files.map((f) => f.filepath);
|
|
7348
|
+
ctx.state.clearFiles(project, paths);
|
|
7336
7349
|
const { channel, cleanup } = createChildProcessChannel(project);
|
|
7337
7350
|
const workerId = ++id;
|
|
7338
7351
|
const data = {
|
|
@@ -7343,7 +7356,7 @@ function createVmForksPool(ctx, { execArgv, env }) {
|
|
|
7343
7356
|
invalidates,
|
|
7344
7357
|
environment,
|
|
7345
7358
|
workerId,
|
|
7346
|
-
projectName: project.
|
|
7359
|
+
projectName: project.name,
|
|
7347
7360
|
providedContext: project.getProvidedContext()
|
|
7348
7361
|
};
|
|
7349
7362
|
try {
|
|
@@ -7351,10 +7364,10 @@ function createVmForksPool(ctx, { execArgv, env }) {
|
|
|
7351
7364
|
} catch (error) {
|
|
7352
7365
|
if (error instanceof Error && /Failed to terminate worker/.test(error.message)) {
|
|
7353
7366
|
ctx.state.addProcessTimeoutCause(
|
|
7354
|
-
`Failed to terminate worker while running ${
|
|
7367
|
+
`Failed to terminate worker while running ${paths.join(", ")}.`
|
|
7355
7368
|
);
|
|
7356
7369
|
} else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message)) {
|
|
7357
|
-
ctx.state.cancelFiles(
|
|
7370
|
+
ctx.state.cancelFiles(paths, project);
|
|
7358
7371
|
} else {
|
|
7359
7372
|
throw error;
|
|
7360
7373
|
}
|
|
@@ -7470,7 +7483,8 @@ function createVmThreadsPool(ctx, { execArgv, env }) {
|
|
|
7470
7483
|
const runWithFiles = (name) => {
|
|
7471
7484
|
let id = 0;
|
|
7472
7485
|
async function runFiles(project, config, files, environment, invalidates = []) {
|
|
7473
|
-
|
|
7486
|
+
const paths = files.map((f) => f.filepath);
|
|
7487
|
+
ctx.state.clearFiles(project, paths);
|
|
7474
7488
|
const { workerPort, port } = createWorkerChannel(project);
|
|
7475
7489
|
const workerId = ++id;
|
|
7476
7490
|
const data = {
|
|
@@ -7478,11 +7492,11 @@ function createVmThreadsPool(ctx, { execArgv, env }) {
|
|
|
7478
7492
|
worker,
|
|
7479
7493
|
port: workerPort,
|
|
7480
7494
|
config,
|
|
7481
|
-
files,
|
|
7495
|
+
files: paths,
|
|
7482
7496
|
invalidates,
|
|
7483
7497
|
environment,
|
|
7484
7498
|
workerId,
|
|
7485
|
-
projectName: project.
|
|
7499
|
+
projectName: project.name,
|
|
7486
7500
|
providedContext: project.getProvidedContext()
|
|
7487
7501
|
};
|
|
7488
7502
|
try {
|
|
@@ -7490,13 +7504,13 @@ function createVmThreadsPool(ctx, { execArgv, env }) {
|
|
|
7490
7504
|
} catch (error) {
|
|
7491
7505
|
if (error instanceof Error && /Failed to terminate worker/.test(error.message)) {
|
|
7492
7506
|
ctx.state.addProcessTimeoutCause(
|
|
7493
|
-
`Failed to terminate worker while running ${
|
|
7507
|
+
`Failed to terminate worker while running ${paths.join(
|
|
7494
7508
|
", "
|
|
7495
7509
|
)}.
|
|
7496
7510
|
See https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker for troubleshooting.`
|
|
7497
7511
|
);
|
|
7498
7512
|
} else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message)) {
|
|
7499
|
-
ctx.state.cancelFiles(
|
|
7513
|
+
ctx.state.cancelFiles(paths, project);
|
|
7500
7514
|
} else {
|
|
7501
7515
|
throw error;
|
|
7502
7516
|
}
|
|
@@ -8100,12 +8114,21 @@ ${JSON.stringify({ browser: { provider: "playwright", name: "chromium" } }, null
|
|
|
8100
8114
|
resolved.poolOptions[poolOptionKey][workerOptionKey] = resolveInlineWorkerOption(resolved.poolOptions[poolOptionKey][workerOptionKey]);
|
|
8101
8115
|
}
|
|
8102
8116
|
}
|
|
8103
|
-
if (resolved.workspace) {
|
|
8104
|
-
resolved.workspace = options.workspace && options.workspace[0] === "." ? resolve(process.cwd(), options.workspace) : resolvePath(resolved.workspace, resolved.root);
|
|
8117
|
+
if (typeof resolved.workspace === "string") {
|
|
8118
|
+
resolved.workspace = typeof options.workspace === "string" && options.workspace[0] === "." ? resolve(process.cwd(), options.workspace) : resolvePath(resolved.workspace, resolved.root);
|
|
8105
8119
|
}
|
|
8106
8120
|
if (!builtinPools.includes(resolved.pool)) {
|
|
8107
8121
|
resolved.pool = resolvePath(resolved.pool, resolved.root);
|
|
8108
8122
|
}
|
|
8123
|
+
if (resolved.poolMatchGlobs) {
|
|
8124
|
+
logger.warn(
|
|
8125
|
+
c.yellow(
|
|
8126
|
+
`${c.inverse(
|
|
8127
|
+
c.yellow(" Vitest ")
|
|
8128
|
+
)} "poolMatchGlobs" is deprecated. Use "workspace" to define different configurations instead.`
|
|
8129
|
+
)
|
|
8130
|
+
);
|
|
8131
|
+
}
|
|
8109
8132
|
resolved.poolMatchGlobs = (resolved.poolMatchGlobs || []).map(
|
|
8110
8133
|
([glob, pool]) => {
|
|
8111
8134
|
if (!builtinPools.includes(pool)) {
|
|
@@ -8206,7 +8229,7 @@ ${JSON.stringify({ browser: { provider: "playwright", name: "chromium" } }, null
|
|
|
8206
8229
|
if (resolved.cache !== false) {
|
|
8207
8230
|
let cacheDir = VitestCache.resolveCacheDir(
|
|
8208
8231
|
"",
|
|
8209
|
-
|
|
8232
|
+
viteConfig.cacheDir,
|
|
8210
8233
|
resolved.name
|
|
8211
8234
|
);
|
|
8212
8235
|
if (resolved.cache && resolved.cache.dir) {
|
|
@@ -8242,6 +8265,15 @@ ${JSON.stringify({ browser: { provider: "playwright", name: "chromium" } }, null
|
|
|
8242
8265
|
...configDefaults.typecheck,
|
|
8243
8266
|
...resolved.typecheck
|
|
8244
8267
|
};
|
|
8268
|
+
if (resolved.environmentMatchGlobs) {
|
|
8269
|
+
logger.warn(
|
|
8270
|
+
c.yellow(
|
|
8271
|
+
`${c.inverse(
|
|
8272
|
+
c.yellow(" Vitest ")
|
|
8273
|
+
)} "environmentMatchGlobs" is deprecated. Use "workspace" to define different configurations instead.`
|
|
8274
|
+
)
|
|
8275
|
+
);
|
|
8276
|
+
}
|
|
8245
8277
|
resolved.environmentMatchGlobs = (resolved.environmentMatchGlobs || []).map(
|
|
8246
8278
|
(i) => [resolve(resolved.root, i[0]), i[1]]
|
|
8247
8279
|
);
|
|
@@ -8332,4 +8364,4 @@ function resolveCoverageReporters(configReporters) {
|
|
|
8332
8364
|
return resolvedReporters;
|
|
8333
8365
|
}
|
|
8334
8366
|
|
|
8335
|
-
export { VitestCache as V, resolveApiServerConfig as a, resolveConfig as b, coverageConfigDefaults as c, createMethodsRPC as d,
|
|
8367
|
+
export { VitestCache as V, resolveApiServerConfig as a, resolveConfig as b, coverageConfigDefaults as c, createMethodsRPC as d, groupBy as e, requireMicromatch as f, getFilePoolName as g, configDefaults as h, isPackageExists as i, isBrowserEnabled as j, createPool as k, mm as m, resolveCoverageReporters as r, stdout as s, wildcardPatternToRegExp as w };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
2
|
import { startTests, collectTests } from '@vitest/runner';
|
|
3
|
-
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.
|
|
3
|
+
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.CkOJwybT.js';
|
|
4
4
|
import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.BoMDb1ip.js';
|
|
5
|
-
import { a as globalExpect, v as vi } from './vi.
|
|
6
|
-
import { c as closeInspector } from './inspector.
|
|
5
|
+
import { a as globalExpect, v as vi } from './vi.CZKezqeD.js';
|
|
6
|
+
import { c as closeInspector } from './inspector.DKLceBVD.js';
|
|
7
7
|
import { createRequire } from 'node:module';
|
|
8
8
|
import timers from 'node:timers';
|
|
9
9
|
import util from 'node:util';
|
|
10
10
|
import { getSafeTimers } from '@vitest/utils';
|
|
11
11
|
import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
|
|
12
12
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
13
|
-
import { V as VitestIndex } from './index.
|
|
14
|
-
import { s as setupCommonEnv } from './setup-common.
|
|
13
|
+
import { V as VitestIndex } from './index.BqHViJW9.js';
|
|
14
|
+
import { s as setupCommonEnv } from './setup-common.B5ClyS48.js';
|
|
15
15
|
import { g as getWorkerState, r as resetModules } from './utils.C8RiOc4B.js';
|
|
16
16
|
import 'chai';
|
|
17
17
|
import 'node:path';
|
|
@@ -121,7 +121,7 @@ async function run(method, files, config, environment, executor) {
|
|
|
121
121
|
executor.mocker.reset();
|
|
122
122
|
resetModules(workerState.moduleCache, true);
|
|
123
123
|
}
|
|
124
|
-
workerState.filepath = file;
|
|
124
|
+
workerState.filepath = file.filepath;
|
|
125
125
|
if (method === "run") {
|
|
126
126
|
await startTests([file], runner);
|
|
127
127
|
} else {
|
|
@@ -13,7 +13,7 @@ async function setupCommonEnv(config) {
|
|
|
13
13
|
globalSetup = true;
|
|
14
14
|
setSafeTimers();
|
|
15
15
|
if (config.globals) {
|
|
16
|
-
(await import('./globals.
|
|
16
|
+
(await import('./globals.DJTzb7B3.js')).registerApiGlobally();
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
function setupDefines(defines) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as BenchFunction, c as BenchmarkAPI } from './benchmark.
|
|
1
|
+
import { Test } from '@vitest/runner';
|
|
2
|
+
import { a as BenchFunction, c as BenchmarkAPI } from './benchmark.CFFwLv-O.js';
|
|
3
3
|
import { Options } from 'tinybench';
|
|
4
4
|
import '@vitest/runner/utils';
|
|
5
5
|
|
|
6
|
-
declare function getBenchOptions(key:
|
|
7
|
-
declare function getBenchFn(key:
|
|
6
|
+
declare function getBenchOptions(key: Test): Options;
|
|
7
|
+
declare function getBenchFn(key: Test): BenchFunction;
|
|
8
8
|
declare const bench: BenchmarkAPI;
|
|
9
9
|
|
|
10
10
|
export { getBenchOptions as a, bench as b, getBenchFn as g };
|
|
@@ -11,9 +11,10 @@ const F_DOT = "\xB7";
|
|
|
11
11
|
const F_CHECK = "\u2713";
|
|
12
12
|
const F_CROSS = "\xD7";
|
|
13
13
|
const F_LONG_DASH = "\u23AF";
|
|
14
|
+
const F_TREE_NODE_MIDDLE = "\u251C\u2500\u2500";
|
|
15
|
+
const F_TREE_NODE_END = "\u2514\u2500\u2500";
|
|
14
16
|
|
|
15
17
|
const spinnerMap = /* @__PURE__ */ new WeakMap();
|
|
16
|
-
const hookSpinnerMap = /* @__PURE__ */ new WeakMap();
|
|
17
18
|
const pointer = c.yellow(F_POINTER);
|
|
18
19
|
const skipped = c.dim(c.gray(F_DOWN));
|
|
19
20
|
const benchmarkPass = c.green(F_DOT);
|
|
@@ -144,22 +145,6 @@ function getStateSymbol(task) {
|
|
|
144
145
|
}
|
|
145
146
|
return " ";
|
|
146
147
|
}
|
|
147
|
-
function getHookStateSymbol(task, hookName) {
|
|
148
|
-
const state = task.result?.hooks?.[hookName];
|
|
149
|
-
if (state && state === "run") {
|
|
150
|
-
let spinnerMap2 = hookSpinnerMap.get(task);
|
|
151
|
-
if (!spinnerMap2) {
|
|
152
|
-
spinnerMap2 = /* @__PURE__ */ new Map();
|
|
153
|
-
hookSpinnerMap.set(task, spinnerMap2);
|
|
154
|
-
}
|
|
155
|
-
let spinner = spinnerMap2.get(hookName);
|
|
156
|
-
if (!spinner) {
|
|
157
|
-
spinner = elegantSpinner();
|
|
158
|
-
spinnerMap2.set(hookName, spinner);
|
|
159
|
-
}
|
|
160
|
-
return c.yellow(spinner());
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
148
|
const spinnerFrames = process.platform === "win32" ? ["-", "\\", "|", "/"] : ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
164
149
|
function elegantSpinner() {
|
|
165
150
|
let index = 0;
|
|
@@ -171,16 +156,28 @@ function elegantSpinner() {
|
|
|
171
156
|
function formatTimeString(date) {
|
|
172
157
|
return date.toTimeString().split(" ")[0];
|
|
173
158
|
}
|
|
159
|
+
function formatTime(time) {
|
|
160
|
+
if (time > 1e3) {
|
|
161
|
+
return `${(time / 1e3).toFixed(2)}s`;
|
|
162
|
+
}
|
|
163
|
+
return `${Math.round(time)}ms`;
|
|
164
|
+
}
|
|
174
165
|
function formatProjectName(name, suffix = " ") {
|
|
175
166
|
if (!name) {
|
|
176
167
|
return "";
|
|
177
168
|
}
|
|
169
|
+
if (!c.isColorSupported) {
|
|
170
|
+
return `|${name}|${suffix}`;
|
|
171
|
+
}
|
|
178
172
|
const index = name.split("").reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0);
|
|
179
|
-
const colors = [c.
|
|
180
|
-
return colors[index % colors.length](
|
|
173
|
+
const colors = [c.black, c.yellow, c.cyan, c.green, c.magenta];
|
|
174
|
+
return c.inverse(colors[index % colors.length](` ${name} `)) + suffix;
|
|
181
175
|
}
|
|
182
176
|
function withLabel(color, label, message) {
|
|
183
|
-
return `${c.bold(c.inverse(c[color](` ${label} `)))} ${c[color](message)}`;
|
|
177
|
+
return `${c.bold(c.inverse(c[color](` ${label} `)))} ${message ? c[color](message) : ""}`;
|
|
178
|
+
}
|
|
179
|
+
function padSummaryTitle(str) {
|
|
180
|
+
return c.dim(`${str.padStart(11)} `);
|
|
184
181
|
}
|
|
185
182
|
|
|
186
183
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -191,12 +188,12 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
191
188
|
elegantSpinner: elegantSpinner,
|
|
192
189
|
formatProjectName: formatProjectName,
|
|
193
190
|
formatTestPath: formatTestPath,
|
|
191
|
+
formatTime: formatTime,
|
|
194
192
|
formatTimeString: formatTimeString,
|
|
195
193
|
getCols: getCols,
|
|
196
|
-
getHookStateSymbol: getHookStateSymbol,
|
|
197
194
|
getStateString: getStateString,
|
|
198
195
|
getStateSymbol: getStateSymbol,
|
|
199
|
-
|
|
196
|
+
padSummaryTitle: padSummaryTitle,
|
|
200
197
|
pending: pending,
|
|
201
198
|
pointer: pointer,
|
|
202
199
|
renderSnapshotSummary: renderSnapshotSummary,
|
|
@@ -209,4 +206,4 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
209
206
|
withLabel: withLabel
|
|
210
207
|
});
|
|
211
208
|
|
|
212
|
-
export { F_POINTER as F, formatTimeString as a, F_RIGHT as b, F_CHECK as c, divider as d, getStateString as e, formatProjectName as f, getStateSymbol as g,
|
|
209
|
+
export { F_POINTER as F, formatTimeString as a, F_RIGHT as b, F_CHECK as c, divider as d, getStateString as e, formatProjectName as f, getStateSymbol as g, formatTime as h, countTestErrors as i, F_TREE_NODE_END as j, F_TREE_NODE_MIDDLE as k, getCols as l, padSummaryTitle as p, renderSnapshotSummary as r, taskFail as t, utils as u, withLabel as w };
|
|
@@ -274,9 +274,9 @@ function recordAsyncExpect(_test, promise, assertion, error) {
|
|
|
274
274
|
}
|
|
275
275
|
});
|
|
276
276
|
return {
|
|
277
|
-
then(
|
|
277
|
+
then(onFulfilled, onRejected) {
|
|
278
278
|
resolved = true;
|
|
279
|
-
return promise.then(
|
|
279
|
+
return promise.then(onFulfilled, onRejected);
|
|
280
280
|
},
|
|
281
281
|
catch(onRejected) {
|
|
282
282
|
return promise.catch(onRejected);
|
|
@@ -318,15 +318,20 @@ function getError(expected, promise) {
|
|
|
318
318
|
throw new Error("snapshot function didn't throw");
|
|
319
319
|
}
|
|
320
320
|
function getTestNames(test) {
|
|
321
|
-
if (!test) {
|
|
322
|
-
return {};
|
|
323
|
-
}
|
|
324
321
|
return {
|
|
325
322
|
filepath: test.file.filepath,
|
|
326
|
-
name: getNames(test).slice(1).join(" > ")
|
|
323
|
+
name: getNames(test).slice(1).join(" > "),
|
|
324
|
+
testId: test.id
|
|
327
325
|
};
|
|
328
326
|
}
|
|
329
327
|
const SnapshotPlugin = (chai, utils) => {
|
|
328
|
+
function getTest(assertionName, obj) {
|
|
329
|
+
const test = utils.flag(obj, "vitest-test");
|
|
330
|
+
if (!test) {
|
|
331
|
+
throw new Error(`'${assertionName}' cannot be used without test context`);
|
|
332
|
+
}
|
|
333
|
+
return test;
|
|
334
|
+
}
|
|
330
335
|
for (const key of ["matchSnapshot", "toMatchSnapshot"]) {
|
|
331
336
|
utils.addMethod(
|
|
332
337
|
chai.Assertion.prototype,
|
|
@@ -338,7 +343,7 @@ const SnapshotPlugin = (chai, utils) => {
|
|
|
338
343
|
throw new Error(`${key} cannot be used with "not"`);
|
|
339
344
|
}
|
|
340
345
|
const expected = utils.flag(this, "object");
|
|
341
|
-
const test =
|
|
346
|
+
const test = getTest(key, this);
|
|
342
347
|
if (typeof properties === "string" && typeof message === "undefined") {
|
|
343
348
|
message = properties;
|
|
344
349
|
properties = void 0;
|
|
@@ -366,7 +371,7 @@ const SnapshotPlugin = (chai, utils) => {
|
|
|
366
371
|
}
|
|
367
372
|
const error = new Error("resolves");
|
|
368
373
|
const expected = utils.flag(this, "object");
|
|
369
|
-
const test =
|
|
374
|
+
const test = getTest("toMatchFileSnapshot", this);
|
|
370
375
|
const errorMessage = utils.flag(this, "message");
|
|
371
376
|
const promise = getSnapshotClient().assertRaw({
|
|
372
377
|
received: expected,
|
|
@@ -395,8 +400,8 @@ const SnapshotPlugin = (chai, utils) => {
|
|
|
395
400
|
if (isNot) {
|
|
396
401
|
throw new Error('toMatchInlineSnapshot cannot be used with "not"');
|
|
397
402
|
}
|
|
398
|
-
const test =
|
|
399
|
-
const isInsideEach = test
|
|
403
|
+
const test = getTest("toMatchInlineSnapshot", this);
|
|
404
|
+
const isInsideEach = test.each || test.suite?.each;
|
|
400
405
|
if (isInsideEach) {
|
|
401
406
|
throw new Error(
|
|
402
407
|
"InlineSnapshot cannot be used inside of test.each or describe.each"
|
|
@@ -437,7 +442,7 @@ const SnapshotPlugin = (chai, utils) => {
|
|
|
437
442
|
);
|
|
438
443
|
}
|
|
439
444
|
const expected = utils.flag(this, "object");
|
|
440
|
-
const test =
|
|
445
|
+
const test = getTest("toThrowErrorMatchingSnapshot", this);
|
|
441
446
|
const promise = utils.flag(this, "promise");
|
|
442
447
|
const errorMessage = utils.flag(this, "message");
|
|
443
448
|
getSnapshotClient().assert({
|
|
@@ -458,8 +463,8 @@ const SnapshotPlugin = (chai, utils) => {
|
|
|
458
463
|
'toThrowErrorMatchingInlineSnapshot cannot be used with "not"'
|
|
459
464
|
);
|
|
460
465
|
}
|
|
461
|
-
const test =
|
|
462
|
-
const isInsideEach = test
|
|
466
|
+
const test = getTest("toThrowErrorMatchingInlineSnapshot", this);
|
|
467
|
+
const isInsideEach = test.each || test.suite?.each;
|
|
463
468
|
if (isInsideEach) {
|
|
464
469
|
throw new Error(
|
|
465
470
|
"InlineSnapshot cannot be used inside of test.each or describe.each"
|
|
@@ -119,6 +119,7 @@ class CommonjsExecutor {
|
|
|
119
119
|
static constants = Module.constants;
|
|
120
120
|
static enableCompileCache = Module.enableCompileCache;
|
|
121
121
|
static getCompileCacheDir = Module.getCompileCacheDir;
|
|
122
|
+
static flushCompileCache = Module.flushCompileCache;
|
|
122
123
|
static Module = Module$1;
|
|
123
124
|
};
|
|
124
125
|
this.extensions[".js"] = this.requireJs;
|
|
@@ -830,8 +831,16 @@ async function runVmTests(method, state) {
|
|
|
830
831
|
const { run } = await executor.importExternalModule(
|
|
831
832
|
entryFile
|
|
832
833
|
);
|
|
834
|
+
const fileSpecs = ctx.files.map(
|
|
835
|
+
(f) => typeof f === "string" ? { filepath: f, testLocations: void 0 } : f
|
|
836
|
+
);
|
|
833
837
|
try {
|
|
834
|
-
await run(
|
|
838
|
+
await run(
|
|
839
|
+
method,
|
|
840
|
+
fileSpecs,
|
|
841
|
+
ctx.config,
|
|
842
|
+
executor
|
|
843
|
+
);
|
|
835
844
|
} finally {
|
|
836
845
|
await vm.teardown?.();
|
|
837
846
|
state.environmentTeardownRun = true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { File, TaskResultPack, CancelReason, Task } from '@vitest/runner';
|
|
1
|
+
import { File, TaskResultPack, CancelReason, FileSpec, Task } from '@vitest/runner';
|
|
2
2
|
import { ViteNodeResolveId, ModuleCacheMap } from 'vite-node';
|
|
3
|
-
import { S as SerializedConfig } from './config.
|
|
3
|
+
import { S as SerializedConfig } from './config.BTPBhmK5.js';
|
|
4
4
|
import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.CT0jpO-1.js';
|
|
5
5
|
import { SnapshotResult } from '@vitest/snapshot';
|
|
6
6
|
|
|
@@ -130,7 +130,7 @@ interface ContextRPC {
|
|
|
130
130
|
workerId: number;
|
|
131
131
|
config: SerializedConfig;
|
|
132
132
|
projectName: string;
|
|
133
|
-
files: string[];
|
|
133
|
+
files: string[] | FileSpec[];
|
|
134
134
|
environment: ContextTestEnvironment;
|
|
135
135
|
providedContext: Record<string, any>;
|
|
136
136
|
invalidates?: string[];
|