vitest 4.1.2 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/chunks/{base.BPik1OqN.js → base.Cv_yNPUJ.js} +4 -4
- package/dist/chunks/{browser.d.BMOr_Kmk.d.ts → browser.d.C0zGu1u9.d.ts} +1 -1
- package/dist/chunks/{cac.DRKYQDPl.js → cac.wyYWMVI-.js} +19 -7
- package/dist/chunks/{cli-api.Bxr1Nn49.js → cli-api.lDy4N9kC.js} +45 -18
- package/dist/chunks/{config.d.Cz9kPrQs.d.ts → config.d.ChUh6-ad.d.ts} +1 -0
- package/dist/chunks/{coverage.kqM80boz.js → coverage.Da5gzbsu.js} +16 -2
- package/dist/chunks/{global.d.x-ILCfAE.d.ts → global.d.D74z04P1.d.ts} +2 -0
- package/dist/chunks/{globals.CVqIbOyt.js → globals.BVDtJR67.js} +3 -3
- package/dist/chunks/{index.0GYC6HAu.js → index.BMXTnDNz.js} +11 -2
- package/dist/chunks/{index.DOa3dzoN.js → index.C-zNJvRx.js} +2 -1
- package/dist/chunks/{index.nZ2xqFgD.js → index.C3MK_gXn.js} +2 -2
- package/dist/chunks/{plugin.d.BWbK_Jpw.d.ts → plugin.d.CEihBODF.d.ts} +1 -1
- package/dist/chunks/{reporters.d.B0uk8id2.d.ts → reporters.d.BwkR0iL5.d.ts} +16 -3
- package/dist/chunks/{setup-common.2wZXQUjS.js → setup-common.BDwxwUWG.js} +1 -1
- package/dist/chunks/{test.p_J6dB8a.js → test.D1JkM1w4.js} +488 -335
- package/dist/chunks/{utils.DK8FXp4T.js → utils.BS4fH3nR.js} +1 -1
- package/dist/chunks/{vm.BvVhnZPV.js → vm.DVLYObm9.js} +5 -4
- package/dist/chunks/{worker.d.BT5j8dyR.d.ts → worker.d.CckNUvI5.d.ts} +1 -1
- package/dist/cli.js +1 -1
- package/dist/config.d.ts +6 -6
- package/dist/coverage.d.ts +4 -4
- package/dist/coverage.js +2 -1
- package/dist/index.d.ts +99 -10
- package/dist/index.js +3 -3
- package/dist/node.d.ts +8 -8
- package/dist/node.js +7 -7
- package/dist/reporters.d.ts +4 -4
- package/dist/reporters.js +2 -2
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +2 -2
- package/dist/worker.d.ts +2 -2
- package/dist/worker.js +5 -5
- package/dist/workers/forks.js +5 -5
- package/dist/workers/runVmTests.js +4 -4
- package/dist/workers/threads.js +5 -5
- package/dist/workers/vmForks.js +1 -1
- package/dist/workers/vmThreads.js +1 -1
- package/package.json +20 -12
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/config.d.
|
|
1
|
+
import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/config.d.ChUh6-ad.js';
|
|
2
2
|
import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.BZtK59WP.js';
|
|
3
3
|
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
4
4
|
export { O as OTELCarrier, T as Traces } from './chunks/traces.d.402V_yFI.js';
|
package/dist/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.
|
|
1
|
+
export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.BDwxwUWG.js';
|
|
2
2
|
export { T as Traces } from './chunks/traces.DT5aQ62U.js';
|
|
3
3
|
export { collectTests, startTests } from '@vitest/runner';
|
|
4
4
|
import * as spyModule from '@vitest/spy';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { runInThisContext } from 'node:vm';
|
|
2
2
|
import * as spyModule from '@vitest/spy';
|
|
3
|
-
import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.
|
|
3
|
+
import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.C3MK_gXn.js';
|
|
4
4
|
import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.D98-gwRW.js';
|
|
5
5
|
import { N as NativeModuleRunner } from './nativeModuleRunner.BIakptoF.js';
|
|
6
6
|
import { T as Traces } from './traces.DT5aQ62U.js';
|
|
@@ -8,15 +8,15 @@ import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
|
|
|
8
8
|
import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startVitestModuleRunner.bRl2_oI_.js';
|
|
9
9
|
import { performance as performance$1 } from 'node:perf_hooks';
|
|
10
10
|
import { startTests, collectTests } from '@vitest/runner';
|
|
11
|
-
import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.
|
|
12
|
-
import { g as globalExpect, v as vi } from './test.
|
|
11
|
+
import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.BDwxwUWG.js';
|
|
12
|
+
import { g as globalExpect, v as vi } from './test.D1JkM1w4.js';
|
|
13
13
|
import { c as closeInspector } from './inspector.CvyFGlXm.js';
|
|
14
14
|
import { createRequire } from 'node:module';
|
|
15
15
|
import timers from 'node:timers';
|
|
16
16
|
import timersPromises from 'node:timers/promises';
|
|
17
17
|
import util from 'node:util';
|
|
18
18
|
import { KNOWN_ASSET_TYPES } from '@vitest/utils/constants';
|
|
19
|
-
import { i as index } from './index.
|
|
19
|
+
import { i as index } from './index.C-zNJvRx.js';
|
|
20
20
|
import { g as getWorkerState, r as resetModules, p as provideWorkerState, a as getSafeWorkerState } from './utils.BX5Fg8C4.js';
|
|
21
21
|
|
|
22
22
|
// this should only be used in Node
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FileSpecification } from '@vitest/runner';
|
|
2
2
|
import { O as OTELCarrier } from './traces.d.402V_yFI.js';
|
|
3
|
-
import { T as TestExecutionMethod } from './worker.d.
|
|
3
|
+
import { T as TestExecutionMethod } from './worker.d.CckNUvI5.js';
|
|
4
4
|
|
|
5
5
|
type SerializedTestSpecification = [project: {
|
|
6
6
|
name: string | undefined;
|
|
@@ -621,7 +621,7 @@ class CAC extends EventEmitter {
|
|
|
621
621
|
|
|
622
622
|
const cac = (name = "") => new CAC(name);
|
|
623
623
|
|
|
624
|
-
var version = "4.1.
|
|
624
|
+
var version = "4.1.4";
|
|
625
625
|
|
|
626
626
|
const apiConfig = (port) => ({
|
|
627
627
|
port: {
|
|
@@ -891,7 +891,18 @@ const cliOptionsConfig = {
|
|
|
891
891
|
viewport: null,
|
|
892
892
|
screenshotDirectory: null,
|
|
893
893
|
screenshotFailures: null,
|
|
894
|
-
locators:
|
|
894
|
+
locators: {
|
|
895
|
+
description: "Options for how locators should be handled by default",
|
|
896
|
+
argument: "<options>",
|
|
897
|
+
subcommands: {
|
|
898
|
+
testIdAttribute: null,
|
|
899
|
+
exact: { description: "Should locators match the text exactly by default (default: `false`)" }
|
|
900
|
+
},
|
|
901
|
+
transform(val) {
|
|
902
|
+
if (typeof val !== "object" || val == null) return {};
|
|
903
|
+
return val;
|
|
904
|
+
}
|
|
905
|
+
},
|
|
895
906
|
testerHtmlPath: null,
|
|
896
907
|
instances: null,
|
|
897
908
|
expect: null,
|
|
@@ -1243,7 +1254,8 @@ const cliOptionsConfig = {
|
|
|
1243
1254
|
argument: "<path>",
|
|
1244
1255
|
description: "Custom provider for detecting changed files. (default: `git`)",
|
|
1245
1256
|
subcommands: null
|
|
1246
|
-
}
|
|
1257
|
+
},
|
|
1258
|
+
preParse: { description: "Parse test specifications before running them. This will apply `.only` flag and test name pattern across all files without running them. (default: `false`)" }
|
|
1247
1259
|
}
|
|
1248
1260
|
},
|
|
1249
1261
|
cliExclude: null,
|
|
@@ -2324,11 +2336,11 @@ function normalizeCliOptions(cliFilters, argv) {
|
|
|
2324
2336
|
}
|
|
2325
2337
|
async function start(mode, cliFilters, options) {
|
|
2326
2338
|
try {
|
|
2327
|
-
const { startVitest } = await import('./cli-api.
|
|
2339
|
+
const { startVitest } = await import('./cli-api.lDy4N9kC.js').then(function (n) { return n.q; });
|
|
2328
2340
|
const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
|
|
2329
2341
|
if (!ctx.shouldKeepServer()) await ctx.exit();
|
|
2330
2342
|
} catch (e) {
|
|
2331
|
-
const { errorBanner } = await import('./utils.
|
|
2343
|
+
const { errorBanner } = await import('./utils.BS4fH3nR.js').then(function (n) { return n.u; });
|
|
2332
2344
|
console.error(`\n${errorBanner("Startup Error")}`);
|
|
2333
2345
|
console.error(e);
|
|
2334
2346
|
console.error("\n\n");
|
|
@@ -2346,7 +2358,7 @@ async function init(project) {
|
|
|
2346
2358
|
}
|
|
2347
2359
|
async function collect(mode, cliFilters, options) {
|
|
2348
2360
|
try {
|
|
2349
|
-
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.
|
|
2361
|
+
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.lDy4N9kC.js').then(function (n) { return n.q; });
|
|
2350
2362
|
const ctx = await prepareVitest(mode, {
|
|
2351
2363
|
...normalizeCliOptions(cliFilters, options),
|
|
2352
2364
|
watch: false,
|
|
@@ -2368,7 +2380,7 @@ async function collect(mode, cliFilters, options) {
|
|
|
2368
2380
|
} else outputFileList(await ctx.getRelevantTestSpecifications(cliFilters.map(normalize)), options);
|
|
2369
2381
|
await ctx.close();
|
|
2370
2382
|
} catch (e) {
|
|
2371
|
-
const { errorBanner } = await import('./utils.
|
|
2383
|
+
const { errorBanner } = await import('./utils.BS4fH3nR.js').then(function (n) { return n.u; });
|
|
2372
2384
|
console.error(`\n${errorBanner("Collect Error")}`);
|
|
2373
2385
|
console.error(e);
|
|
2374
2386
|
console.error("\n\n");
|
|
@@ -10,23 +10,23 @@ import { parseAst, searchForWorkspaceRoot, fetchModule, version, createServer, i
|
|
|
10
10
|
import { A as API_PATH, c as configFiles, d as defaultBrowserPort, b as defaultPort } from './constants.CPYnjOGj.js';
|
|
11
11
|
import * as nodeos from 'node:os';
|
|
12
12
|
import nodeos__default, { tmpdir } from 'node:os';
|
|
13
|
-
import { generateHash as generateHash$1, createTaskName, validateTags, calculateSuiteHash,
|
|
13
|
+
import { generateHash as generateHash$1, createTaskName, validateTags, calculateSuiteHash, hasFailed, generateFileHash, limitConcurrency, createFileTask as createFileTask$1, createTagsFilter, someTasksAreOnly, interpretTaskModes, getTasks, isTestCase } from '@vitest/runner/utils';
|
|
14
14
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
15
15
|
import { serializeValue } from '@vitest/utils/serialize';
|
|
16
|
-
import { v as version$1 } from './cac.
|
|
16
|
+
import { v as version$1 } from './cac.wyYWMVI-.js';
|
|
17
17
|
import { rootDir, distDir } from '../path.js';
|
|
18
|
-
import { f as createIndexLocationsMap, g as TraceMap, o as originalPositionFor, h as ancestor, s as stringify, p as parse, i as printError, j as Typechecker, k as generateCodeFrame, l as escapeRegExp, m as createDefinesScript, a as BenchmarkReportsMap, R as ReportersMap, n as groupBy, q as BlobReporter, r as readBlobs, t as convertTasksToEvents, H as HangingProcessReporter, w as wildcardPatternToRegExp, u as stdout } from './index.
|
|
18
|
+
import { f as createIndexLocationsMap, g as TraceMap, o as originalPositionFor, h as ancestor, s as stringify, p as parse, i as printError, j as Typechecker, k as generateCodeFrame, l as escapeRegExp, m as createDefinesScript, a as BenchmarkReportsMap, R as ReportersMap, n as groupBy, q as BlobReporter, r as readBlobs, t as convertTasksToEvents, H as HangingProcessReporter, w as wildcardPatternToRegExp, u as stdout } from './index.BMXTnDNz.js';
|
|
19
19
|
import { N as NativeModuleRunner } from './nativeModuleRunner.BIakptoF.js';
|
|
20
20
|
import { T as Traces } from './traces.DT5aQ62U.js';
|
|
21
21
|
import { createDebug } from 'obug';
|
|
22
|
-
import { h as hash, R as RandomSequencer, i as isBrowserEnabled, r as resolveConfig, g as getCoverageProvider, b as resolveApiServerConfig } from './coverage.
|
|
22
|
+
import { h as hash, R as RandomSequencer, i as isBrowserEnabled, r as resolveConfig, g as getCoverageProvider, b as resolveApiServerConfig } from './coverage.Da5gzbsu.js';
|
|
23
23
|
import { rm, readFile, writeFile, rename, stat, unlink, mkdir, copyFile } from 'node:fs/promises';
|
|
24
24
|
import c from 'tinyrainbow';
|
|
25
25
|
import { VitestModuleEvaluator } from '#module-evaluator';
|
|
26
26
|
import { ModuleRunner } from 'vite/module-runner';
|
|
27
27
|
import { Console } from 'node:console';
|
|
28
28
|
import { g as getDefaultExportFromCjs } from './_commonjsHelpers.D26ty3Ew.js';
|
|
29
|
-
import { g as formatProjectName, w as withLabel, e as errorBanner, d as divider } from './utils.
|
|
29
|
+
import { g as formatProjectName, w as withLabel, e as errorBanner, d as divider } from './utils.BS4fH3nR.js';
|
|
30
30
|
import { createRequire, builtinModules, isBuiltin as isBuiltin$1 } from 'node:module';
|
|
31
31
|
import url, { fileURLToPath, pathToFileURL } from 'node:url';
|
|
32
32
|
import { i as isTTY, a as isWindows } from './env.D4Lgay0q.js';
|
|
@@ -389,8 +389,6 @@ function createFileTask(testFilepath, code, requestMap, config, filepath, fileTa
|
|
|
389
389
|
latestSuite.tasks.push(task);
|
|
390
390
|
});
|
|
391
391
|
calculateSuiteHash(file);
|
|
392
|
-
const hasOnly = someTasksAreOnly(file);
|
|
393
|
-
interpretTaskModes(file, config.testNamePattern, void 0, void 0, void 0, hasOnly, false, config.allowOnly);
|
|
394
392
|
markDynamicTests(file.tasks);
|
|
395
393
|
if (!file.tasks.length) file.result = {
|
|
396
394
|
state: "fail",
|
|
@@ -2322,7 +2320,7 @@ class VitestPackageInstaller {
|
|
|
2322
2320
|
} catch {}
|
|
2323
2321
|
}
|
|
2324
2322
|
if (/* @__PURE__ */ isPackageExists(dependency, { paths: [root, __dirname$1] })) return true;
|
|
2325
|
-
process.stderr.write(
|
|
2323
|
+
process.stderr.write(withLabel("red", "MISSING DEPENDENCY", `Cannot find dependency '${dependency}'\n\n`));
|
|
2326
2324
|
if (!isTTY) return false;
|
|
2327
2325
|
const { install } = await (await import('./index.og1WyBLx.js').then(function (n) { return n.i; })).default({
|
|
2328
2326
|
type: "confirm",
|
|
@@ -9228,7 +9226,10 @@ function serializeConfig(project) {
|
|
|
9228
9226
|
detailsPanelPosition: browser.detailsPanelPosition ?? "right",
|
|
9229
9227
|
viewport: browser.viewport,
|
|
9230
9228
|
screenshotFailures: browser.screenshotFailures,
|
|
9231
|
-
locators: {
|
|
9229
|
+
locators: {
|
|
9230
|
+
testIdAttribute: browser.locators.testIdAttribute,
|
|
9231
|
+
exact: browser.locators.exact
|
|
9232
|
+
},
|
|
9232
9233
|
providerOptions: provider?.name === "playwright" ? { actionTimeout: provider?.options?.actionTimeout } : {},
|
|
9233
9234
|
trackUnhandledErrors: browser.trackUnhandledErrors ?? true,
|
|
9234
9235
|
trace: browser.trace.mode
|
|
@@ -11221,7 +11222,10 @@ function cloneConfig(project, { browser, ...config }) {
|
|
|
11221
11222
|
...clonedConfig,
|
|
11222
11223
|
browser: {
|
|
11223
11224
|
...project.config.browser,
|
|
11224
|
-
locators: locators ? {
|
|
11225
|
+
locators: locators ? {
|
|
11226
|
+
testIdAttribute: locators.testIdAttribute ?? currentConfig.locators.testIdAttribute,
|
|
11227
|
+
exact: locators.exact ?? currentConfig.locators.exact
|
|
11228
|
+
} : project.config.browser.locators,
|
|
11225
11229
|
viewport: viewport ?? currentConfig.viewport,
|
|
11226
11230
|
testerHtmlPath: testerHtmlPath ?? currentConfig.testerHtmlPath,
|
|
11227
11231
|
screenshotDirectory: screenshotDirectory ?? currentConfig.screenshotDirectory,
|
|
@@ -13413,7 +13417,7 @@ class Vitest {
|
|
|
13413
13417
|
}
|
|
13414
13418
|
this.filenamePattern = filters && filters?.length > 0 ? filters : void 0;
|
|
13415
13419
|
startSpan.setAttribute("vitest.start.filters", this.filenamePattern || []);
|
|
13416
|
-
|
|
13420
|
+
let specifications = await this._traces.$("vitest.config.resolve_include_glob", async () => {
|
|
13417
13421
|
const specifications = await this.specifications.getRelevantTestSpecifications(filters);
|
|
13418
13422
|
startSpan.setAttribute("vitest.start.specifications", specifications.map((s) => {
|
|
13419
13423
|
const relativeModuleId = relative(s.project.config.root, s.moduleId);
|
|
@@ -13422,6 +13426,13 @@ class Vitest {
|
|
|
13422
13426
|
}));
|
|
13423
13427
|
return specifications;
|
|
13424
13428
|
});
|
|
13429
|
+
if (this.config.experimental.preParse) {
|
|
13430
|
+
// This populates specification.testModule with parsed information
|
|
13431
|
+
await this.experimental_parseSpecifications(specifications);
|
|
13432
|
+
specifications = specifications.filter(({ testModule }) => {
|
|
13433
|
+
return !testModule || testModule.task.mode !== "skip";
|
|
13434
|
+
});
|
|
13435
|
+
}
|
|
13425
13436
|
// if run with --changed, don't exit if no tests are found
|
|
13426
13437
|
if (!specifications.length) {
|
|
13427
13438
|
await this._traces.$("vitest.test_run", async () => {
|
|
@@ -13618,14 +13629,34 @@ class Vitest {
|
|
|
13618
13629
|
async experimental_parseSpecifications(specifications, options) {
|
|
13619
13630
|
if (this.mode !== "test") throw new Error(`The \`experimental_parseSpecifications\` does not support "${this.mode}" mode.`);
|
|
13620
13631
|
const limit = limitConcurrency(options?.concurrency ?? (typeof nodeos__default.availableParallelism === "function" ? nodeos__default.availableParallelism() : nodeos__default.cpus().length));
|
|
13621
|
-
|
|
13622
|
-
|
|
13632
|
+
// Phase 1: parse all files in parallel (without mode interpretation)
|
|
13633
|
+
const results = await Promise.all(specifications.map((specification) => limit(async () => {
|
|
13634
|
+
return {
|
|
13635
|
+
file: await astCollectTests(specification.project, specification.moduleId).catch((error) => {
|
|
13636
|
+
return createFailedFileTask(specification.project, specification.moduleId, error);
|
|
13637
|
+
}),
|
|
13638
|
+
specification
|
|
13639
|
+
};
|
|
13640
|
+
})));
|
|
13641
|
+
const tagsFilter = this.config.tagsFilter ? createTagsFilter(this.config.tagsFilter, this.config.tags) : void 0;
|
|
13642
|
+
// Phase 2: cross-file .only resolution
|
|
13643
|
+
const globalHasOnly = results.some(({ file }) => someTasksAreOnly(file));
|
|
13644
|
+
for (const { file, specification } of results) {
|
|
13645
|
+
const config = specification.project.config;
|
|
13646
|
+
interpretTaskModes(file, config.testNamePattern, specification.testLines, specification.testIds, tagsFilter, globalHasOnly, false, config.allowOnly);
|
|
13647
|
+
this.state.collectFiles(specification.project, [file]);
|
|
13648
|
+
}
|
|
13649
|
+
return results.map(({ file }) => this.state.getReportedEntity(file));
|
|
13623
13650
|
}
|
|
13624
13651
|
async experimental_parseSpecification(specification) {
|
|
13625
13652
|
if (this.mode !== "test") throw new Error(`The \`experimental_parseSpecification\` does not support "${this.mode}" mode.`);
|
|
13626
13653
|
const file = await astCollectTests(specification.project, specification.moduleId).catch((error) => {
|
|
13627
13654
|
return createFailedFileTask(specification.project, specification.moduleId, error);
|
|
13628
13655
|
});
|
|
13656
|
+
const config = specification.project.config;
|
|
13657
|
+
const hasOnly = someTasksAreOnly(file);
|
|
13658
|
+
const tagsFilter = this.config.tagsFilter ? createTagsFilter(this.config.tagsFilter, this.config.tags) : void 0;
|
|
13659
|
+
interpretTaskModes(file, config.testNamePattern, specification.testLines, specification.testIds, tagsFilter, hasOnly, false, config.allowOnly);
|
|
13629
13660
|
// register in state, so it can be retrieved by "getReportedEntity"
|
|
13630
13661
|
this.state.collectFiles(specification.project, [file]);
|
|
13631
13662
|
return this.state.getReportedEntity(file);
|
|
@@ -14020,7 +14051,7 @@ async function VitestPlugin(options = {}, vitest = new Vitest("test", deepClone(
|
|
|
14020
14051
|
// preliminary merge of options to be able to create server options for vite
|
|
14021
14052
|
// however to allow vitest plugins to modify vitest config values
|
|
14022
14053
|
// this is repeated in configResolved where the config is final
|
|
14023
|
-
const testConfig = deepMerge({}, configDefaults,
|
|
14054
|
+
const testConfig = deepMerge({}, configDefaults, viteConfig.test ?? {}, options);
|
|
14024
14055
|
testConfig.api = resolveApiServerConfig(testConfig, defaultPort);
|
|
14025
14056
|
// store defines for globalThis to make them
|
|
14026
14057
|
// reassignable when running in worker in src/runtime/setup.ts
|
|
@@ -14140,10 +14171,6 @@ async function VitestPlugin(options = {}, vitest = new Vitest("test", deepClone(
|
|
|
14140
14171
|
ModuleRunnerTransform()
|
|
14141
14172
|
].filter(notNullish);
|
|
14142
14173
|
}
|
|
14143
|
-
function removeUndefinedValues(obj) {
|
|
14144
|
-
for (const key in Object.keys(obj)) if (obj[key] === void 0) delete obj[key];
|
|
14145
|
-
return obj;
|
|
14146
|
-
}
|
|
14147
14174
|
|
|
14148
14175
|
async function createVitest(mode, options, viteOverrides = {}, vitestOptions = {}) {
|
|
14149
14176
|
const ctx = new Vitest(mode, deepClone(options), vitestOptions);
|
|
@@ -14,7 +14,8 @@ import { mergeConfig } from 'vite';
|
|
|
14
14
|
import { c as configFiles, d as defaultBrowserPort, a as defaultInspectPort, b as defaultPort } from './constants.CPYnjOGj.js';
|
|
15
15
|
import './env.D4Lgay0q.js';
|
|
16
16
|
import nodeos__default from 'node:os';
|
|
17
|
-
import {
|
|
17
|
+
import { w as withLabel } from './utils.BS4fH3nR.js';
|
|
18
|
+
import { isAgent, isCI, provider } from 'std-env';
|
|
18
19
|
import { r as resolveCoverageProviderModule } from './coverage.CTzCuANN.js';
|
|
19
20
|
|
|
20
21
|
const hash = crypto.hash ?? ((algorithm, data, outputEncoding) => crypto.createHash(algorithm).update(data).digest(outputEncoding));
|
|
@@ -155,7 +156,7 @@ function resolveConfig$1(vitest, options, viteConfig) {
|
|
|
155
156
|
const mode = vitest.mode;
|
|
156
157
|
const logger = vitest.logger;
|
|
157
158
|
if (options.dom) {
|
|
158
|
-
if (viteConfig.test?.environment != null && viteConfig.test.environment !== "happy-dom") logger.console.warn(
|
|
159
|
+
if (viteConfig.test?.environment != null && viteConfig.test.environment !== "happy-dom") logger.console.warn(withLabel("yellow", "Vitest", `Your config.test.environment ("${viteConfig.test.environment}") conflicts with --dom flag ("happy-dom"), ignoring "${viteConfig.test.environment}"`));
|
|
159
160
|
options.environment = "happy-dom";
|
|
160
161
|
}
|
|
161
162
|
const resolved = {
|
|
@@ -296,6 +297,18 @@ function resolveConfig$1(vitest, options, viteConfig) {
|
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
299
|
resolved.coverage.reporter = resolveCoverageReporters(resolved.coverage.reporter);
|
|
300
|
+
if (isAgent) {
|
|
301
|
+
// default to `skipFull` and add `text-summary` reporter when `text` reporter is used on agents
|
|
302
|
+
const text = resolved.coverage.reporter.find(([name]) => name === "text");
|
|
303
|
+
const textSummary = resolved.coverage.reporter.find(([name]) => name === "text-summary");
|
|
304
|
+
if (text) {
|
|
305
|
+
text[1] = {
|
|
306
|
+
skipFull: true,
|
|
307
|
+
...text[1]
|
|
308
|
+
};
|
|
309
|
+
if (!textSummary) resolved.coverage.reporter.push(["text-summary", {}]);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
299
312
|
if (resolved.coverage.changed === void 0 && resolved.changed !== void 0) resolved.coverage.changed = resolved.changed;
|
|
300
313
|
if (resolved.coverage.enabled && resolved.coverage.reportsDirectory) {
|
|
301
314
|
const reportsDirectory = resolve(resolved.root, resolved.coverage.reportsDirectory);
|
|
@@ -489,6 +502,7 @@ function resolveConfig$1(vitest, options, viteConfig) {
|
|
|
489
502
|
resolved.browser.viewport.height ??= 896;
|
|
490
503
|
resolved.browser.locators ??= {};
|
|
491
504
|
resolved.browser.locators.testIdAttribute ??= "data-testid";
|
|
505
|
+
resolved.browser.locators.exact ??= false;
|
|
492
506
|
if (typeof resolved.browser.provider === "string") {
|
|
493
507
|
const source = `@vitest/browser-${resolved.browser.provider}`;
|
|
494
508
|
throw new TypeError(`The \`browser.provider\` configuration was changed to accept a factory instead of a string. Add an import of "${resolved.browser.provider}" from "${source}" instead. See: https://vitest.dev/config/browser/provider`);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
|
|
2
2
|
import { Plugin } from '@vitest/pretty-format';
|
|
3
|
+
import { Test } from '@vitest/runner';
|
|
3
4
|
import { SnapshotState } from '@vitest/snapshot';
|
|
4
5
|
import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
|
|
5
6
|
import { U as UserConsoleLog } from './rpc.d.BFMWpdph.js';
|
|
@@ -16,6 +17,7 @@ declare module "@vitest/expect" {
|
|
|
16
17
|
interface MatcherState {
|
|
17
18
|
environment: string;
|
|
18
19
|
snapshotState: SnapshotState;
|
|
20
|
+
task?: Readonly<Test>;
|
|
19
21
|
}
|
|
20
22
|
interface ExpectPollOptions {
|
|
21
23
|
interval?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as globalApis } from './constants.CPYnjOGj.js';
|
|
2
|
-
import { i as index } from './index.
|
|
3
|
-
import './test.
|
|
2
|
+
import { i as index } from './index.C-zNJvRx.js';
|
|
3
|
+
import './test.D1JkM1w4.js';
|
|
4
4
|
import '@vitest/runner';
|
|
5
5
|
import '@vitest/utils/helpers';
|
|
6
6
|
import '@vitest/utils/timers';
|
|
@@ -10,13 +10,13 @@ import './utils.BX5Fg8C4.js';
|
|
|
10
10
|
import '@vitest/expect';
|
|
11
11
|
import '@vitest/utils/error';
|
|
12
12
|
import 'pathe';
|
|
13
|
-
import '@vitest/snapshot';
|
|
14
13
|
import '@vitest/spy';
|
|
15
14
|
import '@vitest/utils/offset';
|
|
16
15
|
import '@vitest/utils/source-map';
|
|
17
16
|
import './_commonjsHelpers.D26ty3Ew.js';
|
|
18
17
|
import './rpc.MzXet3jl.js';
|
|
19
18
|
import './index.Chj8NDwU.js';
|
|
19
|
+
import '@vitest/snapshot';
|
|
20
20
|
import './evaluatedModules.Dg1zASAC.js';
|
|
21
21
|
import 'vite/module-runner';
|
|
22
22
|
import 'expect-type';
|
|
@@ -3,7 +3,7 @@ import { getTests, generateHash, createTaskName, calculateSuiteHash, someTasksAr
|
|
|
3
3
|
import * as pathe from 'pathe';
|
|
4
4
|
import { relative, basename, resolve as resolve$1, join, normalize, dirname } from 'pathe';
|
|
5
5
|
import c from 'tinyrainbow';
|
|
6
|
-
import { t as truncateString, e as errorBanner, F as F_POINTER, d as divider, f as formatTimeString, a as taskFail, s as separator, b as F_CHECK, c as F_DOWN_RIGHT, g as formatProjectName, h as getStateSymbol, w as withLabel, r as renderSnapshotSummary, p as padSummaryTitle, i as getStateString$1, j as formatTime, k as countTestErrors, l as F_TREE_NODE_END, m as F_TREE_NODE_MIDDLE, n as noun, o as F_RIGHT } from './utils.
|
|
6
|
+
import { t as truncateString, e as errorBanner, F as F_POINTER, d as divider, f as formatTimeString, a as taskFail, s as separator, b as F_CHECK, c as F_DOWN_RIGHT, g as formatProjectName, h as getStateSymbol, w as withLabel, r as renderSnapshotSummary, p as padSummaryTitle, i as getStateString$1, j as formatTime, k as countTestErrors, l as F_TREE_NODE_END, m as F_TREE_NODE_MIDDLE, n as noun, o as F_RIGHT } from './utils.BS4fH3nR.js';
|
|
7
7
|
import { stripVTControlCharacters } from 'node:util';
|
|
8
8
|
import { isPrimitive, toArray, deepMerge, notNullish } from '@vitest/utils/helpers';
|
|
9
9
|
import { performance as performance$1 } from 'node:perf_hooks';
|
|
@@ -1836,6 +1836,7 @@ const skipErrorProperties = new Set([
|
|
|
1836
1836
|
"VITEST_TEST_NAME",
|
|
1837
1837
|
"VITEST_TEST_PATH",
|
|
1838
1838
|
"__vitest_rollup_error__",
|
|
1839
|
+
"__vitest_error_context__",
|
|
1839
1840
|
...Object.getOwnPropertyNames(Error.prototype),
|
|
1840
1841
|
...Object.getOwnPropertyNames(Object.prototype)
|
|
1841
1842
|
]);
|
|
@@ -3571,6 +3572,7 @@ class JsonReporter {
|
|
|
3571
3572
|
const numTodoTests = tests.filter((t) => t.mode === "todo").length;
|
|
3572
3573
|
const testResults = [];
|
|
3573
3574
|
const success = !!(files.length > 0 || this.ctx.config.passWithNoTests) && numFailedTestSuites === 0 && numFailedTests === 0;
|
|
3575
|
+
const { filterMeta } = this.options;
|
|
3574
3576
|
for (const file of files) {
|
|
3575
3577
|
const tests = getTests([file]);
|
|
3576
3578
|
let startTime = tests.reduce((prev, next) => Math.min(prev, next.result?.startTime ?? Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY);
|
|
@@ -3592,7 +3594,14 @@ class JsonReporter {
|
|
|
3592
3594
|
duration: t.result?.duration,
|
|
3593
3595
|
failureMessages: t.result?.errors?.map((e) => e.stack || e.message) || [],
|
|
3594
3596
|
location: t.location,
|
|
3595
|
-
meta:
|
|
3597
|
+
meta: filterMeta ? (() => {
|
|
3598
|
+
const filtered = {};
|
|
3599
|
+
for (const key in t.meta) {
|
|
3600
|
+
const value = t.meta[key];
|
|
3601
|
+
if (filterMeta(key, value)) filtered[key] = value;
|
|
3602
|
+
}
|
|
3603
|
+
return filtered;
|
|
3604
|
+
})() : t.meta,
|
|
3596
3605
|
tags: t.tags || []
|
|
3597
3606
|
};
|
|
3598
3607
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { v as vi, N as NodeBenchmarkRunner, T as TestRunner, a as assert, c as createExpect, g as globalExpect, i as inject, s as should, b as vitest } from './test.
|
|
1
|
+
import { v as vi, N as NodeBenchmarkRunner, S as Snapshots, T as TestRunner, a as assert, c as createExpect, g as globalExpect, i as inject, s as should, b as vitest } from './test.D1JkM1w4.js';
|
|
2
2
|
import { b as bench } from './benchmark.CX_oY03V.js';
|
|
3
3
|
import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
|
|
4
4
|
import { expectTypeOf } from 'expect-type';
|
|
@@ -11,6 +11,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
11
11
|
__proto__: null,
|
|
12
12
|
BenchmarkRunner: NodeBenchmarkRunner,
|
|
13
13
|
EvaluatedModules: VitestEvaluatedModules,
|
|
14
|
+
Snapshots: Snapshots,
|
|
14
15
|
TestRunner: TestRunner,
|
|
15
16
|
afterAll: afterAll,
|
|
16
17
|
afterEach: afterEach,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { chai } from '@vitest/expect';
|
|
2
2
|
import { createHook } from 'node:async_hooks';
|
|
3
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.
|
|
3
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.BDwxwUWG.js';
|
|
4
4
|
import { r as rpc } from './rpc.MzXet3jl.js';
|
|
5
5
|
import { g as getWorkerState } from './utils.BX5Fg8C4.js';
|
|
6
|
-
import { T as TestRunner, N as NodeBenchmarkRunner } from './test.
|
|
6
|
+
import { T as TestRunner, N as NodeBenchmarkRunner } from './test.D1JkM1w4.js';
|
|
7
7
|
|
|
8
8
|
function setupChaiConfig(config) {
|
|
9
9
|
Object.assign(chai.config, config);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DevEnvironment } from 'vite';
|
|
2
|
-
import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.
|
|
2
|
+
import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.BwkR0iL5.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Generate a unique cache identifier.
|
|
@@ -3,14 +3,14 @@ import { TestError, SerializedError, Arrayable, ParsedStack, Awaitable } from '@
|
|
|
3
3
|
import { A as AfterSuiteRunMeta, U as UserConsoleLog, b as AsyncLeak, P as ProvidedContext, L as LabelColor } from './rpc.d.BFMWpdph.js';
|
|
4
4
|
import { Writable } from 'node:stream';
|
|
5
5
|
import { DevEnvironment, TransformResult as TransformResult$1, ViteDevServer, Plugin, UserConfig as UserConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
|
|
6
|
-
import { S as SerializedTestSpecification, c as SourceModuleDiagnostic, B as BrowserTesterOptions } from './browser.d.
|
|
7
|
-
import { B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.
|
|
6
|
+
import { S as SerializedTestSpecification, c as SourceModuleDiagnostic, B as BrowserTesterOptions } from './browser.d.C0zGu1u9.js';
|
|
7
|
+
import { B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.ChUh6-ad.js';
|
|
8
8
|
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
|
9
9
|
import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
|
|
10
10
|
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
11
11
|
import { chai } from '@vitest/expect';
|
|
12
12
|
import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
|
|
13
|
-
import { c as ContextTestEnvironment, d as WorkerExecuteContext, e as WorkerTestEnvironment } from './worker.d.
|
|
13
|
+
import { c as ContextTestEnvironment, d as WorkerExecuteContext, e as WorkerTestEnvironment } from './worker.d.CckNUvI5.js';
|
|
14
14
|
import { O as OTELCarrier } from './traces.d.402V_yFI.js';
|
|
15
15
|
import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
|
|
16
16
|
import { MockedModule } from '@vitest/mocker';
|
|
@@ -1609,6 +1609,11 @@ interface BrowserConfigOptions {
|
|
|
1609
1609
|
* @default 'data-testid'
|
|
1610
1610
|
*/
|
|
1611
1611
|
testIdAttribute?: string;
|
|
1612
|
+
/**
|
|
1613
|
+
* Should locators match the text exactly by default
|
|
1614
|
+
* @default false
|
|
1615
|
+
*/
|
|
1616
|
+
exact?: boolean;
|
|
1612
1617
|
};
|
|
1613
1618
|
/**
|
|
1614
1619
|
* Generate traces that can be viewed on https://trace.playwright.dev/
|
|
@@ -1772,6 +1777,7 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
|
1772
1777
|
screenshotFailures: boolean;
|
|
1773
1778
|
locators: {
|
|
1774
1779
|
testIdAttribute: string;
|
|
1780
|
+
exact: boolean;
|
|
1775
1781
|
};
|
|
1776
1782
|
trace: {
|
|
1777
1783
|
mode: BrowserTraceViewMode;
|
|
@@ -2262,6 +2268,8 @@ interface JsonTestResults {
|
|
|
2262
2268
|
}
|
|
2263
2269
|
interface JsonOptions {
|
|
2264
2270
|
outputFile?: string;
|
|
2271
|
+
/** @experimental */
|
|
2272
|
+
filterMeta?: (key: string, value: unknown) => unknown;
|
|
2265
2273
|
}
|
|
2266
2274
|
declare class JsonReporter implements Reporter {
|
|
2267
2275
|
start: number;
|
|
@@ -3280,6 +3288,11 @@ interface InlineConfig {
|
|
|
3280
3288
|
* implementation of the `VCSProvider` interface to use a different version control system.
|
|
3281
3289
|
*/
|
|
3282
3290
|
vcsProvider?: VCSProvider | string;
|
|
3291
|
+
/**
|
|
3292
|
+
* Parse test specifications before running them.
|
|
3293
|
+
* This will apply `.only` flag and test name pattern across all files without running them.
|
|
3294
|
+
*/
|
|
3295
|
+
preParse?: boolean;
|
|
3283
3296
|
};
|
|
3284
3297
|
/**
|
|
3285
3298
|
* Define tags available in your test files.
|
|
@@ -26,7 +26,7 @@ async function setupCommonEnv(config) {
|
|
|
26
26
|
if (globalSetup) return;
|
|
27
27
|
globalSetup = true;
|
|
28
28
|
setSafeTimers();
|
|
29
|
-
if (config.globals) (await import('./globals.
|
|
29
|
+
if (config.globals) (await import('./globals.BVDtJR67.js')).registerApiGlobally();
|
|
30
30
|
}
|
|
31
31
|
function setupDefines(config) {
|
|
32
32
|
for (const key in config.defines) globalThis[key] = config.defines[key];
|