vitest 4.0.0-beta.11 → 4.0.0-beta.12
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 +4 -101
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +2 -2
- package/dist/chunks/{benchmark.LXhJ0F0X.js → benchmark.DHKMYAts.js} +1 -1
- package/dist/chunks/{browser.d.Dx7DO_Ce.d.ts → browser.d.D9YV3JvA.d.ts} +1 -1
- package/dist/chunks/{cac.elvK37c9.js → cac.r1gel_VZ.js} +16 -9
- package/dist/chunks/{cli-api.C7plPyhs.js → cli-api.CpywZzJV.js} +95 -148
- package/dist/chunks/{config.d.B_LthbQq.d.ts → config.d.DGazh2r6.d.ts} +3 -1
- package/dist/chunks/{console.CiTi59Jy.js → console.CTJL2nuH.js} +3 -5
- package/dist/chunks/{coverage.CG6Uhorw.js → coverage.CiB0fs_7.js} +44 -62
- package/dist/chunks/{creator.08Gi-vCA.js → creator.DfXDsUyL.js} +6 -8
- package/dist/chunks/{global.d.BK3X7FW1.d.ts → global.d.BcFPD2LN.d.ts} +0 -13
- package/dist/chunks/{globals.BjvYA-AD.js → globals.DC4ntO86.js} +5 -5
- package/dist/chunks/{index.DIWhzsUh.js → index.Bt-upxGS.js} +6 -12
- package/dist/chunks/{index.BwBttQPf.js → index.CHrBLuEH.js} +33 -38
- package/dist/chunks/{index.X0nbfr6-.js → index.Dc3xnDvT.js} +48 -289
- package/dist/chunks/{index.AZOjjqWP.js → index.Dnl38iQ_.js} +2 -2
- package/dist/chunks/{index.BhY64fF0.js → index.uLUz1RDt.js} +1 -1
- package/dist/chunks/{inspector.CvQD-Nie.js → inspector.Br76Q2Mb.js} +1 -4
- package/dist/chunks/{moduleRunner.d.BNa-CL9e.d.ts → moduleRunner.d.CeYc7nZ0.d.ts} +1 -1
- package/dist/chunks/{node.BsdMi6DV.js → node.BwAWWjHZ.js} +2 -3
- package/dist/chunks/{plugin.d.C5phQR6o.d.ts → plugin.d.XreRXLXS.d.ts} +1 -1
- package/dist/chunks/{reporters.d.CVzhsTvK.d.ts → reporters.d.CJVTaaWb.d.ts} +39 -3
- package/dist/chunks/{resolveSnapshotEnvironment.DQVamkje.js → resolveSnapshotEnvironment.BsJpmVZR.js} +7 -8
- package/dist/chunks/{rpc.jKGRSXIH.js → rpc.cD77ENhU.js} +12 -13
- package/dist/chunks/{setup-common.NAWRuMRP.js → setup-common.BewgbkTd.js} +5 -5
- package/dist/chunks/{startModuleRunner.oAuCu1yL.js → startModuleRunner.DPBo3mme.js} +40 -48
- package/dist/chunks/{test.KC5tH8hC.js → test.CTuWuHYH.js} +5 -5
- package/dist/chunks/{typechecker.gXq-5P3n.js → typechecker.BfOQ86_a.js} +54 -77
- package/dist/chunks/{utils.DGKhod2J.js → utils.CG9h5ccR.js} +1 -4
- package/dist/chunks/{vi.CiJ0Laa6.js → vi.B2--mG9U.js} +35 -144
- package/dist/chunks/{worker.rPGLlbkW.js → worker.DVTUM2IW.js} +11 -15
- package/dist/chunks/{worker.d.B_Fd9M_w.d.ts → worker.d.buwuBpBt.d.ts} +1 -1
- package/dist/cli.js +3 -3
- package/dist/config.d.ts +6 -6
- package/dist/coverage.d.ts +5 -5
- package/dist/coverage.js +3 -3
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +5 -5
- package/dist/module-evaluator.d.ts +3 -3
- package/dist/module-evaluator.js +10 -12
- package/dist/module-runner.js +2 -2
- package/dist/node.d.ts +8 -8
- package/dist/node.js +10 -10
- package/dist/reporters.d.ts +5 -5
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +6 -6
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker-base.js +30 -32
- package/dist/worker-vm.js +19 -30
- package/dist/workers/runVmTests.js +10 -10
- package/package.json +18 -19
|
@@ -3,16 +3,16 @@ import { relative, resolve, dirname, extname, normalize, join, basename, isAbsol
|
|
|
3
3
|
import { C as CoverageProviderMap } from './coverage.D_JHT54q.js';
|
|
4
4
|
import path, { resolve as resolve$1 } from 'node:path';
|
|
5
5
|
import { noop, createDefer, slash, toArray, cleanUrl, deepMerge, nanoid, deepClone, isPrimitive, notNullish } from '@vitest/utils/helpers';
|
|
6
|
-
import {
|
|
6
|
+
import { a as any, p as prompt } from './index.Dc3xnDvT.js';
|
|
7
7
|
import * as vite from 'vite';
|
|
8
8
|
import { parseAst, searchForWorkspaceRoot, version, mergeConfig, createServer } from 'vite';
|
|
9
9
|
import { A as API_PATH, c as configFiles, d as defaultBrowserPort, a as defaultPort } from './constants.D_Q9UYh-.js';
|
|
10
10
|
import nodeos__default, { tmpdir } from 'node:os';
|
|
11
11
|
import { generateHash as generateHash$1, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, generateFileHash, limitConcurrency, createFileTask as createFileTask$1, hasFailed, getTasks, isTestCase } from '@vitest/runner/utils';
|
|
12
12
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
13
|
-
import { v as version$1 } from './cac.
|
|
13
|
+
import { v as version$1 } from './cac.r1gel_VZ.js';
|
|
14
14
|
import { c as createBirpc } from './index.Bgo3tNWt.js';
|
|
15
|
-
import { p as parse, d as stringify, e as printError, f as formatProjectName, w as withLabel, h as errorBanner, i as divider, j as generateCodeFrame, R as ReportersMap, B as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.
|
|
15
|
+
import { p as parse, d as stringify, e as printError, f as formatProjectName, w as withLabel, h as errorBanner, i as divider, j as generateCodeFrame, R as ReportersMap, B as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.CHrBLuEH.js';
|
|
16
16
|
import require$$0$3 from 'events';
|
|
17
17
|
import require$$1$1 from 'https';
|
|
18
18
|
import require$$2 from 'http';
|
|
@@ -26,8 +26,8 @@ import require$$0$1 from 'buffer';
|
|
|
26
26
|
import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
|
|
27
27
|
import crypto, { createHash } from 'node:crypto';
|
|
28
28
|
import { distDir, rootDir } from '../path.js';
|
|
29
|
-
import { h as hash, d as createFetchModuleFunction, n as normalizeResolvedIdToUrl, R as RandomSequencer, i as isPackageExists, g as getFilePoolName, e as isBrowserEnabled, r as resolveConfig, f as groupBy, j as getCoverageProvider, k as createPool, w as wildcardPatternToRegExp, a as resolveApiServerConfig, s as stdout } from './coverage.
|
|
30
|
-
import { b as TraceMap, o as originalPositionFor, c as ancestor, d as createDefinesScript, e as convertTasksToEvents } from './typechecker.
|
|
29
|
+
import { h as hash, d as createFetchModuleFunction, n as normalizeResolvedIdToUrl, R as RandomSequencer, i as isPackageExists, g as getFilePoolName, e as isBrowserEnabled, r as resolveConfig, f as groupBy, j as getCoverageProvider, k as createPool, w as wildcardPatternToRegExp, a as resolveApiServerConfig, s as stdout } from './coverage.CiB0fs_7.js';
|
|
30
|
+
import { b as TraceMap, o as originalPositionFor, c as ancestor, d as createDefinesScript, e as convertTasksToEvents } from './typechecker.BfOQ86_a.js';
|
|
31
31
|
import createDebug from 'debug';
|
|
32
32
|
import { VitestModuleEvaluator } from '#module-evaluator';
|
|
33
33
|
import { ModuleRunner } from 'vite/module-runner';
|
|
@@ -46,7 +46,7 @@ import { c as configDefaults } from './defaults.CXFFjsi8.js';
|
|
|
46
46
|
import { KNOWN_ASSET_RE } from '@vitest/utils/constants';
|
|
47
47
|
import { findNearestPackageData } from '@vitest/utils/resolver';
|
|
48
48
|
import * as esModuleLexer from 'es-module-lexer';
|
|
49
|
-
import { a as BenchmarkReportsMap } from './index.
|
|
49
|
+
import { a as BenchmarkReportsMap } from './index.uLUz1RDt.js';
|
|
50
50
|
import assert$1 from 'node:assert';
|
|
51
51
|
import { serializeValue } from '@vitest/utils/serialize';
|
|
52
52
|
import { parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
@@ -5083,8 +5083,8 @@ catch {}
|
|
|
5083
5083
|
}
|
|
5084
5084
|
|
|
5085
5085
|
function setup(ctx, _server) {
|
|
5086
|
-
const wss = new WebSocketServer({ noServer: true }), clients = /* @__PURE__ */ new Map()
|
|
5087
|
-
|
|
5086
|
+
const wss = new WebSocketServer({ noServer: true }), clients = /* @__PURE__ */ new Map();
|
|
5087
|
+
(_server || ctx.vite).httpServer?.on("upgrade", (request, socket, head) => {
|
|
5088
5088
|
if (!request.url) return;
|
|
5089
5089
|
const { pathname } = new URL(request.url, "http://localhost");
|
|
5090
5090
|
if (pathname === API_PATH) {
|
|
@@ -5150,8 +5150,7 @@ function setup(ctx, _server) {
|
|
|
5150
5150
|
return ctx.state.getUnhandledErrors();
|
|
5151
5151
|
},
|
|
5152
5152
|
async getTestFiles() {
|
|
5153
|
-
|
|
5154
|
-
return spec.map((spec) => [
|
|
5153
|
+
return (await ctx.globTestSpecifications()).map((spec) => [
|
|
5155
5154
|
{
|
|
5156
5155
|
name: spec.project.config.name,
|
|
5157
5156
|
root: spec.project.config.root
|
|
@@ -5340,17 +5339,13 @@ function createFailedFileTask(project, filepath, error) {
|
|
|
5340
5339
|
return file.file = file, file;
|
|
5341
5340
|
}
|
|
5342
5341
|
function serializeError(ctx, error) {
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
});
|
|
5351
|
-
return errors;
|
|
5352
|
-
}
|
|
5353
|
-
return [{
|
|
5342
|
+
return "errors" in error && "pluginCode" in error ? error.errors.map((e) => {
|
|
5343
|
+
return {
|
|
5344
|
+
name: error.name,
|
|
5345
|
+
message: e.text,
|
|
5346
|
+
stack: e.location ? `${error.name}: ${e.text}\n at ${relative(ctx.config.root, e.location.file)}:${e.location.line}:${e.location.column}` : ""
|
|
5347
|
+
};
|
|
5348
|
+
}) : [{
|
|
5354
5349
|
name: error.name,
|
|
5355
5350
|
stack: error.stack,
|
|
5356
5351
|
message: error.message
|
|
@@ -5622,8 +5617,7 @@ class ServerModuleRunner extends ModuleRunner {
|
|
|
5622
5617
|
if (event.type !== "custom") throw new Error(`Vitest Module Runner doesn't support Vite HMR events.`);
|
|
5623
5618
|
const { data } = event.data;
|
|
5624
5619
|
try {
|
|
5625
|
-
|
|
5626
|
-
return { result };
|
|
5620
|
+
return { result: await fetchModule(data[0], data[1], environment, data[2]) };
|
|
5627
5621
|
} catch (error) {
|
|
5628
5622
|
return { error };
|
|
5629
5623
|
}
|
|
@@ -5762,8 +5756,8 @@ class Logger {
|
|
|
5762
5756
|
const projectsFilter = toArray(config.project);
|
|
5763
5757
|
if (projectsFilter.length) this.console.error(c.dim("projects: ") + c.yellow(projectsFilter.join(comma)));
|
|
5764
5758
|
this.ctx.projects.forEach((project) => {
|
|
5765
|
-
const config = project.config
|
|
5766
|
-
if (
|
|
5759
|
+
const config = project.config;
|
|
5760
|
+
if (!project.isRootProject() && project.name) this.console.error(`\n${formatProjectName(project)}\n`);
|
|
5767
5761
|
if (config.include) this.console.error(c.dim("include: ") + c.yellow(config.include.join(comma)));
|
|
5768
5762
|
if (config.exclude) this.console.error(c.dim("exclude: ") + c.yellow(config.exclude.join(comma)));
|
|
5769
5763
|
if (config.typecheck.enabled) this.console.error(c.dim("typecheck include: ") + c.yellow(config.typecheck.include.join(comma))), this.console.error(c.dim("typecheck exclude: ") + c.yellow(config.typecheck.exclude.join(comma)));
|
|
@@ -5854,7 +5848,7 @@ class VitestPackageInstaller {
|
|
|
5854
5848
|
}
|
|
5855
5849
|
if (/* @__PURE__ */ isPackageExists(dependency, { paths: [root, __dirname] })) return true;
|
|
5856
5850
|
if (process.stderr.write(c.red(`${c.inverse(c.red(" MISSING DEPENDENCY "))} Cannot find dependency '${dependency}'\n\n`)), !isTTY) return false;
|
|
5857
|
-
const
|
|
5851
|
+
const { install } = await (await import('./index.Dc3xnDvT.js').then(function (n) { return n.i; })).default({
|
|
5858
5852
|
type: "confirm",
|
|
5859
5853
|
name: "install",
|
|
5860
5854
|
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
@@ -5966,7 +5960,8 @@ function serializeConfig(project) {
|
|
|
5966
5960
|
screenshotFailures: browser.screenshotFailures,
|
|
5967
5961
|
locators: { testIdAttribute: browser.locators.testIdAttribute },
|
|
5968
5962
|
providerOptions: provider?.name === "playwright" ? { actionTimeout: provider?.options?.actionTimeout } : {},
|
|
5969
|
-
trackUnhandledErrors: browser.trackUnhandledErrors ?? true
|
|
5963
|
+
trackUnhandledErrors: browser.trackUnhandledErrors ?? true,
|
|
5964
|
+
trace: browser.trace.mode
|
|
5970
5965
|
};
|
|
5971
5966
|
})(config.browser),
|
|
5972
5967
|
standalone: config.standalone,
|
|
@@ -6502,7 +6497,7 @@ function MetaEnvReplacerPlugin() {
|
|
|
6502
6497
|
transform(code, id) {
|
|
6503
6498
|
if (!/\bimport\.meta\.env\b/.test(code)) return null;
|
|
6504
6499
|
let s = null;
|
|
6505
|
-
const
|
|
6500
|
+
const envs = stripLiteral(code).matchAll(/\bimport\.meta\.env\b/g);
|
|
6506
6501
|
for (const env of envs) {
|
|
6507
6502
|
s ||= new MagicString(code);
|
|
6508
6503
|
const startIndex = env.index, endIndex = startIndex + env[0].length;
|
|
@@ -6634,9 +6629,7 @@ function isInline(id) {
|
|
|
6634
6629
|
return cssInlineRE.test(id);
|
|
6635
6630
|
}
|
|
6636
6631
|
function getCSSModuleProxyReturn(strategy, filename) {
|
|
6637
|
-
|
|
6638
|
-
const hash = generateCssFilenameHash(filename);
|
|
6639
|
-
return `\`_\${style}_${hash}\``;
|
|
6632
|
+
return strategy === "non-scoped" ? "style" : `\`_\${style}_${generateCssFilenameHash(filename)}\``;
|
|
6640
6633
|
}
|
|
6641
6634
|
function CSSEnablerPlugin(ctx) {
|
|
6642
6635
|
const shouldProcessCSS = (id) => {
|
|
@@ -6658,12 +6651,12 @@ function CSSEnablerPlugin(ctx) {
|
|
|
6658
6651
|
// return proxy for css modules, so that imported module has names:
|
|
6659
6652
|
// styles.foo returns a "foo" instead of "undefined"
|
|
6660
6653
|
// we don't use code content to generate hash for "scoped", because it's empty
|
|
6661
|
-
const scopeStrategy = typeof ctx.config.css !== "boolean" && ctx.config.css.modules?.classNameStrategy || "stable"
|
|
6654
|
+
const scopeStrategy = typeof ctx.config.css !== "boolean" && ctx.config.css.modules?.classNameStrategy || "stable";
|
|
6655
|
+
return { code: `export default new Proxy(Object.create(null), {
|
|
6662
6656
|
get(_, style) {
|
|
6663
|
-
return ${
|
|
6657
|
+
return ${getCSSModuleProxyReturn(scopeStrategy, relative(ctx.config.root, id))};
|
|
6664
6658
|
},
|
|
6665
|
-
})
|
|
6666
|
-
return { code };
|
|
6659
|
+
})` };
|
|
6667
6660
|
}
|
|
6668
6661
|
return { code: "export default \"\"" };
|
|
6669
6662
|
}
|
|
@@ -6778,12 +6771,7 @@ function getDefaultResolveOptions() {
|
|
|
6778
6771
|
};
|
|
6779
6772
|
}
|
|
6780
6773
|
function getDefaultServerConditions() {
|
|
6781
|
-
|
|
6782
|
-
if (viteMajor >= 6) {
|
|
6783
|
-
const conditions = vite.defaultServerConditions;
|
|
6784
|
-
return conditions.filter((c) => c !== "module");
|
|
6785
|
-
}
|
|
6786
|
-
return ["node"];
|
|
6774
|
+
return Number(version.split(".")[0]) >= 6 ? vite.defaultServerConditions.filter((c) => c !== "module") : ["node"];
|
|
6787
6775
|
}
|
|
6788
6776
|
|
|
6789
6777
|
function ModuleRunnerTransform() {
|
|
@@ -6841,15 +6829,10 @@ function VitestProjectResolver(ctx) {
|
|
|
6841
6829
|
name: "vitest:resolve-root",
|
|
6842
6830
|
enforce: "pre",
|
|
6843
6831
|
async resolveId(id, _, { ssr }) {
|
|
6844
|
-
if (id === "vitest" || id.startsWith("@vitest/") || id.startsWith("vitest/")) {
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
skip: new Set([plugin]),
|
|
6849
|
-
ssr
|
|
6850
|
-
});
|
|
6851
|
-
return resolved;
|
|
6852
|
-
}
|
|
6832
|
+
if (id === "vitest" || id.startsWith("@vitest/") || id.startsWith("vitest/")) return await ctx.vite.pluginContainer.resolveId(id, void 0, {
|
|
6833
|
+
skip: new Set([plugin]),
|
|
6834
|
+
ssr
|
|
6835
|
+
});
|
|
6853
6836
|
}
|
|
6854
6837
|
};
|
|
6855
6838
|
return plugin;
|
|
@@ -6884,22 +6867,19 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
6884
6867
|
if (existsSync(pkgJsonPath)) name = JSON.parse(readFileSync(pkgJsonPath, "utf-8")).name;
|
|
6885
6868
|
if (typeof name !== "string" || !name) name = basename(dir);
|
|
6886
6869
|
} else name = options.workspacePath.toString();
|
|
6887
|
-
const
|
|
6870
|
+
const isBrowserEnabled = viteConfig.test?.browser?.enabled ?? (viteConfig.test?.browser && project.vitest._cliOptions.browser?.enabled), workspaceNames = [name], browser = viteConfig.test.browser || {};
|
|
6888
6871
|
if (isBrowserEnabled && browser.name && !browser.instances?.length)
|
|
6889
6872
|
// vitest injects `instances` in this case later on
|
|
6890
6873
|
workspaceNames.push(name ? `${name} (${browser.name})` : browser.name);
|
|
6891
|
-
viteConfig.test?.browser?.instances?.forEach((instance) => {
|
|
6892
|
-
if (instance.name ??= name ? `${name} (${instance.browser})` : instance.browser, isBrowserEnabled) workspaceNames.push(instance.name);
|
|
6893
|
-
});
|
|
6894
|
-
const filters = project.vitest.config.project;
|
|
6895
6874
|
// if there is `--project=...` filter, check if any of the potential projects match
|
|
6896
6875
|
// if projects don't match, we ignore the test project altogether
|
|
6897
6876
|
// if some of them match, they will later be filtered again by `resolveWorkspace`
|
|
6898
|
-
if (
|
|
6899
|
-
|
|
6877
|
+
if (viteConfig.test?.browser?.instances?.forEach((instance) => {
|
|
6878
|
+
if (instance.name ??= name ? `${name} (${instance.browser})` : instance.browser, isBrowserEnabled) workspaceNames.push(instance.name);
|
|
6879
|
+
}), project.vitest.config.project.length) {
|
|
6880
|
+
if (!workspaceNames.some((name) => {
|
|
6900
6881
|
return project.vitest.matchesProjectFilter(name);
|
|
6901
|
-
});
|
|
6902
|
-
if (!hasProject) throw new VitestFilteredOutProjectError();
|
|
6882
|
+
})) throw new VitestFilteredOutProjectError();
|
|
6903
6883
|
}
|
|
6904
6884
|
return {
|
|
6905
6885
|
environments: { __vitest__: { dev: {} } },
|
|
@@ -7040,9 +7020,7 @@ async function isValidNodeImport(id) {
|
|
|
7040
7020
|
const extension = extname(id);
|
|
7041
7021
|
if (BUILTIN_EXTENSIONS.has(extension)) return true;
|
|
7042
7022
|
if (extension !== ".js") return false;
|
|
7043
|
-
id = id.replace("file:///", "");
|
|
7044
|
-
const package_ = findNearestPackageData(dirname(id));
|
|
7045
|
-
if (package_.type === "module") return true;
|
|
7023
|
+
if (id = id.replace("file:///", ""), findNearestPackageData(dirname(id)).type === "module") return true;
|
|
7046
7024
|
if (/\.(?:\w+-)?esm?(?:-\w+)?\.js$|\/esm?\//.test(id)) return false;
|
|
7047
7025
|
try {
|
|
7048
7026
|
await esModuleLexer.init;
|
|
@@ -7066,8 +7044,8 @@ async function _shouldExternalize(id, options) {
|
|
|
7066
7044
|
// Unless the user explicitly opted to inline them, externalize Vite deps.
|
|
7067
7045
|
// They are too big to inline by default.
|
|
7068
7046
|
if (matchExternalizePattern(id, moduleDirectories, options?.external) || options?.cacheDir && id.includes(options.cacheDir)) return id;
|
|
7069
|
-
const isLibraryModule = moduleDirectories.some((dir) => id.includes(dir))
|
|
7070
|
-
return id =
|
|
7047
|
+
const isLibraryModule = moduleDirectories.some((dir) => id.includes(dir));
|
|
7048
|
+
return id = isLibraryModule && options?.fallbackCJS ? guessCJSversion(id) || id : id, matchExternalizePattern(id, moduleDirectories, defaultInline) ? false : matchExternalizePattern(id, moduleDirectories, depsExternal) || isLibraryModule && await isValidNodeImport(id) ? id : false;
|
|
7071
7049
|
}
|
|
7072
7050
|
function matchExternalizePattern(id, moduleDirectories, patterns) {
|
|
7073
7051
|
if (patterns == null) return false;
|
|
@@ -7109,7 +7087,7 @@ class TestSpecification {
|
|
|
7109
7087
|
*/
|
|
7110
7088
|
get testModule() {
|
|
7111
7089
|
const task = this.project.vitest.state.idMap.get(this.taskId);
|
|
7112
|
-
|
|
7090
|
+
if (task) return this.project.vitest.state.getReportedEntity(task);
|
|
7113
7091
|
}
|
|
7114
7092
|
toJSON() {
|
|
7115
7093
|
return [
|
|
@@ -7338,16 +7316,15 @@ class TestProject {
|
|
|
7338
7316
|
}
|
|
7339
7317
|
/** @internal */
|
|
7340
7318
|
async globFiles(include, exclude, cwd) {
|
|
7341
|
-
|
|
7319
|
+
// keep the slashes consistent with Vite
|
|
7320
|
+
// we are not using the pathe here because it normalizes the drive letter on Windows
|
|
7321
|
+
// and we want to keep it the same as working dir
|
|
7322
|
+
return (await glob(include, {
|
|
7342
7323
|
dot: true,
|
|
7343
7324
|
cwd,
|
|
7344
7325
|
ignore: exclude,
|
|
7345
7326
|
expandDirectories: false
|
|
7346
|
-
}
|
|
7347
|
-
// keep the slashes consistent with Vite
|
|
7348
|
-
// we are not using the pathe here because it normalizes the drive letter on Windows
|
|
7349
|
-
// and we want to keep it the same as working dir
|
|
7350
|
-
return files.map((file) => slash(path.resolve(cwd, file)));
|
|
7327
|
+
})).map((file) => slash(path.resolve(cwd, file)));
|
|
7351
7328
|
}
|
|
7352
7329
|
/**
|
|
7353
7330
|
* Test if a file matches the test globs. This does the actual glob matching if the test is not cached, unlike `isCachedTestFile`.
|
|
@@ -7520,7 +7497,7 @@ function generateHash(str) {
|
|
|
7520
7497
|
// vite.unit.config.*
|
|
7521
7498
|
const CONFIG_REGEXP = /^vite(?:st)?(?:\.\w+)?\.config\./;
|
|
7522
7499
|
async function resolveProjects(vitest, cliOptions, workspaceConfigPath, projectsDefinition, names) {
|
|
7523
|
-
const { configFiles, projectConfigs, nonConfigDirectories } = await resolveTestProjectConfigs(vitest, workspaceConfigPath, projectsDefinition),
|
|
7500
|
+
const { configFiles, projectConfigs, nonConfigDirectories } = await resolveTestProjectConfigs(vitest, workspaceConfigPath, projectsDefinition), cliOverrides = [
|
|
7524
7501
|
"logHeapUsage",
|
|
7525
7502
|
"allowOnly",
|
|
7526
7503
|
"sequence",
|
|
@@ -7539,7 +7516,7 @@ async function resolveProjects(vitest, cliOptions, workspaceConfigPath, projects
|
|
|
7539
7516
|
"inspect",
|
|
7540
7517
|
"inspectBrk",
|
|
7541
7518
|
"fileParallelism"
|
|
7542
|
-
]
|
|
7519
|
+
].reduce((acc, name) => {
|
|
7543
7520
|
if (name in cliOptions) acc[name] = cliOptions[name];
|
|
7544
7521
|
return acc;
|
|
7545
7522
|
}, {}), projectPromises = [], fileProjects = [...configFiles, ...nonConfigDirectories], concurrent = limitConcurrency(nodeos__default.availableParallelism?.() || nodeos__default.cpus().length || 5);
|
|
@@ -7655,7 +7632,7 @@ async function resolveBrowserProjects(vitest, names, resolvedProjects) {
|
|
|
7655
7632
|
if (headedBrowserProjects.length > 1) {
|
|
7656
7633
|
const message = [`Found multiple projects that run browser tests in headed mode: "${headedBrowserProjects.map((p) => p.name).join("\", \"")}".`, ` Vitest cannot run multiple headed browsers at the same time.`].join("");
|
|
7657
7634
|
if (!isTTY) throw new Error(`${message} Please, filter projects with --browser=name or --project=name flag or run tests with "headless: true" option.`);
|
|
7658
|
-
const
|
|
7635
|
+
const { projectName } = await (await import('./index.Dc3xnDvT.js').then(function (n) { return n.i; })).default({
|
|
7659
7636
|
type: "select",
|
|
7660
7637
|
name: "projectName",
|
|
7661
7638
|
choices: headedBrowserProjects.map((project) => ({
|
|
@@ -7739,8 +7716,8 @@ async function resolveTestProjectConfigs(vitest, workspaceConfigPath, projectsDe
|
|
|
7739
7716
|
"**/*.timestamp-*",
|
|
7740
7717
|
"**/.DS_Store"
|
|
7741
7718
|
]
|
|
7742
|
-
}
|
|
7743
|
-
|
|
7719
|
+
};
|
|
7720
|
+
(await glob(projectsGlobMatches, globOptions)).forEach((path) => {
|
|
7744
7721
|
// directories are allowed with a glob like `packages/*`
|
|
7745
7722
|
// in this case every directory is treated as a project
|
|
7746
7723
|
if (path.endsWith("/")) {
|
|
@@ -7767,10 +7744,7 @@ function resolveDirectoryConfig(directory) {
|
|
|
7767
7744
|
}
|
|
7768
7745
|
function getDefaultTestProject(vitest) {
|
|
7769
7746
|
const filter = vitest.config.project, project = vitest._ensureRootProject();
|
|
7770
|
-
|
|
7771
|
-
// check for the project name and browser names
|
|
7772
|
-
const hasProjects = getPotentialProjectNames(project).some((p) => vitest.matchesProjectFilter(p));
|
|
7773
|
-
return hasProjects ? project : null;
|
|
7747
|
+
return !filter.length || getPotentialProjectNames(project).some((p) => vitest.matchesProjectFilter(p)) ? project : null;
|
|
7774
7748
|
}
|
|
7775
7749
|
function getPotentialProjectNames(project) {
|
|
7776
7750
|
const names = [project.name];
|
|
@@ -7793,17 +7767,11 @@ function createReporters(reporterReferences, ctx) {
|
|
|
7793
7767
|
const runner = ctx.runner, promisedReporters = reporterReferences.map(async (referenceOrInstance) => {
|
|
7794
7768
|
if (Array.isArray(referenceOrInstance)) {
|
|
7795
7769
|
const [reporterName, reporterOptions] = referenceOrInstance;
|
|
7796
|
-
if (reporterName === "html")
|
|
7797
|
-
|
|
7798
|
-
const CustomReporter = await loadCustomReporterModule("@vitest/ui/reporter", runner);
|
|
7799
|
-
return new CustomReporter(reporterOptions);
|
|
7800
|
-
} else if (reporterName in ReportersMap) {
|
|
7770
|
+
if (reporterName === "html") return await ctx.packageInstaller.ensureInstalled("@vitest/ui", ctx.config.root, ctx.version), new (await (loadCustomReporterModule("@vitest/ui/reporter", runner)))(reporterOptions);
|
|
7771
|
+
if (reporterName in ReportersMap) {
|
|
7801
7772
|
const BuiltinReporter = ReportersMap[reporterName];
|
|
7802
7773
|
return new BuiltinReporter(reporterOptions);
|
|
7803
|
-
} else
|
|
7804
|
-
const CustomReporter = await loadCustomReporterModule(reporterName, runner);
|
|
7805
|
-
return new CustomReporter(reporterOptions);
|
|
7806
|
-
}
|
|
7774
|
+
} else return new (await (loadCustomReporterModule(reporterName, runner)))(reporterOptions);
|
|
7807
7775
|
}
|
|
7808
7776
|
return referenceOrInstance;
|
|
7809
7777
|
});
|
|
@@ -7814,10 +7782,7 @@ function createBenchmarkReporters(reporterReferences, runner) {
|
|
|
7814
7782
|
if (typeof referenceOrInstance === "string") if (referenceOrInstance in BenchmarkReportsMap) {
|
|
7815
7783
|
const BuiltinReporter = BenchmarkReportsMap[referenceOrInstance];
|
|
7816
7784
|
return new BuiltinReporter();
|
|
7817
|
-
} else
|
|
7818
|
-
const CustomReporter = await loadCustomReporterModule(referenceOrInstance, runner);
|
|
7819
|
-
return new CustomReporter();
|
|
7820
|
-
}
|
|
7785
|
+
} else return new (await (loadCustomReporterModule(referenceOrInstance, runner)))();
|
|
7821
7786
|
return referenceOrInstance;
|
|
7822
7787
|
});
|
|
7823
7788
|
return Promise.all(promisedReporters);
|
|
@@ -7835,11 +7800,11 @@ function parseFilter(filter) {
|
|
|
7835
7800
|
return { filename: filter };
|
|
7836
7801
|
}
|
|
7837
7802
|
function groupFilters(filters) {
|
|
7838
|
-
const groupedFilters_ = groupBy(filters, (f) => f.filename)
|
|
7803
|
+
const groupedFilters_ = groupBy(filters, (f) => f.filename);
|
|
7804
|
+
return Object.fromEntries(Object.entries(groupedFilters_).map((entry) => {
|
|
7839
7805
|
const [filename, filters] = entry, testLocations = filters.map((f) => f.lineNumber);
|
|
7840
7806
|
return [filename, testLocations.filter((l) => l !== void 0)];
|
|
7841
7807
|
}));
|
|
7842
|
-
return groupedFilters;
|
|
7843
7808
|
}
|
|
7844
7809
|
|
|
7845
7810
|
class VitestSpecifications {
|
|
@@ -7900,7 +7865,7 @@ class VitestSpecifications {
|
|
|
7900
7865
|
}
|
|
7901
7866
|
async filterTestsBySource(specs) {
|
|
7902
7867
|
if (this.vitest.config.changed && !this.vitest.config.related) {
|
|
7903
|
-
const { VitestGit } = await import('./git.BFNcloKD.js'),
|
|
7868
|
+
const { VitestGit } = await import('./git.BFNcloKD.js'), related = await new VitestGit(this.vitest.config.root).findChangedFiles({ changedSince: this.vitest.config.changed });
|
|
7904
7869
|
if (!related) throw process.exitCode = 1, new GitNotFoundError();
|
|
7905
7870
|
this.vitest.config.related = Array.from(new Set(related));
|
|
7906
7871
|
}
|
|
@@ -7924,7 +7889,7 @@ class VitestSpecifications {
|
|
|
7924
7889
|
const addImports = async (project, filepath) => {
|
|
7925
7890
|
if (deps.has(filepath)) return;
|
|
7926
7891
|
deps.add(filepath);
|
|
7927
|
-
const
|
|
7892
|
+
const transformed = project.vite.environments.ssr.moduleGraph.getModuleById(filepath)?.transformResult || await project.vite.environments.ssr.transformRequest(filepath);
|
|
7928
7893
|
if (!transformed) return;
|
|
7929
7894
|
const dependencies = [...transformed.deps || [], ...transformed.dynamicDeps || []];
|
|
7930
7895
|
await Promise.all(dependencies.map(async (dep) => {
|
|
@@ -8062,10 +8027,10 @@ class TestCase extends ReportedTaskImplementation {
|
|
|
8062
8027
|
diagnostic() {
|
|
8063
8028
|
const result = this.task.result;
|
|
8064
8029
|
// startTime should always be available if the test has properly finished
|
|
8065
|
-
if (!result || !result.startTime) return
|
|
8066
|
-
const duration = result.duration || 0
|
|
8030
|
+
if (!result || !result.startTime) return;
|
|
8031
|
+
const duration = result.duration || 0;
|
|
8067
8032
|
return {
|
|
8068
|
-
slow,
|
|
8033
|
+
slow: duration > this.project.globalConfig.slowTestThreshold,
|
|
8069
8034
|
heap: result.heap,
|
|
8070
8035
|
duration,
|
|
8071
8036
|
startTime: result.startTime,
|
|
@@ -8216,8 +8181,7 @@ class TestModule extends SuiteImplementation {
|
|
|
8216
8181
|
* Checks the running state of the test file.
|
|
8217
8182
|
*/
|
|
8218
8183
|
state() {
|
|
8219
|
-
|
|
8220
|
-
return state === "queued" ? "queued" : getSuiteState(this.task);
|
|
8184
|
+
return this.task.result?.state === "queued" ? "queued" : getSuiteState(this.task);
|
|
8221
8185
|
}
|
|
8222
8186
|
/**
|
|
8223
8187
|
* Useful information about the module like duration, memory usage, etc.
|
|
@@ -8376,6 +8340,10 @@ class StateManager {
|
|
|
8376
8340
|
getReportedEntity(task) {
|
|
8377
8341
|
return this.reportedTasksMap.get(task);
|
|
8378
8342
|
}
|
|
8343
|
+
getReportedEntityById(taskId) {
|
|
8344
|
+
const task = this.idMap.get(taskId);
|
|
8345
|
+
return task ? this.reportedTasksMap.get(task) : void 0;
|
|
8346
|
+
}
|
|
8379
8347
|
updateTasks(packs) {
|
|
8380
8348
|
for (const [id, result, meta] of packs) {
|
|
8381
8349
|
const task = this.idMap.get(id);
|
|
@@ -8948,9 +8916,8 @@ class TestRun {
|
|
|
8948
8916
|
const path = attachment.path;
|
|
8949
8917
|
if (path && !path.startsWith("http://") && !path.startsWith("https://")) {
|
|
8950
8918
|
const currentPath = resolve(project.config.root, path), hash = createHash("sha1").update(currentPath).digest("hex"), newPath = resolve(project.config.attachmentsDir, `${sanitizeFilePath(annotation.message)}-${hash}${extname(currentPath)}`);
|
|
8951
|
-
await mkdir(
|
|
8952
|
-
|
|
8953
|
-
attachment.contentType = contentType || void 0;
|
|
8919
|
+
if (!existsSync(project.config.attachmentsDir)) await mkdir(project.config.attachmentsDir, { recursive: true });
|
|
8920
|
+
await copyFile(currentPath, newPath), attachment.path = newPath, attachment.contentType = (attachment.contentType ?? mime.getType(basename(currentPath))) || void 0;
|
|
8954
8921
|
}
|
|
8955
8922
|
return attachment;
|
|
8956
8923
|
}
|
|
@@ -9010,21 +8977,14 @@ class VitestWatcher {
|
|
|
9010
8977
|
}), triggered;
|
|
9011
8978
|
}
|
|
9012
8979
|
onFileChange = (id) => {
|
|
9013
|
-
id = slash(id), this.vitest.logger.clearHighlightCache(id), this.vitest.invalidateFile(id);
|
|
9014
|
-
|
|
9015
|
-
if (testFiles) this.scheduleRerun(id);
|
|
9016
|
-
else {
|
|
9017
|
-
const needsRerun = this.handleFileChanged(id);
|
|
9018
|
-
if (needsRerun) this.scheduleRerun(id);
|
|
9019
|
-
}
|
|
8980
|
+
if (id = slash(id), this.vitest.logger.clearHighlightCache(id), this.vitest.invalidateFile(id), this.getTestFilesFromWatcherTrigger(id)) this.scheduleRerun(id);
|
|
8981
|
+
else if (this.handleFileChanged(id)) this.scheduleRerun(id);
|
|
9020
8982
|
};
|
|
9021
8983
|
onFileDelete = (id) => {
|
|
9022
8984
|
if (id = slash(id), this.vitest.logger.clearHighlightCache(id), this.invalidates.add(id), this.vitest.state.filesMap.has(id)) this.vitest.projects.forEach((project) => project._removeCachedTestFile(id)), this.vitest.state.filesMap.delete(id), this.vitest.cache.results.removeFromCache(id), this.vitest.cache.stats.removeStats(id), this.changedTests.delete(id), this.vitest.report("onTestRemoved", id);
|
|
9023
8985
|
};
|
|
9024
8986
|
onFileCreate = (id) => {
|
|
9025
|
-
id = slash(id), this.vitest.invalidateFile(id)
|
|
9026
|
-
const testFiles = this.getTestFilesFromWatcherTrigger(id);
|
|
9027
|
-
if (testFiles) {
|
|
8987
|
+
if (id = slash(id), this.vitest.invalidateFile(id), this.getTestFilesFromWatcherTrigger(id)) {
|
|
9028
8988
|
this.scheduleRerun(id);
|
|
9029
8989
|
return;
|
|
9030
8990
|
}
|
|
@@ -9033,11 +8993,7 @@ class VitestWatcher {
|
|
|
9033
8993
|
if (this.vitest.projects.forEach((project) => {
|
|
9034
8994
|
if (project.matchesTestGlob(id, () => fileContent ??= readFileSync(id, "utf-8"))) matchingProjects.push(project);
|
|
9035
8995
|
}), matchingProjects.length > 0) this.changedTests.add(id), this.scheduleRerun(id);
|
|
9036
|
-
else
|
|
9037
|
-
// it's possible that file was already there but watcher triggered "add" event instead
|
|
9038
|
-
const needsRerun = this.handleFileChanged(id);
|
|
9039
|
-
if (needsRerun) this.scheduleRerun(id);
|
|
9040
|
-
}
|
|
8996
|
+
else if (this.handleFileChanged(id)) this.scheduleRerun(id);
|
|
9041
8997
|
};
|
|
9042
8998
|
handleSetupFile(filepath) {
|
|
9043
8999
|
let isSetupFile = false;
|
|
@@ -9057,8 +9013,7 @@ class VitestWatcher {
|
|
|
9057
9013
|
if (pm.isMatch(filepath, this.vitest.config.forceRerunTriggers)) return this.vitest.state.getFilepaths().forEach((file) => this.changedTests.add(file)), true;
|
|
9058
9014
|
if (this.handleSetupFile(filepath)) return true;
|
|
9059
9015
|
const projects = this.vitest.projects.filter((project) => {
|
|
9060
|
-
|
|
9061
|
-
return moduleGraph.getModulesByFile(filepath)?.size;
|
|
9016
|
+
return (project.browser?.vite.moduleGraph || project.vite.moduleGraph).getModulesByFile(filepath)?.size;
|
|
9062
9017
|
});
|
|
9063
9018
|
if (!projects.length) return this.vitest.state.filesMap.has(filepath) || this.vitest.projects.some((project) => project._isCachedTestFile(filepath)) ? (this.changedTests.add(filepath), true) : false;
|
|
9064
9019
|
const files = [];
|
|
@@ -9072,9 +9027,7 @@ class VitestWatcher {
|
|
|
9072
9027
|
}
|
|
9073
9028
|
let rerun = false;
|
|
9074
9029
|
for (const mod of mods) mod.importers.forEach((i) => {
|
|
9075
|
-
if (
|
|
9076
|
-
const needsRerun = this.handleFileChanged(i.file);
|
|
9077
|
-
if (needsRerun) rerun = true;
|
|
9030
|
+
if (i.file && this.handleFileChanged(i.file)) rerun = true;
|
|
9078
9031
|
});
|
|
9079
9032
|
if (rerun) files.push(filepath);
|
|
9080
9033
|
}
|
|
@@ -9198,9 +9151,7 @@ class Vitest {
|
|
|
9198
9151
|
server.restart = async (...args) => {
|
|
9199
9152
|
await Promise.all(this._onRestartListeners.map((fn) => fn())), this.report("onServerRestart"), await this.close(), await serverRestart(...args);
|
|
9200
9153
|
}, server.watcher.on("change", async (file) => {
|
|
9201
|
-
file = normalize(file);
|
|
9202
|
-
const isConfig = file === server.config.configFile || this.projects.some((p) => p.vite.config.configFile === file);
|
|
9203
|
-
if (isConfig) await Promise.all(this._onRestartListeners.map((fn) => fn("config"))), this.report("onServerRestart", "config"), await this.close(), await serverRestart();
|
|
9154
|
+
if (file = normalize(file), file === server.config.configFile || this.projects.some((p) => p.vite.config.configFile === file)) await Promise.all(this._onRestartListeners.map((fn) => fn("config"))), this.report("onServerRestart", "config"), await this.close(), await serverRestart();
|
|
9204
9155
|
});
|
|
9205
9156
|
}
|
|
9206
9157
|
this.cache.results.setConfig(resolved.root, resolved.cache);
|
|
@@ -9209,15 +9160,13 @@ class Vitest {
|
|
|
9209
9160
|
} catch {}
|
|
9210
9161
|
const projects = await this.resolveProjects(this._cliOptions);
|
|
9211
9162
|
if (this.projects = projects, await Promise.all(projects.flatMap((project) => {
|
|
9212
|
-
|
|
9213
|
-
return hooks.map((hook) => hook({
|
|
9163
|
+
return project.vite.config.getSortedPluginHooks("configureVitest").map((hook) => hook({
|
|
9214
9164
|
project,
|
|
9215
9165
|
vitest: this,
|
|
9216
9166
|
injectTestProjects: this.injectTestProject
|
|
9217
9167
|
}));
|
|
9218
9168
|
})), this._cliOptions.browser?.enabled) {
|
|
9219
|
-
|
|
9220
|
-
if (!browserProjects.length) throw new Error(`Vitest received --browser flag, but no project had a browser configuration.`);
|
|
9169
|
+
if (!this.projects.filter((p) => p.config.browser.enabled).length) throw new Error(`Vitest received --browser flag, but no project had a browser configuration.`);
|
|
9221
9170
|
}
|
|
9222
9171
|
if (!this.projects.length) {
|
|
9223
9172
|
const filter = toArray(resolved.project).join("\", \"");
|
|
@@ -9336,7 +9285,7 @@ class Vitest {
|
|
|
9336
9285
|
}, await this.report("onInit", this);
|
|
9337
9286
|
const specifications = [];
|
|
9338
9287
|
for (const file of files) {
|
|
9339
|
-
const
|
|
9288
|
+
const specification = this.getProjectByName(file.projectName || "").createSpecification(file.filepath, void 0, file.pool);
|
|
9340
9289
|
specifications.push(specification);
|
|
9341
9290
|
}
|
|
9342
9291
|
await this._testRun.start(specifications).catch(noop);
|
|
@@ -9346,6 +9295,12 @@ class Vitest {
|
|
|
9346
9295
|
unhandledErrors: this.state.getUnhandledErrors()
|
|
9347
9296
|
};
|
|
9348
9297
|
}
|
|
9298
|
+
/**
|
|
9299
|
+
* Returns the seed, if tests are running in a random order.
|
|
9300
|
+
*/
|
|
9301
|
+
getSeed() {
|
|
9302
|
+
return this.config.sequence.seed ?? null;
|
|
9303
|
+
}
|
|
9349
9304
|
/** @internal */
|
|
9350
9305
|
async _reportFileTask(file) {
|
|
9351
9306
|
const project = this.getProjectByName(file.projectName || "");
|
|
@@ -9669,10 +9624,8 @@ class Vitest {
|
|
|
9669
9624
|
*/
|
|
9670
9625
|
invalidateFile(filepath) {
|
|
9671
9626
|
this.projects.forEach(({ vite, browser }) => {
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
const modules = moduleGraph.getModulesByFile(filepath);
|
|
9675
|
-
modules?.forEach((module) => moduleGraph.invalidateModule(module));
|
|
9627
|
+
[...Object.values(vite.environments), ...Object.values(browser?.vite.environments || {})].forEach(({ moduleGraph }) => {
|
|
9628
|
+
moduleGraph.getModulesByFile(filepath)?.forEach((module) => moduleGraph.invalidateModule(module));
|
|
9676
9629
|
});
|
|
9677
9630
|
});
|
|
9678
9631
|
}
|
|
@@ -9795,8 +9748,7 @@ class Vitest {
|
|
|
9795
9748
|
matchesProjectFilter(name) {
|
|
9796
9749
|
const projects = this._config?.project || this._cliOptions?.project;
|
|
9797
9750
|
return !projects || !projects.length ? true : toArray(projects).some((project) => {
|
|
9798
|
-
|
|
9799
|
-
return regexp.test(name);
|
|
9751
|
+
return wildcardPatternToRegExp(project).test(name);
|
|
9800
9752
|
});
|
|
9801
9753
|
}
|
|
9802
9754
|
}
|
|
@@ -9825,11 +9777,7 @@ async function VitestPlugin(options = {}, vitest = new Vitest("test", deepClone(
|
|
|
9825
9777
|
// however to allow vitest plugins to modify vitest config values
|
|
9826
9778
|
// this is repeated in configResolved where the config is final
|
|
9827
9779
|
const testConfig = deepMerge({}, configDefaults, removeUndefinedValues(viteConfig.test ?? {}), options);
|
|
9828
|
-
testConfig.api = resolveApiServerConfig(testConfig, defaultPort);
|
|
9829
|
-
// store defines for globalThis to make them
|
|
9830
|
-
// reassignable when running in worker in src/runtime/setup.ts
|
|
9831
|
-
const defines = deleteDefineConfig(viteConfig);
|
|
9832
|
-
options.defines = defines;
|
|
9780
|
+
testConfig.api = resolveApiServerConfig(testConfig, defaultPort), options.defines = deleteDefineConfig(viteConfig);
|
|
9833
9781
|
let open = false;
|
|
9834
9782
|
if (testConfig.ui && testConfig.open) open = testConfig.uiBase ?? "/__vitest__/";
|
|
9835
9783
|
const resolveOptions = getDefaultResolveOptions();
|
|
@@ -9944,7 +9892,7 @@ function removeUndefinedValues(obj) {
|
|
|
9944
9892
|
}
|
|
9945
9893
|
|
|
9946
9894
|
async function createVitest(mode, options, viteOverrides = {}, vitestOptions = {}) {
|
|
9947
|
-
const ctx = new Vitest(mode, deepClone(options), vitestOptions), root = slash(resolve$1(options.root || process.cwd())), configPath = options.config === false ? false : options.config ? resolve$1(root, options.config) :
|
|
9895
|
+
const ctx = new Vitest(mode, deepClone(options), vitestOptions), root = slash(resolve$1(options.root || process.cwd())), configPath = options.config === false ? false : options.config ? resolve$1(root, options.config) : any(configFiles, { cwd: root });
|
|
9948
9896
|
options.config = configPath;
|
|
9949
9897
|
const { browser: _removeBrowser,...restOptions } = options, config = {
|
|
9950
9898
|
configFile: configPath,
|
|
@@ -10157,7 +10105,7 @@ function registerConsoleShortcuts(ctx, stdin = process.stdin, stdout) {
|
|
|
10157
10105
|
}
|
|
10158
10106
|
async function inputNamePattern() {
|
|
10159
10107
|
off();
|
|
10160
|
-
const
|
|
10108
|
+
const filter = await new WatchFilter("Input test name pattern (RegExp)", stdin, stdout).filter((str) => {
|
|
10161
10109
|
return [...getFilteredTestNames(str, ctx.state.getFiles())];
|
|
10162
10110
|
});
|
|
10163
10111
|
if (on(), typeof filter === "undefined") return;
|
|
@@ -10177,8 +10125,7 @@ function registerConsoleShortcuts(ctx, stdin = process.stdin, stdout) {
|
|
|
10177
10125
|
async function inputFilePattern() {
|
|
10178
10126
|
off();
|
|
10179
10127
|
const watchFilter = new WatchFilter("Input filename pattern", stdin, stdout), filter = await watchFilter.filter(async (str) => {
|
|
10180
|
-
|
|
10181
|
-
return specifications.map((specification) => relative(ctx.config.root, specification.moduleId)).filter((file, index, all) => all.indexOf(file) === index);
|
|
10128
|
+
return (await ctx.globTestSpecifications([str])).map((specification) => relative(ctx.config.root, specification.moduleId)).filter((file, index, all) => all.indexOf(file) === index);
|
|
10182
10129
|
});
|
|
10183
10130
|
if (on(), typeof filter === "undefined") return;
|
|
10184
10131
|
latestFilename = filter?.trim() || "";
|
|
@@ -185,6 +185,7 @@ interface SerializedConfig {
|
|
|
185
185
|
providerOptions: {
|
|
186
186
|
actionTimeout?: number;
|
|
187
187
|
};
|
|
188
|
+
trace: BrowserTraceViewMode;
|
|
188
189
|
trackUnhandledErrors: boolean;
|
|
189
190
|
};
|
|
190
191
|
standalone: boolean;
|
|
@@ -210,5 +211,6 @@ type RuntimeConfig = Pick<SerializedConfig, "allowOnly" | "testTimeout" | "hookT
|
|
|
210
211
|
};
|
|
211
212
|
};
|
|
212
213
|
type RuntimeOptions = Partial<RuntimeConfig>;
|
|
214
|
+
type BrowserTraceViewMode = "on" | "off" | "on-first-retry" | "on-all-retries" | "retain-on-failure";
|
|
213
215
|
|
|
214
|
-
export type { FakeTimerInstallOpts as F, RuntimeOptions as R, SerializedCoverageConfig as S, SerializedConfig as a, RuntimeConfig as b };
|
|
216
|
+
export type { BrowserTraceViewMode as B, FakeTimerInstallOpts as F, RuntimeOptions as R, SerializedCoverageConfig as S, SerializedConfig as a, RuntimeConfig as b };
|
|
@@ -4,7 +4,7 @@ import { Writable } from 'node:stream';
|
|
|
4
4
|
import { getSafeTimers } from '@vitest/utils/timers';
|
|
5
5
|
import c from 'tinyrainbow';
|
|
6
6
|
import { R as RealDate } from './date.-jtEtIeV.js';
|
|
7
|
-
import { g as getWorkerState } from './utils.
|
|
7
|
+
import { g as getWorkerState } from './utils.CG9h5ccR.js';
|
|
8
8
|
|
|
9
9
|
const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
|
|
10
10
|
function getTaskIdByStack(root) {
|
|
@@ -78,7 +78,7 @@ function createCustomConsole(defaultState) {
|
|
|
78
78
|
if (state().config.printConsoleTrace) {
|
|
79
79
|
const limit = Error.stackTraceLimit;
|
|
80
80
|
Error.stackTraceLimit = limit + 6;
|
|
81
|
-
const
|
|
81
|
+
const trace = (/* @__PURE__ */ new Error("STACK_TRACE")).stack?.split("\n").slice(7).join("\n");
|
|
82
82
|
Error.stackTraceLimit = limit, buffer.push([data, trace]);
|
|
83
83
|
} else buffer.push([data, void 0]);
|
|
84
84
|
schedule(id), callback();
|
|
@@ -96,9 +96,7 @@ function createCustomConsole(defaultState) {
|
|
|
96
96
|
const limit = Error.stackTraceLimit;
|
|
97
97
|
Error.stackTraceLimit = limit + 6;
|
|
98
98
|
const stack = (/* @__PURE__ */ new Error("STACK_TRACE")).stack?.split("\n");
|
|
99
|
-
Error.stackTraceLimit = limit;
|
|
100
|
-
const isTrace = stack?.some((line) => line.includes("at Console.trace"));
|
|
101
|
-
if (isTrace) buffer.push([data, void 0]);
|
|
99
|
+
if (Error.stackTraceLimit = limit, stack?.some((line) => line.includes("at Console.trace"))) buffer.push([data, void 0]);
|
|
102
100
|
else {
|
|
103
101
|
const trace = stack?.slice(7).join("\n");
|
|
104
102
|
Error.stackTraceLimit = limit, buffer.push([data, trace]);
|