vitest 2.2.0-beta.2 → 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/LICENSE.md +75 -0
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +1 -1
- package/dist/chunks/{RandomSequencer.BPedXEug.js → RandomSequencer.gisBJ77r.js} +11 -4
- package/dist/chunks/{base.BS0HhLXd.js → base.CkcgFVQd.js} +8 -3
- package/dist/chunks/{cac.Cs06pOqp.js → cac.CWCZimpS.js} +7 -7
- package/dist/chunks/{cli-api.CB-jIbYQ.js → cli-api.BKUOv0Nc.js} +186 -83
- 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.bzFpKeaq.js → index.DKe7vK-G.js} +530 -144
- 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.F9D2idOT.d.ts → reporters.BZbwTvrM.d.ts} +249 -258
- package/dist/chunks/{resolveConfig.CLnvCvEs.js → resolveConfig.3rGGWga5.js} +81 -49
- 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/{utils.DJONn5B5.js → utils.CMUTX-p8.js} +5 -2
- package/dist/chunks/{vi.BlPttogV.js → vi.CZKezqeD.js} +18 -13
- package/dist/chunks/{vite.DonA4fvH.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 +4 -5
- package/dist/config.js +1 -10
- package/dist/coverage.d.ts +2 -2
- package/dist/coverage.js +4 -4
- package/dist/execute.d.ts +3 -3
- package/dist/index.d.ts +21 -13
- package/dist/index.js +2 -2
- package/dist/node.d.ts +9 -22
- package/dist/node.js +9 -9
- package/dist/reporters.d.ts +2 -2
- package/dist/reporters.js +5 -4
- package/dist/runners.d.ts +1 -2
- package/dist/runners.js +9 -14
- 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 +21 -22
|
@@ -8,12 +8,12 @@ import { f as findUp, p as prompt } from './index.BJDntFik.js';
|
|
|
8
8
|
import { searchForWorkspaceRoot, version, createServer, mergeConfig } from 'vite';
|
|
9
9
|
import { A as API_PATH, c as configFiles, a as defaultBrowserPort, w as workspacesFiles, d as defaultPort } from './constants.fzPh7AOq.js';
|
|
10
10
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
11
|
-
import { i as isPackageExists,
|
|
11
|
+
import { e as groupBy, i as isPackageExists, f as requireMicromatch, V as VitestCache, h as configDefaults, g as getFilePoolName, j as isBrowserEnabled, m as mm, b as resolveConfig, w as wildcardPatternToRegExp, k as createPool, a as resolveApiServerConfig, c as coverageConfigDefaults, s as stdout } from './resolveConfig.3rGGWga5.js';
|
|
12
12
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
13
13
|
import { ViteNodeServer } from 'vite-node/server';
|
|
14
|
-
import { v as version$1 } from './cac.
|
|
14
|
+
import { v as version$1 } from './cac.CWCZimpS.js';
|
|
15
15
|
import { c as createBirpc } from './index.68735LiX.js';
|
|
16
|
-
import { s as stringify, p as parse, i as generateCodeFrame, R as ReportersMap, h as BenchmarkReportsMap, f as TestModule, g as TestSuite, e as TestCase, L as Logger, j as BlobReporter, r as readBlobs } from './index.
|
|
16
|
+
import { s as stringify, p as parse, i as generateCodeFrame, R as ReportersMap, h as BenchmarkReportsMap, f as TestModule, g as TestSuite, e as TestCase, L as Logger, j as BlobReporter, r as readBlobs } from './index.DKe7vK-G.js';
|
|
17
17
|
import require$$0$2 from 'stream';
|
|
18
18
|
import require$$0 from 'zlib';
|
|
19
19
|
import require$$0$1 from 'buffer';
|
|
@@ -30,7 +30,7 @@ import { distDir, rootDir } from '../path.js';
|
|
|
30
30
|
import { createRequire } from 'node:module';
|
|
31
31
|
import url from 'node:url';
|
|
32
32
|
import c from 'tinyrainbow';
|
|
33
|
-
import { h as hash, i as isWindows } from './RandomSequencer.
|
|
33
|
+
import { h as hash, i as isWindows } from './RandomSequencer.gisBJ77r.js';
|
|
34
34
|
import { isCI } from 'std-env';
|
|
35
35
|
import { rm } from 'node:fs/promises';
|
|
36
36
|
import nodeos__default, { tmpdir } from 'node:os';
|
|
@@ -5069,6 +5069,59 @@ class GitNotFoundError extends Error {
|
|
|
5069
5069
|
super("Could not find Git root. Have you initialized git with `git init`?");
|
|
5070
5070
|
}
|
|
5071
5071
|
}
|
|
5072
|
+
class LocationFilterFileNotFoundError extends Error {
|
|
5073
|
+
code = "VITEST_LOCATION_FILTER_FILE_NOT_FOUND";
|
|
5074
|
+
constructor(filename) {
|
|
5075
|
+
super(`Couldn't find file ${filename}. Note when specifying the test location you have to specify the full test filename.`);
|
|
5076
|
+
}
|
|
5077
|
+
}
|
|
5078
|
+
class IncludeTaskLocationDisabledError extends Error {
|
|
5079
|
+
code = "VITEST_INCLUDE_TASK_LOCATION_DISABLED";
|
|
5080
|
+
constructor() {
|
|
5081
|
+
super("Recieved line number filters while `includeTaskLocation` option is disabled");
|
|
5082
|
+
}
|
|
5083
|
+
}
|
|
5084
|
+
class RangeLocationFilterProvidedError extends Error {
|
|
5085
|
+
code = "VITEST_RANGE_LOCATION_FILTER_PROVIDED";
|
|
5086
|
+
constructor(filter) {
|
|
5087
|
+
super(`Found "-" in location filter ${filter}. Note that range location filters are not supported. Consider specifying the exact line numbers of your tests.`);
|
|
5088
|
+
}
|
|
5089
|
+
}
|
|
5090
|
+
|
|
5091
|
+
function parseFilter(filter) {
|
|
5092
|
+
const colonIndex = filter.lastIndexOf(":");
|
|
5093
|
+
if (colonIndex === -1) {
|
|
5094
|
+
return { filename: filter };
|
|
5095
|
+
}
|
|
5096
|
+
const [parsedFilename, lineNumber] = [
|
|
5097
|
+
filter.substring(0, colonIndex),
|
|
5098
|
+
filter.substring(colonIndex + 1)
|
|
5099
|
+
];
|
|
5100
|
+
if (lineNumber.match(/^\d+$/)) {
|
|
5101
|
+
return {
|
|
5102
|
+
filename: parsedFilename,
|
|
5103
|
+
lineNumber: Number.parseInt(lineNumber)
|
|
5104
|
+
};
|
|
5105
|
+
} else if (lineNumber.match(/^\d+-\d+$/)) {
|
|
5106
|
+
throw new RangeLocationFilterProvidedError(filter);
|
|
5107
|
+
} else {
|
|
5108
|
+
return { filename: filter };
|
|
5109
|
+
}
|
|
5110
|
+
}
|
|
5111
|
+
function groupFilters(filters) {
|
|
5112
|
+
const groupedFilters_ = groupBy(filters, (f) => f.filename);
|
|
5113
|
+
const groupedFilters = Object.fromEntries(
|
|
5114
|
+
Object.entries(groupedFilters_).map((entry) => {
|
|
5115
|
+
const [filename, filters2] = entry;
|
|
5116
|
+
const testLocations = filters2.map((f) => f.lineNumber);
|
|
5117
|
+
return [
|
|
5118
|
+
filename,
|
|
5119
|
+
testLocations.filter((l) => l !== void 0)
|
|
5120
|
+
];
|
|
5121
|
+
})
|
|
5122
|
+
);
|
|
5123
|
+
return groupedFilters;
|
|
5124
|
+
}
|
|
5072
5125
|
|
|
5073
5126
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
5074
5127
|
class VitestPackageInstaller {
|
|
@@ -5111,7 +5164,7 @@ class VitestPackageInstaller {
|
|
|
5111
5164
|
});
|
|
5112
5165
|
if (install) {
|
|
5113
5166
|
const packageName = version ? `${dependency}@${version}` : dependency;
|
|
5114
|
-
await (await import('./index.
|
|
5167
|
+
await (await import('./index.DQboAxJm.js')).installPackage(packageName, { dev: true });
|
|
5115
5168
|
process.stderr.write(
|
|
5116
5169
|
c.yellow(
|
|
5117
5170
|
`
|
|
@@ -8703,7 +8756,7 @@ function requireJsTokens () {
|
|
|
8703
8756
|
// Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
|
|
8704
8757
|
// License: MIT.
|
|
8705
8758
|
var HashbangComment, Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
|
|
8706
|
-
RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:[^\]\\\n\r\u2028\u2029]+|\\.)*\]
|
|
8759
|
+
RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:[^\]\\\n\r\u2028\u2029]+|\\.)*\]?|[^\/[\\\n\r\u2028\u2029]+|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/yu;
|
|
8707
8760
|
Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
|
|
8708
8761
|
Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]+|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/yu;
|
|
8709
8762
|
StringLiteral = /(['"])(?:[^'"\\\n\r]+|(?!\1)['"]|\\(?:\r\n|[^]))*(\1)?/y;
|
|
@@ -9543,14 +9596,17 @@ class TestSpecification {
|
|
|
9543
9596
|
project;
|
|
9544
9597
|
moduleId;
|
|
9545
9598
|
pool;
|
|
9599
|
+
/** @private */
|
|
9600
|
+
testLocations;
|
|
9546
9601
|
// public readonly location: WorkspaceSpecLocation | undefined
|
|
9547
|
-
constructor(project, moduleId, pool) {
|
|
9602
|
+
constructor(project, moduleId, pool, testLocations) {
|
|
9548
9603
|
this[0] = project;
|
|
9549
9604
|
this[1] = moduleId;
|
|
9550
9605
|
this[2] = { pool };
|
|
9551
9606
|
this.project = project;
|
|
9552
9607
|
this.moduleId = moduleId;
|
|
9553
9608
|
this.pool = pool;
|
|
9609
|
+
this.testLocations = testLocations;
|
|
9554
9610
|
}
|
|
9555
9611
|
toJSON() {
|
|
9556
9612
|
return [
|
|
@@ -9623,10 +9679,12 @@ class TestProject {
|
|
|
9623
9679
|
_provided = {};
|
|
9624
9680
|
_config;
|
|
9625
9681
|
_vite;
|
|
9682
|
+
// "provide" is a property, not a method to keep the context when destructed in the global setup,
|
|
9683
|
+
// making it a method would be a breaking change, and can be done in Vitest 3 at minimum
|
|
9626
9684
|
/**
|
|
9627
9685
|
* Provide a value to the test context. This value will be available to all tests with `inject`.
|
|
9628
9686
|
*/
|
|
9629
|
-
provide(key, value) {
|
|
9687
|
+
provide = (key, value) => {
|
|
9630
9688
|
try {
|
|
9631
9689
|
structuredClone(value);
|
|
9632
9690
|
} catch (err) {
|
|
@@ -9638,7 +9696,7 @@ class TestProject {
|
|
|
9638
9696
|
);
|
|
9639
9697
|
}
|
|
9640
9698
|
this._provided[key] = value;
|
|
9641
|
-
}
|
|
9699
|
+
};
|
|
9642
9700
|
/**
|
|
9643
9701
|
* Get the provided context. The project context is merged with the global context.
|
|
9644
9702
|
*/
|
|
@@ -9655,11 +9713,12 @@ class TestProject {
|
|
|
9655
9713
|
* Creates a new test specification. Specifications describe how to run tests.
|
|
9656
9714
|
* @param moduleId The file path
|
|
9657
9715
|
*/
|
|
9658
|
-
createSpecification(moduleId, pool) {
|
|
9716
|
+
createSpecification(moduleId, pool, testLocations) {
|
|
9659
9717
|
return new TestSpecification(
|
|
9660
9718
|
this,
|
|
9661
9719
|
moduleId,
|
|
9662
|
-
pool || getFilePoolName(this, moduleId)
|
|
9720
|
+
pool || getFilePoolName(this, moduleId),
|
|
9721
|
+
testLocations
|
|
9663
9722
|
);
|
|
9664
9723
|
}
|
|
9665
9724
|
toJSON() {
|
|
@@ -9731,11 +9790,7 @@ class TestProject {
|
|
|
9731
9790
|
this.config.globalSetup
|
|
9732
9791
|
);
|
|
9733
9792
|
for (const globalSetupFile of this._globalSetups) {
|
|
9734
|
-
const teardown = await globalSetupFile.setup?.(
|
|
9735
|
-
provide: (key, value) => this.provide(key, value),
|
|
9736
|
-
config: this.config,
|
|
9737
|
-
onTestsRerun: (cb) => this.vitest.onTestsRerun(cb)
|
|
9738
|
-
});
|
|
9793
|
+
const teardown = await globalSetupFile.setup?.(this);
|
|
9739
9794
|
if (teardown == null || !!globalSetupFile.teardown) {
|
|
9740
9795
|
continue;
|
|
9741
9796
|
}
|
|
@@ -9747,6 +9802,9 @@ class TestProject {
|
|
|
9747
9802
|
globalSetupFile.teardown = teardown;
|
|
9748
9803
|
}
|
|
9749
9804
|
}
|
|
9805
|
+
onTestsRerun(cb) {
|
|
9806
|
+
this.vitest.onTestsRerun(cb);
|
|
9807
|
+
}
|
|
9750
9808
|
/** @deprecated */
|
|
9751
9809
|
teardownGlobalSetup() {
|
|
9752
9810
|
return this._teardownGlobalSetup();
|
|
@@ -10053,18 +10111,15 @@ class TestProject {
|
|
|
10053
10111
|
}
|
|
10054
10112
|
async function initializeProject(workspacePath, ctx, options) {
|
|
10055
10113
|
const project = new TestProject(workspacePath, ctx, options);
|
|
10056
|
-
const { extends: extendsConfig,
|
|
10057
|
-
const root = options.root || (typeof workspacePath === "number" ? void 0 : workspacePath.endsWith("/") ? workspacePath : dirname(workspacePath));
|
|
10058
|
-
const configFile = extendsConfig ? resolve(dirname(workspaceConfigPath), extendsConfig) : typeof workspacePath === "number" || workspacePath.endsWith("/") ? false : workspacePath;
|
|
10114
|
+
const { extends: extendsConfig, configFile, ...restOptions } = options;
|
|
10059
10115
|
const config = {
|
|
10060
10116
|
...restOptions,
|
|
10061
|
-
root,
|
|
10062
10117
|
configFile,
|
|
10063
10118
|
// this will make "mode": "test" | "benchmark" inside defineConfig
|
|
10064
10119
|
mode: options.test?.mode || options.mode || ctx.config.mode,
|
|
10065
10120
|
plugins: [
|
|
10066
10121
|
...options.plugins || [],
|
|
10067
|
-
WorkspaceVitestPlugin(project, { ...options,
|
|
10122
|
+
WorkspaceVitestPlugin(project, { ...options, workspacePath })
|
|
10068
10123
|
]
|
|
10069
10124
|
};
|
|
10070
10125
|
await createViteServer(config);
|
|
@@ -10387,35 +10442,41 @@ async function resolveWorkspace(vitest, cliOptions, workspaceConfigPath, workspa
|
|
|
10387
10442
|
const projectPromises = [];
|
|
10388
10443
|
const fileProjects = [...configFiles, ...nonConfigDirectories];
|
|
10389
10444
|
const concurrent = limitConcurrency(nodeos__default.availableParallelism?.() || nodeos__default.cpus().length || 5);
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
10445
|
+
projectConfigs.forEach((options, index) => {
|
|
10446
|
+
const configRoot = workspaceConfigPath ? dirname(workspaceConfigPath) : vitest.config.root;
|
|
10447
|
+
const configFile = typeof options.extends === "string" ? resolve(configRoot, options.extends) : false;
|
|
10448
|
+
const rootOptions = options.extends === true ? vitest._options : {};
|
|
10449
|
+
const root = options.root ? resolve(configRoot, options.root) : vitest.config.root;
|
|
10450
|
+
projectPromises.push(concurrent(() => initializeProject(
|
|
10451
|
+
index,
|
|
10452
|
+
vitest,
|
|
10453
|
+
mergeConfig(rootOptions, { ...options, root, configFile })
|
|
10454
|
+
)));
|
|
10455
|
+
});
|
|
10456
|
+
for (const path of fileProjects) {
|
|
10457
|
+
if (vitest.server.config.configFile === path) {
|
|
10458
|
+
projectPromises.push(Promise.resolve(vitest._createRootProject()));
|
|
10393
10459
|
continue;
|
|
10394
10460
|
}
|
|
10461
|
+
const configFile = path.endsWith("/") ? false : path;
|
|
10462
|
+
const root = path.endsWith("/") ? path : dirname(path);
|
|
10395
10463
|
projectPromises.push(
|
|
10396
10464
|
concurrent(() => initializeProject(
|
|
10397
|
-
|
|
10465
|
+
path,
|
|
10398
10466
|
vitest,
|
|
10399
|
-
{
|
|
10467
|
+
{ root, configFile, test: cliOverrides }
|
|
10400
10468
|
))
|
|
10401
10469
|
);
|
|
10402
10470
|
}
|
|
10403
|
-
projectConfigs.forEach((options, index) => {
|
|
10404
|
-
projectPromises.push(concurrent(() => initializeProject(
|
|
10405
|
-
index,
|
|
10406
|
-
vitest,
|
|
10407
|
-
mergeConfig(options, { workspaceConfigPath, test: cliOverrides })
|
|
10408
|
-
)));
|
|
10409
|
-
});
|
|
10410
10471
|
if (!projectPromises.length) {
|
|
10411
|
-
return [
|
|
10472
|
+
return [vitest._createRootProject()];
|
|
10412
10473
|
}
|
|
10413
10474
|
const resolvedProjects = await Promise.all(projectPromises);
|
|
10414
10475
|
const names = /* @__PURE__ */ new Set();
|
|
10415
10476
|
for (const project of resolvedProjects) {
|
|
10416
|
-
const name = project.
|
|
10477
|
+
const name = project.name;
|
|
10417
10478
|
if (names.has(name)) {
|
|
10418
|
-
const duplicate = resolvedProjects.find((p) => p.
|
|
10479
|
+
const duplicate = resolvedProjects.find((p) => p.name === name && p !== project);
|
|
10419
10480
|
const filesError = fileProjects.length ? [
|
|
10420
10481
|
"\n\nYour config matched these files:\n",
|
|
10421
10482
|
fileProjects.map((p) => ` - ${relative(vitest.config.root, p)}`).join("\n"),
|
|
@@ -10439,14 +10500,15 @@ async function resolveTestProjectConfigs(vitest, workspaceConfigPath, workspaceD
|
|
|
10439
10500
|
const workspaceConfigFiles = [];
|
|
10440
10501
|
const workspaceGlobMatches = [];
|
|
10441
10502
|
const nonConfigProjectDirectories = [];
|
|
10442
|
-
const relativeWorkpaceConfigPath = relative(vitest.config.root, workspaceConfigPath);
|
|
10443
10503
|
for (const definition of workspaceDefinition) {
|
|
10444
10504
|
if (typeof definition === "string") {
|
|
10445
10505
|
const stringOption = definition.replace("<rootDir>", vitest.config.root);
|
|
10446
10506
|
if (!isDynamicPattern(stringOption)) {
|
|
10447
10507
|
const file = resolve(vitest.config.root, stringOption);
|
|
10448
10508
|
if (!existsSync(file)) {
|
|
10449
|
-
|
|
10509
|
+
const relativeWorkpaceConfigPath = workspaceConfigPath ? relative(vitest.config.root, workspaceConfigPath) : void 0;
|
|
10510
|
+
const note = workspaceConfigPath ? `Workspace config file "${relativeWorkpaceConfigPath}"` : "Inline workspace";
|
|
10511
|
+
throw new Error(`${note} references a non-existing file or a directory: ${file}`);
|
|
10450
10512
|
}
|
|
10451
10513
|
const stats = await promises.stat(file);
|
|
10452
10514
|
if (stats.isFile()) {
|
|
@@ -10494,16 +10556,16 @@ async function resolveTestProjectConfigs(vitest, workspaceConfigPath, workspaceD
|
|
|
10494
10556
|
]
|
|
10495
10557
|
};
|
|
10496
10558
|
const workspacesFs = await fg.glob(workspaceGlobMatches, globOptions);
|
|
10497
|
-
await Promise.all(workspacesFs.map(async (
|
|
10498
|
-
if (
|
|
10499
|
-
const configFile = await resolveDirectoryConfig(
|
|
10559
|
+
await Promise.all(workspacesFs.map(async (path) => {
|
|
10560
|
+
if (path.endsWith("/")) {
|
|
10561
|
+
const configFile = await resolveDirectoryConfig(path);
|
|
10500
10562
|
if (configFile) {
|
|
10501
10563
|
workspaceConfigFiles.push(configFile);
|
|
10502
10564
|
} else {
|
|
10503
|
-
nonConfigProjectDirectories.push(
|
|
10565
|
+
nonConfigProjectDirectories.push(path);
|
|
10504
10566
|
}
|
|
10505
10567
|
} else {
|
|
10506
|
-
workspaceConfigFiles.push(
|
|
10568
|
+
workspaceConfigFiles.push(path);
|
|
10507
10569
|
}
|
|
10508
10570
|
}));
|
|
10509
10571
|
}
|
|
@@ -10553,6 +10615,7 @@ class Vitest {
|
|
|
10553
10615
|
restartsCount = 0;
|
|
10554
10616
|
runner = void 0;
|
|
10555
10617
|
packageInstaller;
|
|
10618
|
+
/** TODO: rename to `_coreRootProject` */
|
|
10556
10619
|
/** @internal */
|
|
10557
10620
|
coreWorkspaceProject;
|
|
10558
10621
|
/** @private */
|
|
@@ -10563,14 +10626,17 @@ class Vitest {
|
|
|
10563
10626
|
_workspaceConfigPath;
|
|
10564
10627
|
/** @deprecated use `_cachedSpecs` */
|
|
10565
10628
|
projectTestFiles = this._cachedSpecs;
|
|
10566
|
-
/** @
|
|
10629
|
+
/** @internal */
|
|
10567
10630
|
_browserLastPort = defaultBrowserPort;
|
|
10631
|
+
/** @internal */
|
|
10632
|
+
_options = {};
|
|
10568
10633
|
_onRestartListeners = [];
|
|
10569
10634
|
_onClose = [];
|
|
10570
10635
|
_onSetServer = [];
|
|
10571
10636
|
_onCancelListeners = [];
|
|
10572
10637
|
_onUserTestsRerun = [];
|
|
10573
10638
|
async setServer(options, server, cliOptions) {
|
|
10639
|
+
this._options = options;
|
|
10574
10640
|
this.unregisterWatcher?.();
|
|
10575
10641
|
clearTimeout(this._rerunTimer);
|
|
10576
10642
|
this.restartsCount += 1;
|
|
@@ -10616,7 +10682,7 @@ class Vitest {
|
|
|
10616
10682
|
};
|
|
10617
10683
|
server.watcher.on("change", async (file) => {
|
|
10618
10684
|
file = normalize(file);
|
|
10619
|
-
const isConfig = file === server.config.configFile || this.resolvedProjects.some((p) => p.
|
|
10685
|
+
const isConfig = file === server.config.configFile || this.resolvedProjects.some((p) => p.vite.config.configFile === file) || file === this._workspaceConfigPath;
|
|
10620
10686
|
if (isConfig) {
|
|
10621
10687
|
await Promise.all(this._onRestartListeners.map((fn) => fn("config")));
|
|
10622
10688
|
this.report("onServerRestart", "config");
|
|
@@ -10637,7 +10703,7 @@ class Vitest {
|
|
|
10637
10703
|
const filters = toArray(resolved.project).map((s) => wildcardPatternToRegExp(s));
|
|
10638
10704
|
if (filters.length > 0) {
|
|
10639
10705
|
this.projects = this.projects.filter(
|
|
10640
|
-
(p) => filters.some((pattern) => pattern.test(p.
|
|
10706
|
+
(p) => filters.some((pattern) => pattern.test(p.name))
|
|
10641
10707
|
);
|
|
10642
10708
|
}
|
|
10643
10709
|
if (!this.coreWorkspaceProject) {
|
|
@@ -10654,7 +10720,7 @@ class Vitest {
|
|
|
10654
10720
|
/**
|
|
10655
10721
|
* @internal
|
|
10656
10722
|
*/
|
|
10657
|
-
|
|
10723
|
+
_createRootProject() {
|
|
10658
10724
|
this.coreWorkspaceProject = TestProject._createBasicProject(this);
|
|
10659
10725
|
return this.coreWorkspaceProject;
|
|
10660
10726
|
}
|
|
@@ -10675,8 +10741,8 @@ class Vitest {
|
|
|
10675
10741
|
getProjectByName(name = "") {
|
|
10676
10742
|
return this.projects.find((p) => p.name === name) || this.coreWorkspaceProject || this.projects[0];
|
|
10677
10743
|
}
|
|
10678
|
-
async
|
|
10679
|
-
if (this.config.workspace) {
|
|
10744
|
+
async resolveWorkspaceConfigPath() {
|
|
10745
|
+
if (typeof this.config.workspace === "string") {
|
|
10680
10746
|
return this.config.workspace;
|
|
10681
10747
|
}
|
|
10682
10748
|
const configDir = this.server.config.configFile ? dirname(this.server.config.configFile) : this.config.root;
|
|
@@ -10690,10 +10756,18 @@ class Vitest {
|
|
|
10690
10756
|
return join(configDir, workspaceConfigName);
|
|
10691
10757
|
}
|
|
10692
10758
|
async resolveWorkspace(cliOptions) {
|
|
10693
|
-
|
|
10759
|
+
if (Array.isArray(this.config.workspace)) {
|
|
10760
|
+
return resolveWorkspace(
|
|
10761
|
+
this,
|
|
10762
|
+
cliOptions,
|
|
10763
|
+
void 0,
|
|
10764
|
+
this.config.workspace
|
|
10765
|
+
);
|
|
10766
|
+
}
|
|
10767
|
+
const workspaceConfigPath = await this.resolveWorkspaceConfigPath();
|
|
10694
10768
|
this._workspaceConfigPath = workspaceConfigPath;
|
|
10695
10769
|
if (!workspaceConfigPath) {
|
|
10696
|
-
return [this.
|
|
10770
|
+
return [this._createRootProject()];
|
|
10697
10771
|
}
|
|
10698
10772
|
const workspaceModule = await this.runner.executeFile(workspaceConfigPath);
|
|
10699
10773
|
if (!workspaceModule.default || !Array.isArray(workspaceModule.default)) {
|
|
@@ -10933,35 +11007,38 @@ class Vitest {
|
|
|
10933
11007
|
this._onCancelListeners = [];
|
|
10934
11008
|
this.isCancelling = false;
|
|
10935
11009
|
this.runningPromise = (async () => {
|
|
10936
|
-
if (!this.pool) {
|
|
10937
|
-
this.pool = createPool(this);
|
|
10938
|
-
}
|
|
10939
|
-
const invalidates = Array.from(this.invalidates);
|
|
10940
|
-
this.invalidates.clear();
|
|
10941
|
-
this.snapshot.clear();
|
|
10942
|
-
this.state.clearErrors();
|
|
10943
|
-
if (!this.isFirstRun && this.config.coverage.cleanOnRerun) {
|
|
10944
|
-
await this.coverageProvider?.clean();
|
|
10945
|
-
}
|
|
10946
|
-
await this.initializeGlobalSetup(specs);
|
|
10947
11010
|
try {
|
|
10948
|
-
|
|
10949
|
-
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
11011
|
+
if (!this.pool) {
|
|
11012
|
+
this.pool = createPool(this);
|
|
11013
|
+
}
|
|
11014
|
+
const invalidates = Array.from(this.invalidates);
|
|
11015
|
+
this.invalidates.clear();
|
|
11016
|
+
this.snapshot.clear();
|
|
11017
|
+
this.state.clearErrors();
|
|
11018
|
+
if (!this.isFirstRun && this.config.coverage.cleanOnRerun) {
|
|
11019
|
+
await this.coverageProvider?.clean();
|
|
11020
|
+
}
|
|
11021
|
+
await this.initializeGlobalSetup(specs);
|
|
11022
|
+
try {
|
|
11023
|
+
await this.pool.runTests(specs, invalidates);
|
|
11024
|
+
} catch (err) {
|
|
11025
|
+
this.state.catchError(err, "Unhandled Error");
|
|
11026
|
+
}
|
|
11027
|
+
const files = this.state.getFiles();
|
|
11028
|
+
if (hasFailed(files)) {
|
|
11029
|
+
process.exitCode = 1;
|
|
11030
|
+
}
|
|
11031
|
+
this.cache.results.updateResults(files);
|
|
11032
|
+
await this.cache.results.writeToCache();
|
|
11033
|
+
} finally {
|
|
11034
|
+
const files = Array.from(new Set(specs.map((spec) => spec.moduleId)));
|
|
11035
|
+
const errors = this.state.getUnhandledErrors();
|
|
11036
|
+
const coverage = await this.coverageProvider?.generateCoverage({ allTestsRun });
|
|
11037
|
+
this.checkUnhandledErrors(errors);
|
|
11038
|
+
await this.report("onFinished", this.state.getFiles(files), errors, coverage);
|
|
11039
|
+
await this.reportCoverage(coverage, allTestsRun);
|
|
10955
11040
|
}
|
|
10956
|
-
|
|
10957
|
-
await this.cache.results.writeToCache();
|
|
10958
|
-
})().finally(async () => {
|
|
10959
|
-
const files = Array.from(new Set(specs.map((spec) => spec.moduleId)));
|
|
10960
|
-
const errors = this.state.getUnhandledErrors();
|
|
10961
|
-
const coverage = await this.coverageProvider?.generateCoverage({ allTestsRun });
|
|
10962
|
-
this.checkUnhandledErrors(errors);
|
|
10963
|
-
await this.report("onFinished", this.state.getFiles(files), errors, coverage);
|
|
10964
|
-
await this.reportCoverage(coverage, allTestsRun);
|
|
11041
|
+
})().finally(() => {
|
|
10965
11042
|
this.runningPromise = void 0;
|
|
10966
11043
|
this.isFirstRun = false;
|
|
10967
11044
|
this.config.changed = false;
|
|
@@ -10993,7 +11070,7 @@ class Vitest {
|
|
|
10993
11070
|
if (hasFailed(files)) {
|
|
10994
11071
|
process.exitCode = 1;
|
|
10995
11072
|
}
|
|
10996
|
-
})().finally(
|
|
11073
|
+
})().finally(() => {
|
|
10997
11074
|
this.runningPromise = void 0;
|
|
10998
11075
|
this.config.changed = false;
|
|
10999
11076
|
this.config.related = void 0;
|
|
@@ -11042,7 +11119,7 @@ class Vitest {
|
|
|
11042
11119
|
} else {
|
|
11043
11120
|
this.configOverride.project = pattern;
|
|
11044
11121
|
}
|
|
11045
|
-
this.projects = this.resolvedProjects.filter((p) => p.
|
|
11122
|
+
this.projects = this.resolvedProjects.filter((p) => p.name === pattern);
|
|
11046
11123
|
const files = (await this.globTestSpecs()).map((spec) => spec.moduleId);
|
|
11047
11124
|
await this.rerunFiles(files, "change project filter", pattern === "");
|
|
11048
11125
|
}
|
|
@@ -11354,19 +11431,41 @@ class Vitest {
|
|
|
11354
11431
|
}
|
|
11355
11432
|
async globTestSpecs(filters = []) {
|
|
11356
11433
|
const files = [];
|
|
11434
|
+
const dir = process.cwd();
|
|
11435
|
+
const parsedFilters = filters.map((f) => parseFilter(f));
|
|
11436
|
+
if (!this.config.includeTaskLocation && parsedFilters.some((f) => f.lineNumber !== void 0)) {
|
|
11437
|
+
throw new IncludeTaskLocationDisabledError();
|
|
11438
|
+
}
|
|
11439
|
+
const testLocations = groupFilters(parsedFilters.map(
|
|
11440
|
+
(f) => ({ ...f, filename: slash(resolve$1(dir, f.filename)) })
|
|
11441
|
+
));
|
|
11442
|
+
const testLocHasMatch = {};
|
|
11357
11443
|
await Promise.all(this.projects.map(async (project) => {
|
|
11358
|
-
const { testFiles, typecheckTestFiles } = await project.globTestFiles(
|
|
11444
|
+
const { testFiles, typecheckTestFiles } = await project.globTestFiles(
|
|
11445
|
+
parsedFilters.map((f) => f.filename)
|
|
11446
|
+
);
|
|
11359
11447
|
testFiles.forEach((file) => {
|
|
11360
|
-
const
|
|
11448
|
+
const loc = testLocations[file];
|
|
11449
|
+
testLocHasMatch[file] = true;
|
|
11450
|
+
const spec = project.createSpecification(file, void 0, loc);
|
|
11361
11451
|
this.ensureSpecCached(spec);
|
|
11362
11452
|
files.push(spec);
|
|
11363
11453
|
});
|
|
11364
11454
|
typecheckTestFiles.forEach((file) => {
|
|
11365
|
-
const
|
|
11455
|
+
const loc = testLocations[file];
|
|
11456
|
+
testLocHasMatch[file] = true;
|
|
11457
|
+
const spec = project.createSpecification(file, "typescript", loc);
|
|
11366
11458
|
this.ensureSpecCached(spec);
|
|
11367
11459
|
files.push(spec);
|
|
11368
11460
|
});
|
|
11369
11461
|
}));
|
|
11462
|
+
Object.entries(testLocations).forEach(([filepath, loc]) => {
|
|
11463
|
+
if (loc.length !== 0 && !testLocHasMatch[filepath]) {
|
|
11464
|
+
throw new LocationFilterFileNotFoundError(
|
|
11465
|
+
relative(dir, filepath)
|
|
11466
|
+
);
|
|
11467
|
+
}
|
|
11468
|
+
});
|
|
11370
11469
|
return files;
|
|
11371
11470
|
}
|
|
11372
11471
|
/**
|
|
@@ -12013,6 +12112,10 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, v
|
|
|
12013
12112
|
ctx.logger.error(e.message);
|
|
12014
12113
|
return ctx;
|
|
12015
12114
|
}
|
|
12115
|
+
if (e instanceof IncludeTaskLocationDisabledError || e instanceof RangeLocationFilterProvidedError || e instanceof LocationFilterFileNotFoundError) {
|
|
12116
|
+
ctx.logger.printError(e, { verbose: false });
|
|
12117
|
+
return ctx;
|
|
12118
|
+
}
|
|
12016
12119
|
process.exitCode = 1;
|
|
12017
12120
|
ctx.logger.printError(e, { fullStack: true, type: "Unhandled Error" });
|
|
12018
12121
|
ctx.logger.error("\n\n");
|
|
@@ -33,7 +33,7 @@ interface FakeTimerInstallOpts {
|
|
|
33
33
|
/**
|
|
34
34
|
* An array with names of global methods and APIs to fake.
|
|
35
35
|
* For instance, `vi.useFakeTimer({ toFake: ['setTimeout', 'performance'] })` will fake only `setTimeout()` and `performance.now()`
|
|
36
|
-
* @default
|
|
36
|
+
* @default everything available globally except `nextTick`
|
|
37
37
|
*/
|
|
38
38
|
toFake?: FakeMethod[] | undefined;
|
|
39
39
|
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { existsSync, writeFileSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { resolve, dirname, relative } from 'node:path';
|
|
4
|
-
import { detectPackageManager, installPackage } from './index.
|
|
4
|
+
import { detectPackageManager, installPackage } from './index.DQboAxJm.js';
|
|
5
5
|
import { p as prompt, f as findUp } from './index.BJDntFik.js';
|
|
6
6
|
import { x } from 'tinyexec';
|
|
7
7
|
import c from 'tinyrainbow';
|
|
8
8
|
import { c as configFiles } from './constants.fzPh7AOq.js';
|
|
9
|
-
import 'process';
|
|
10
9
|
import 'node:process';
|
|
11
|
-
import 'fs';
|
|
12
|
-
import 'path';
|
|
13
10
|
import 'node:url';
|
|
14
11
|
import './_commonjsHelpers.BFTU3MAI.js';
|
|
15
12
|
import 'readline';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as globalApis } from './constants.fzPh7AOq.js';
|
|
2
|
-
import { V as VitestIndex } from './index.
|
|
3
|
-
import './vi.
|
|
2
|
+
import { V as VitestIndex } from './index.BqHViJW9.js';
|
|
3
|
+
import './vi.CZKezqeD.js';
|
|
4
4
|
import '@vitest/expect';
|
|
5
5
|
import '@vitest/runner';
|
|
6
6
|
import '@vitest/runner/utils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as createExpect, a as globalExpect, i as inject, v as vi, b as vitest } from './vi.
|
|
1
|
+
import { c as createExpect, a as globalExpect, i as inject, v as vi, b as vitest } from './vi.CZKezqeD.js';
|
|
2
2
|
import { i as isFirstRun, a as runOnce } from './run-once.2ogXb3JV.js';
|
|
3
3
|
import { b as bench } from './benchmark.Cdu9hjj4.js';
|
|
4
4
|
import { expectTypeOf } from 'expect-type';
|
|
@@ -3,7 +3,7 @@ import { resolve } from 'node:path';
|
|
|
3
3
|
import { t as takeCoverageInsideWorker } from './coverage.BoMDb1ip.js';
|
|
4
4
|
import { distDir } from '../path.js';
|
|
5
5
|
import { r as rpc } from './rpc.C3q9uwRX.js';
|
|
6
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.
|
|
6
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.B5ClyS48.js';
|
|
7
7
|
import { g as getWorkerState } from './utils.C8RiOc4B.js';
|
|
8
8
|
|
|
9
9
|
function setupChaiConfig(config) {
|