vitest 4.1.0-beta.2 → 4.1.0-beta.3

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.
Files changed (51) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{base.DiopZV8F.js → base.BawQY8vy.js} +4 -4
  4. package/dist/chunks/{browser.d.BE4kbYok.d.ts → browser.d.CweQ2M9y.d.ts} +1 -1
  5. package/dist/chunks/{cac.C4jjt2RX.js → cac.Bmb60yM3.js} +259 -124
  6. package/dist/chunks/{cli-api.ChbI1JU9.js → cli-api.DwoCIT8I.js} +89 -85
  7. package/dist/chunks/{config.d.Cr1Ep39N.d.ts → config.d.pC9164XK.d.ts} +14 -1
  8. package/dist/chunks/{constants.B63TT-Bl.js → constants.CPYnjOGj.js} +3 -1
  9. package/dist/chunks/{coverage.tyqbzn4W.js → coverage.DAUQBfjL.js} +32 -5
  10. package/dist/chunks/{creator.yyCHuw5R.js → creator.DgVhQm5q.js} +3 -3
  11. package/dist/chunks/{global.d.JeWMqlOm.d.ts → global.d.DYf8kr_l.d.ts} +1 -1
  12. package/dist/chunks/{globals.C6Ecf1TO.js → globals.AhCakrmA.js} +3 -3
  13. package/dist/chunks/{index.CAN630q3.js → index.CEU66SQN.js} +2 -2
  14. package/dist/chunks/{index.D3XRDfWc.js → index.CMESou6r.js} +26 -1
  15. package/dist/chunks/{index.CouFDptX.js → index.D3wDRGBz.js} +4 -2
  16. package/dist/chunks/{index.B-iBE_Gx.js → index.De5aIHUc.js} +39 -18
  17. package/dist/chunks/{index.D4KonVSU.js → index.og1WyBLx.js} +18 -3
  18. package/dist/chunks/{index.CFulQRmC.js → index.qcTcl_eM.js} +1 -1
  19. package/dist/chunks/{plugin.d.C9o5bttz.d.ts → plugin.d.CTohQCcC.d.ts} +1 -1
  20. package/dist/chunks/{reporters.d.7faYdkxy.d.ts → reporters.d.DPe11uSn.d.ts} +82 -14
  21. package/dist/chunks/{rpc.d.CM7x9-sm.d.ts → rpc.d.CUhiUEld.d.ts} +1 -1
  22. package/dist/chunks/{setup-common.cvFp-ao9.js → setup-common.BoY7R7rC.js} +2 -2
  23. package/dist/chunks/{suite.d.BJWk38HB.d.ts → suite.d.udJtyAgw.d.ts} +1 -1
  24. package/dist/chunks/{test.G82XYNFk.js → test.CnO2BIt2.js} +6 -2
  25. package/dist/chunks/{vm.BdLtzhnj.js → vm.CMbtLg78.js} +1 -1
  26. package/dist/chunks/{worker.d.CPzI2ZzJ.d.ts → worker.d.CiaQ1oon.d.ts} +2 -2
  27. package/dist/cli.js +3 -3
  28. package/dist/config.d.ts +8 -8
  29. package/dist/config.js +1 -1
  30. package/dist/coverage.d.ts +5 -5
  31. package/dist/coverage.js +2 -2
  32. package/dist/index.d.ts +11 -12
  33. package/dist/index.js +3 -3
  34. package/dist/module-evaluator.d.ts +2 -1
  35. package/dist/module-evaluator.js +36 -26
  36. package/dist/node.d.ts +13 -10
  37. package/dist/node.js +9 -9
  38. package/dist/reporters.d.ts +5 -5
  39. package/dist/reporters.js +2 -2
  40. package/dist/runners.d.ts +2 -2
  41. package/dist/runners.js +1 -1
  42. package/dist/suite.d.ts +1 -1
  43. package/dist/worker.d.ts +3 -3
  44. package/dist/worker.js +5 -5
  45. package/dist/workers/forks.js +5 -5
  46. package/dist/workers/runVmTests.js +4 -4
  47. package/dist/workers/threads.js +5 -5
  48. package/dist/workers/vmForks.js +1 -1
  49. package/dist/workers/vmThreads.js +1 -1
  50. package/globals.d.ts +2 -0
  51. package/package.json +16 -16
@@ -3,19 +3,19 @@ import { relative, resolve, dirname, join, extname, normalize, 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 { cleanUrl, noop, unique, createDefer, slash, withTrailingSlash, wrapId, isExternalUrl, unwrapId, toArray, deepMerge, nanoid, deepClone, isPrimitive, notNullish } from '@vitest/utils/helpers';
6
- import { a as any, p as prompt } from './index.D4KonVSU.js';
6
+ import { a as any, p as prompt } from './index.og1WyBLx.js';
7
7
  import { i as isPackageExists, r as resolveModule } from './index.BCY_7LL2.js';
8
8
  import * as vite from 'vite';
9
- import { createServer, isFileLoadingAllowed, normalizePath, parseAst, searchForWorkspaceRoot, fetchModule, version, mergeConfig } from 'vite';
10
- import { A as API_PATH, c as configFiles, d as defaultBrowserPort, b as defaultPort } from './constants.B63TT-Bl.js';
9
+ import { createServer, isFileLoadingAllowed, normalizePath, parseAst, searchForWorkspaceRoot, fetchModule, version, isRunnableDevEnvironment, mergeConfig } from 'vite';
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
13
  import { generateHash as generateHash$1, createTaskName, validateTags, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, hasFailed, generateFileHash, limitConcurrency, createFileTask as createFileTask$1, getTasks, isTestCase } from '@vitest/runner/utils';
14
14
  import { SnapshotManager } from '@vitest/snapshot/manager';
15
- import { v as version$1 } from './cac.C4jjt2RX.js';
15
+ import { v as version$1 } from './cac.Bmb60yM3.js';
16
16
  import { performance as performance$1 } from 'node:perf_hooks';
17
17
  import { c as createBirpc } from './index.Chj8NDwU.js';
18
- import { p as parse, d as stringify, e as createIndexLocationsMap, h as TraceMap, o as originalPositionFor, i as ancestor, j as printError, f as formatProjectName, w as withLabel, k as errorBanner, l as divider, m as Typechecker, n as generateCodeFrame, q as escapeRegExp, r as createDefinesScript, R as ReportersMap, u as groupBy, B as BlobReporter, v as readBlobs, x as convertTasksToEvents, H as HangingProcessReporter, y as wildcardPatternToRegExp, z as stdout } from './index.B-iBE_Gx.js';
18
+ import { p as parse, d as stringify, e as createIndexLocationsMap, h as TraceMap, o as originalPositionFor, i as ancestor, j as printError, f as formatProjectName, w as withLabel, k as errorBanner, l as divider, m as Typechecker, n as generateCodeFrame, q as escapeRegExp, r as createDefinesScript, R as ReportersMap, u as groupBy, B as BlobReporter, v as readBlobs, x as convertTasksToEvents, H as HangingProcessReporter, y as wildcardPatternToRegExp, z as stdout } from './index.De5aIHUc.js';
19
19
  import require$$0$3 from 'events';
20
20
  import require$$1$1 from 'https';
21
21
  import require$$2 from 'http';
@@ -32,7 +32,7 @@ import { rootDir, distDir } from '../path.js';
32
32
  import { N as NativeModuleRunner } from './nativeModuleRunner.BIakptoF.js';
33
33
  import { T as Traces } from './traces.CCmnQaNT.js';
34
34
  import { createDebug } from 'obug';
35
- import { h as hash, R as RandomSequencer, i as isBrowserEnabled, r as resolveConfig, g as getCoverageProvider, a as resolveApiServerConfig } from './coverage.tyqbzn4W.js';
35
+ import { h as hash, R as RandomSequencer, i as isBrowserEnabled, r as resolveConfig, g as getCoverageProvider, b as resolveApiServerConfig } from './coverage.DAUQBfjL.js';
36
36
  import { rm, readFile, writeFile, rename, stat, unlink, mkdir, copyFile } from 'node:fs/promises';
37
37
  import c from 'tinyrainbow';
38
38
  import { VitestModuleEvaluator } from '#module-evaluator';
@@ -44,7 +44,7 @@ import url, { fileURLToPath, pathToFileURL } from 'node:url';
44
44
  import { i as isTTY, a as isWindows } from './env.D4Lgay0q.js';
45
45
  import { isatty } from 'node:tty';
46
46
  import EventEmitter$1, { EventEmitter } from 'node:events';
47
- import { t as toBuiltin, i as isBuiltin } from './modules.BJuCwlRJ.js';
47
+ import { i as isBuiltin, t as toBuiltin } from './modules.BJuCwlRJ.js';
48
48
  import { fork } from 'node:child_process';
49
49
  import { Worker } from 'node:worker_threads';
50
50
  import pm from 'picomatch';
@@ -55,7 +55,7 @@ import { c as configDefaults } from './defaults.BOqNVLsY.js';
55
55
  import { KNOWN_ASSET_RE } from '@vitest/utils/constants';
56
56
  import { findNearestPackageData } from '@vitest/utils/resolver';
57
57
  import * as esModuleLexer from 'es-module-lexer';
58
- import { a as BenchmarkReportsMap } from './index.CFulQRmC.js';
58
+ import { a as BenchmarkReportsMap } from './index.qcTcl_eM.js';
59
59
  import assert$1 from 'node:assert';
60
60
  import { serializeValue } from '@vitest/utils/serialize';
61
61
  import { parseErrorStacktrace } from '@vitest/utils/source-map';
@@ -5175,9 +5175,6 @@ function setup(ctx, _server) {
5175
5175
  });
5176
5176
  function setupClient(ws) {
5177
5177
  const rpc = createBirpc({
5178
- async onTaskUpdate(packs, events) {
5179
- await ctx._testRun.updated(packs, events);
5180
- },
5181
5178
  getFiles() {
5182
5179
  return ctx.state.getFiles();
5183
5180
  },
@@ -5190,12 +5187,18 @@ function setup(ctx, _server) {
5190
5187
  },
5191
5188
  async saveTestFile(id, content) {
5192
5189
  if (!ctx.state.filesMap.has(id) || !existsSync(id)) throw new Error(`Test file "${id}" was not registered, so it cannot be updated using the API.`);
5190
+ // silently ignore write attempts if not allowed
5191
+ if (!ctx.config.api.allowWrite) return;
5193
5192
  return promises.writeFile(id, content, "utf-8");
5194
5193
  },
5195
5194
  async rerun(files, resetTestNamePattern) {
5195
+ // silently ignore exec attempts if not allowed
5196
+ if (!ctx.config.api.allowExec) return;
5196
5197
  await ctx.rerunFiles(files, void 0, true, resetTestNamePattern);
5197
5198
  },
5198
5199
  async rerunTask(id) {
5200
+ // silently ignore exec attempts if not allowed
5201
+ if (!ctx.config.api.allowExec) return;
5199
5202
  await ctx.rerunTask(id);
5200
5203
  },
5201
5204
  getConfig() {
@@ -5242,6 +5245,9 @@ function setup(ctx, _server) {
5242
5245
  return getModuleGraph(ctx, project, id, browser);
5243
5246
  },
5244
5247
  async updateSnapshot(file) {
5248
+ // silently ignore exec/write attempts if not allowed
5249
+ // this function both executes the code and write snapshots
5250
+ if (!ctx.config.api.allowExec || !ctx.config.api.allowWrite) return;
5245
5251
  if (!file) await ctx.updateSnapshot();
5246
5252
  else await ctx.updateSnapshot([file.filepath]);
5247
5253
  },
@@ -5472,7 +5478,7 @@ function astParseFile(filepath, code) {
5472
5478
  if (messageNode?.type === "Literal" || messageNode?.type === "TemplateLiteral") message = code.slice(messageNode.start + 1, messageNode.end - 1);
5473
5479
  else message = code.slice(messageNode.start, messageNode.end);
5474
5480
  if (message.startsWith("0,")) message = message.slice(2);
5475
- message = message.replace(/__vite_ssr_import_\d+__\./g, "").replace(/__vi_import_\d+__\./g, "");
5481
+ message = message.replace(/\(0\s?,\s?__vite_ssr_import_\d+__.(\w+)\)/g, "$1").replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "").replace(/__vi_import_\d+__\./g, "");
5476
5482
  // cannot statically analyze, so we always skip it
5477
5483
  if (mode === "skipIf" || mode === "runIf") mode = "skip";
5478
5484
  const parentCalleeName = typeof callee?.callee === "object" && callee?.callee.type === "MemberExpression" && callee?.callee.property?.name;
@@ -6808,7 +6814,7 @@ This might cause false positive tests. Resolve unhandled errors to make sure you
6808
6814
  }
6809
6815
  }
6810
6816
 
6811
- // this function recieves the module diagnostic with the location of imports
6817
+ // this function receives the module diagnostic with the location of imports
6812
6818
  // and populates it with collected import durations; the duration is injected
6813
6819
  // only if the current module is the one that imported the module
6814
6820
  // if testModule is not defined, then Vitest aggregates durations of ALL collected test modules
@@ -7057,14 +7063,14 @@ class VitestPackageInstaller {
7057
7063
  if (/* @__PURE__ */ isPackageExists(dependency, { paths: [root, __dirname$1] })) return true;
7058
7064
  process.stderr.write(c.red(`${c.inverse(c.red(" MISSING DEPENDENCY "))} Cannot find dependency '${dependency}'\n\n`));
7059
7065
  if (!isTTY) return false;
7060
- const { install } = await (await import('./index.D4KonVSU.js').then(function (n) { return n.i; })).default({
7066
+ const { install } = await (await import('./index.og1WyBLx.js').then(function (n) { return n.i; })).default({
7061
7067
  type: "confirm",
7062
7068
  name: "install",
7063
7069
  message: c.reset(`Do you want to install ${c.green(dependency)}?`)
7064
7070
  });
7065
7071
  if (install) {
7066
7072
  const packageName = version ? `${dependency}@${version}` : dependency;
7067
- await (await import('./index.D3XRDfWc.js')).installPackage(packageName, { dev: true });
7073
+ await (await import('./index.CMESou6r.js')).installPackage(packageName, { dev: true });
7068
7074
  // TODO: somehow it fails to load the package after installation, remove this when it's fixed
7069
7075
  process.stderr.write(c.yellow(`\nPackage ${packageName} installed, re-run the command to start.\n`));
7070
7076
  process.exit();
@@ -8594,6 +8600,12 @@ function serializeConfig(project) {
8594
8600
  pool: config.pool,
8595
8601
  expect: config.expect,
8596
8602
  snapshotSerializers: config.snapshotSerializers,
8603
+ api: ((api) => {
8604
+ return {
8605
+ allowExec: api?.allowExec,
8606
+ allowWrite: api?.allowWrite
8607
+ };
8608
+ })(project.isBrowserEnabled() ? config.browser.api : config.api),
8597
8609
  diff: config.diff,
8598
8610
  retry: config.retry,
8599
8611
  disableConsoleIntercept: config.disableConsoleIntercept,
@@ -8653,6 +8665,7 @@ function serializeConfig(project) {
8653
8665
  isolate: browser.isolate,
8654
8666
  fileParallelism: browser.fileParallelism,
8655
8667
  ui: browser.ui,
8668
+ detailsPanelPosition: browser.detailsPanelPosition ?? "right",
8656
8669
  viewport: browser.viewport,
8657
8670
  screenshotFailures: browser.screenshotFailures,
8658
8671
  locators: { testIdAttribute: browser.locators.testIdAttribute },
@@ -8667,7 +8680,7 @@ function serializeConfig(project) {
8667
8680
  serializedDefines: config.browser.enabled ? "" : project._serializedDefines || "",
8668
8681
  experimental: {
8669
8682
  fsModuleCache: config.experimental.fsModuleCache ?? false,
8670
- printImportBreakdown: config.experimental.printImportBreakdown,
8683
+ importDurations: config.experimental.importDurations,
8671
8684
  viteModuleRunner: config.experimental.viteModuleRunner ?? true,
8672
8685
  nodeLoader: config.experimental.nodeLoader ?? true,
8673
8686
  openTelemetry: config.experimental.openTelemetry
@@ -9526,13 +9539,17 @@ function getDefaultServerConditions() {
9526
9539
  }
9527
9540
 
9528
9541
  function ModuleRunnerTransform() {
9542
+ let testConfig;
9543
+ const noExternal = [];
9544
+ const external = [];
9545
+ let noExternalAll = false;
9529
9546
  // make sure Vite always applies the module runner transform
9530
9547
  return {
9531
9548
  name: "vitest:environments-module-runner",
9532
9549
  config: {
9533
9550
  order: "post",
9534
9551
  handler(config) {
9535
- const testConfig = config.test || {};
9552
+ testConfig = config.test || {};
9536
9553
  config.environments ??= {};
9537
9554
  const names = new Set(Object.keys(config.environments));
9538
9555
  names.add("client");
@@ -9550,9 +9567,6 @@ function ModuleRunnerTransform() {
9550
9567
  if (!moduleDirectories.includes("/node_modules/")) moduleDirectories.push("/node_modules/");
9551
9568
  testConfig.deps ??= {};
9552
9569
  testConfig.deps.moduleDirectories = moduleDirectories;
9553
- const external = [];
9554
- const noExternal = [];
9555
- let noExternalAll;
9556
9570
  for (const name of names) {
9557
9571
  config.environments[name] ??= {};
9558
9572
  const environment = config.environments[name];
@@ -9564,53 +9578,33 @@ function ModuleRunnerTransform() {
9564
9578
  } else environment.dev.moduleRunnerTransform = true;
9565
9579
  environment.dev.preTransformRequests = false;
9566
9580
  environment.keepProcessEnv = true;
9567
- const resolveExternal = name === "client" ? config.resolve?.external : [];
9568
- const resolveNoExternal = name === "client" ? config.resolve?.noExternal : [];
9569
- const topLevelResolveOptions = {};
9570
- if (resolveExternal != null) topLevelResolveOptions.external = resolveExternal;
9571
- if (resolveNoExternal != null) topLevelResolveOptions.noExternal = resolveNoExternal;
9572
- const currentResolveOptions = mergeConfig(topLevelResolveOptions, environment.resolve || {});
9573
- const envNoExternal = resolveViteResolveOptions("noExternal", currentResolveOptions, moduleDirectories);
9574
- if (envNoExternal === true) noExternalAll = true;
9575
- else if (envNoExternal.length) noExternal.push(...envNoExternal);
9576
- else if (name === "client" || name === "ssr") {
9577
- const deprecatedNoExternal = resolveDeprecatedOptions(name === "client" ? config.resolve?.noExternal : config.ssr?.noExternal, moduleDirectories);
9578
- if (deprecatedNoExternal === true) noExternalAll = true;
9579
- else noExternal.push(...deprecatedNoExternal);
9580
- }
9581
- const envExternal = resolveViteResolveOptions("external", currentResolveOptions, moduleDirectories);
9582
- if (envExternal !== true && envExternal.length) external.push(...envExternal);
9583
- else if (name === "client" || name === "ssr") {
9584
- const deprecatedExternal = resolveDeprecatedOptions(name === "client" ? config.resolve?.external : config.ssr?.external, moduleDirectories);
9585
- if (deprecatedExternal !== true) external.push(...deprecatedExternal);
9586
- }
9587
- // remove Vite's externalization logic because we have our own (unfortunetly)
9588
- environment.resolve ??= {};
9589
- environment.resolve.external = [...builtinModules, ...builtinModules.map((m) => `node:${m}`)];
9590
- // by setting `noExternal` to `true`, we make sure that
9591
- // Vite will never use its own externalization mechanism
9592
- // to externalize modules and always resolve static imports
9593
- // in both SSR and Client environments
9594
- environment.resolve.noExternal = true;
9595
- // Workaround `noExternal` merging bug on Vite 6
9596
- // https://github.com/vitejs/vite/pull/20502
9597
- if (name === "ssr") {
9598
- delete config.ssr?.noExternal;
9599
- delete config.ssr?.external;
9600
- }
9601
- if (name === "__vitest_vm__" || name === "__vitest__") continue;
9602
- const currentOptimizeDeps = environment.optimizeDeps || (name === "client" ? config.optimizeDeps : name === "ssr" ? config.ssr?.optimizeDeps : void 0);
9603
- const optimizeDeps = resolveOptimizerConfig(testConfig.deps?.optimizer?.[name], currentOptimizeDeps);
9604
- // Vite respects the root level optimize deps, so we override it instead
9605
- if (name === "client") {
9606
- config.optimizeDeps = optimizeDeps;
9607
- environment.optimizeDeps = void 0;
9608
- } else if (name === "ssr") {
9609
- config.ssr ??= {};
9610
- config.ssr.optimizeDeps = optimizeDeps;
9611
- environment.optimizeDeps = void 0;
9612
- } else environment.optimizeDeps = optimizeDeps;
9613
9581
  }
9582
+ }
9583
+ },
9584
+ configEnvironment: {
9585
+ order: "post",
9586
+ handler(name, config) {
9587
+ if (name === "__vitest_vm__" || name === "__vitest__") return;
9588
+ config.resolve ??= {};
9589
+ const envNoExternal = resolveViteResolveOptions("noExternal", config.resolve, testConfig.deps?.moduleDirectories);
9590
+ if (envNoExternal === true) noExternalAll = true;
9591
+ else if (envNoExternal.length) noExternal.push(...envNoExternal);
9592
+ const envExternal = resolveViteResolveOptions("external", config.resolve, testConfig.deps?.moduleDirectories);
9593
+ if (envExternal !== true && envExternal.length) external.push(...envExternal);
9594
+ // remove Vite's externalization logic because we have our own (unfortunately)
9595
+ config.resolve.external = [...builtinModules, ...builtinModules.map((m) => `node:${m}`)];
9596
+ // by setting `noExternal` to `true`, we make sure that
9597
+ // Vite will never use its own externalization mechanism
9598
+ // to externalize modules and always resolve static imports
9599
+ // in both SSR and Client environments
9600
+ config.resolve.noExternal = true;
9601
+ config.optimizeDeps = resolveOptimizerConfig(testConfig?.deps?.optimizer?.[name], config.optimizeDeps);
9602
+ }
9603
+ },
9604
+ configResolved: {
9605
+ order: "pre",
9606
+ handler(config) {
9607
+ const testConfig = config.test;
9614
9608
  testConfig.server ??= {};
9615
9609
  testConfig.server.deps ??= {};
9616
9610
  if (testConfig.server.deps.inline !== true) {
@@ -9637,12 +9631,6 @@ function resolveViteResolveOptions(key, options, moduleDirectories) {
9637
9631
  else if (typeof options[key] === "boolean") return true;
9638
9632
  return [];
9639
9633
  }
9640
- function resolveDeprecatedOptions(options, moduleDirectories) {
9641
- if (options === true) return true;
9642
- else if (Array.isArray(options)) return options.map((dep) => processWildcard(dep, moduleDirectories));
9643
- else if (options != null) return [processWildcard(options, moduleDirectories)];
9644
- return [];
9645
- }
9646
9634
  function processWildcard(dep, moduleDirectories) {
9647
9635
  if (typeof dep !== "string") return dep;
9648
9636
  if (typeof dep === "string" && dep.includes("*")) {
@@ -9738,6 +9726,7 @@ function WorkspaceVitestPlugin(project, options) {
9738
9726
  if (testConfig.experimental?.fsModuleCachePath == null && project.vitest.config.experimental?.fsModuleCachePath != null) vitestConfig.experimental.fsModuleCachePath = project.vitest.config.experimental.fsModuleCachePath;
9739
9727
  if (testConfig.experimental?.viteModuleRunner == null && project.vitest.config.experimental?.viteModuleRunner != null) vitestConfig.experimental.viteModuleRunner = project.vitest.config.experimental.viteModuleRunner;
9740
9728
  if (testConfig.experimental?.nodeLoader == null && project.vitest.config.experimental?.nodeLoader != null) vitestConfig.experimental.nodeLoader = project.vitest.config.experimental.nodeLoader;
9729
+ if (testConfig.experimental?.importDurations == null && project.vitest.config.experimental?.importDurations != null) vitestConfig.experimental.importDurations = project.vitest.config.experimental.importDurations;
9741
9730
  return {
9742
9731
  base: "/",
9743
9732
  environments: { __vitest__: { dev: {} } },
@@ -9806,7 +9795,6 @@ function WorkspaceVitestPlugin(project, options) {
9806
9795
  },
9807
9796
  {
9808
9797
  name: "vitest:project:server",
9809
- enforce: "post",
9810
9798
  async configureServer(server) {
9811
9799
  const options = deepMerge({}, configDefaults, server.config.test || {});
9812
9800
  await project._configureServer(options, server);
@@ -9969,7 +9957,6 @@ class TestSpecification {
9969
9957
  moduleId;
9970
9958
  /**
9971
9959
  * The current test pool. It's possible to have multiple pools in a single test project with `typecheck.enabled`.
9972
- * @experimental In later versions, the project will only support a single pool.
9973
9960
  */
9974
9961
  pool;
9975
9962
  /**
@@ -10374,6 +10361,15 @@ class TestProject {
10374
10361
  this._fetcher = createFetchModuleFunction(this._resolver, this._config, this.vitest._fsCache, this.vitest._traces, this.tmpDir);
10375
10362
  const environment = server.environments.__vitest__;
10376
10363
  this.runner = this._config.experimental.viteModuleRunner === false ? new NativeModuleRunner(this._config.root) : new ServerModuleRunner(environment, this._fetcher, this._config);
10364
+ const ssrEnvironment = server.environments.ssr;
10365
+ if (isRunnableDevEnvironment(ssrEnvironment)) {
10366
+ const ssrRunner = new ServerModuleRunner(ssrEnvironment, this._fetcher, this._config);
10367
+ Object.defineProperty(ssrEnvironment, "runner", {
10368
+ value: ssrRunner,
10369
+ writable: true,
10370
+ configurable: true
10371
+ });
10372
+ }
10377
10373
  }
10378
10374
  /** @internal */
10379
10375
  _getViteEnvironments() {
@@ -12406,6 +12402,17 @@ class Vitest {
12406
12402
  this._fetcher = createFetchModuleFunction(this._resolver, this._config, this._fsCache, this._traces, this._tmpDir);
12407
12403
  const environment = server.environments.__vitest__;
12408
12404
  this.runner = resolved.experimental.viteModuleRunner === false ? new NativeModuleRunner(resolved.root) : new ServerModuleRunner(environment, this._fetcher, resolved);
12405
+ // patch default ssr runnable environment so third-party usage of `runner.import`
12406
+ // still works with Vite's external/noExternal configuration.
12407
+ const ssrEnvironment = server.environments.ssr;
12408
+ if (isRunnableDevEnvironment(ssrEnvironment)) {
12409
+ const ssrRunner = new ServerModuleRunner(ssrEnvironment, this._fetcher, resolved);
12410
+ Object.defineProperty(ssrEnvironment, "runner", {
12411
+ value: ssrRunner,
12412
+ writable: true,
12413
+ configurable: true
12414
+ });
12415
+ }
12409
12416
  if (this.config.watch) {
12410
12417
  // hijack server restart
12411
12418
  const serverRestart = server.restart;
@@ -13396,16 +13403,13 @@ async function VitestPlugin(options = {}, vitest = new Vitest("test", deepClone(
13396
13403
  instance.name ??= originalName ? `${originalName} (${instance.browser})` : instance.browser;
13397
13404
  });
13398
13405
  },
13399
- configureServer: {
13400
- order: "post",
13401
- async handler(server) {
13402
- if (options.watch && false);
13403
- await vitest._setServer(options, server);
13404
- if (options.api && options.watch) (await Promise.resolve().then(function () { return setup$1; })).setup(vitest);
13405
- // #415, in run mode we don't need the watcher, close it would improve the performance
13406
- if (!options.watch) await server.watcher.close();
13407
- }
13408
- }
13406
+ configureServer: { async handler(server) {
13407
+ if (options.watch && false);
13408
+ await vitest._setServer(options, server);
13409
+ if (options.api && options.watch) (await Promise.resolve().then(function () { return setup$1; })).setup(vitest);
13410
+ // #415, in run mode we don't need the watcher, close it would improve the performance
13411
+ if (!options.watch) await server.watcher.close();
13412
+ } }
13409
13413
  },
13410
13414
  MetaEnvReplacerPlugin(),
13411
13415
  ...CSSEnablerPlugin(vitest),
@@ -13900,4 +13904,4 @@ var cliApi = /*#__PURE__*/Object.freeze({
13900
13904
  startVitest: startVitest
13901
13905
  });
13902
13906
 
13903
- export { FilesNotFoundError as F, GitNotFoundError as G, ThreadsPoolWorker as T, Vitest as V, VitestPlugin as a, VitestPackageInstaller as b, createVitest as c, createMethodsRPC as d, escapeTestName as e, ForksPoolWorker as f, getFilePoolName as g, TypecheckPoolWorker as h, isValidApiRequest as i, VmForksPoolWorker as j, VmThreadsPoolWorker as k, experimental_getRunnerTask as l, registerConsoleShortcuts as m, isFileServingAllowed as n, createViteLogger as o, createDebugger as p, cliApi as q, resolveFsAllow as r, startVitest as s };
13907
+ export { ForksPoolWorker as F, GitNotFoundError as G, ThreadsPoolWorker as T, Vitest as V, VitestPlugin as a, FilesNotFoundError as b, TypecheckPoolWorker as c, VitestPackageInstaller as d, VmForksPoolWorker as e, VmThreadsPoolWorker as f, createDebugger as g, createMethodsRPC as h, createViteLogger as i, createVitest as j, escapeTestName as k, experimental_getRunnerTask as l, getFilePoolName as m, isFileServingAllowed as n, isValidApiRequest as o, resolveFsAllow as p, cliApi as q, registerConsoleShortcuts as r, startVitest as s };
@@ -137,6 +137,10 @@ interface SerializedConfig {
137
137
  showDiff?: boolean;
138
138
  truncateThreshold?: number;
139
139
  } | undefined;
140
+ api: {
141
+ allowExec: boolean | undefined;
142
+ allowWrite: boolean | undefined;
143
+ };
140
144
  diff: string | SerializedDiffOptions | undefined;
141
145
  retry: SerializableRetry;
142
146
  includeTaskLocation: boolean | undefined;
@@ -169,6 +173,7 @@ interface SerializedConfig {
169
173
  };
170
174
  trace: BrowserTraceViewMode;
171
175
  trackUnhandledErrors: boolean;
176
+ detailsPanelPosition: "right" | "bottom";
172
177
  };
173
178
  standalone: boolean;
174
179
  logHeapUsage: boolean | undefined;
@@ -179,7 +184,15 @@ interface SerializedConfig {
179
184
  serializedDefines: string;
180
185
  experimental: {
181
186
  fsModuleCache: boolean;
182
- printImportBreakdown: boolean | undefined;
187
+ importDurations: {
188
+ print: boolean | "on-warn";
189
+ limit: number;
190
+ failOnDanger: boolean;
191
+ thresholds: {
192
+ warn: number;
193
+ danger: number;
194
+ };
195
+ };
183
196
  viteModuleRunner: boolean;
184
197
  nodeLoader: boolean;
185
198
  openTelemetry: {
@@ -30,7 +30,9 @@ const globalApis = [
30
30
  "beforeEach",
31
31
  "afterEach",
32
32
  "onTestFinished",
33
- "onTestFailed"
33
+ "onTestFailed",
34
+ "aroundEach",
35
+ "aroundAll"
34
36
  ];
35
37
 
36
38
  export { API_PATH as A, defaultInspectPort as a, defaultPort as b, configFiles as c, defaultBrowserPort as d, globalApis as g };
@@ -11,7 +11,7 @@ import { c as configDefaults, e as benchmarkConfigDefaults, a as coverageConfigD
11
11
  import crypto from 'node:crypto';
12
12
  import { r as resolveModule } from './index.BCY_7LL2.js';
13
13
  import { mergeConfig } from 'vite';
14
- import { c as configFiles, d as defaultBrowserPort, a as defaultInspectPort, b as defaultPort } from './constants.B63TT-Bl.js';
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
17
  import { isCI, provider } from 'std-env';
@@ -108,7 +108,10 @@ function parseInspector(inspect) {
108
108
  port: Number(port) || defaultInspectPort
109
109
  };
110
110
  }
111
- function resolveApiServerConfig(options, defaultPort) {
111
+ /**
112
+ * @deprecated Internal function
113
+ */
114
+ function resolveApiServerConfig(options, defaultPort, parentApi, logger) {
112
115
  let api;
113
116
  if (options.ui && !options.api) api = { port: defaultPort };
114
117
  else if (options.api === true) api = { port: defaultPort };
@@ -121,6 +124,18 @@ function resolveApiServerConfig(options, defaultPort) {
121
124
  if (api) {
122
125
  if (!api.port && !api.middlewareMode) api.port = defaultPort;
123
126
  } else api = { middlewareMode: true };
127
+ // if the API server is exposed to network, disable write operations by default
128
+ if (!api.middlewareMode && api.host && api.host !== "localhost" && api.host !== "127.0.0.1") {
129
+ // assigned to browser
130
+ if (parentApi) {
131
+ if (api.allowWrite == null && api.allowExec == null) logger?.error(c.yellow(`${c.yellowBright(" WARNING ")} API server is exposed to network, disabling write and exec operations by default for security reasons. This can cause some APIs to not work as expected. Set \`browser.api.allowExec\` manually to hide this warning. See https://vitest.dev/config/browser/api for more details.`));
132
+ }
133
+ api.allowWrite ??= parentApi?.allowWrite ?? false;
134
+ api.allowExec ??= parentApi?.allowExec ?? false;
135
+ } else {
136
+ api.allowWrite ??= parentApi?.allowWrite ?? true;
137
+ api.allowExec ??= parentApi?.allowExec ?? true;
138
+ }
124
139
  return api;
125
140
  }
126
141
  function resolveInlineWorkerOption(value) {
@@ -317,7 +332,7 @@ function resolveConfig$1(vitest, options, viteConfig) {
317
332
  resolved.snapshotOptions = {
318
333
  expand: resolved.expandSnapshotDiff ?? false,
319
334
  snapshotFormat: resolved.snapshotFormat || {},
320
- updateSnapshot: isCI && !UPDATE_SNAPSHOT ? "none" : UPDATE_SNAPSHOT ? "all" : "new",
335
+ updateSnapshot: UPDATE_SNAPSHOT === "all" || UPDATE_SNAPSHOT === "new" ? UPDATE_SNAPSHOT : isCI && !UPDATE_SNAPSHOT ? "none" : UPDATE_SNAPSHOT ? "all" : "new",
321
336
  resolveSnapshotPath: options.resolveSnapshotPath,
322
337
  snapshotEnvironment: null
323
338
  };
@@ -438,11 +453,13 @@ function resolveConfig$1(vitest, options, viteConfig) {
438
453
  if (resolved.typecheck.enabled) logger.console.warn(c.yellow("Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
439
454
  resolved.browser.enabled ??= false;
440
455
  resolved.browser.headless ??= isCI;
456
+ if (resolved.browser.isolate) logger.console.warn(c.yellow("`browser.isolate` is deprecated. Use top-level `isolate` instead."));
441
457
  resolved.browser.isolate ??= resolved.isolate ?? true;
442
458
  resolved.browser.fileParallelism ??= options.fileParallelism ?? mode !== "benchmark";
443
459
  // disable in headless mode by default, and if CI is detected
444
460
  resolved.browser.ui ??= resolved.browser.headless === true ? false : !isCI;
445
461
  resolved.browser.commands ??= {};
462
+ resolved.browser.detailsPanelPosition ??= "right";
446
463
  if (resolved.browser.screenshotDirectory) resolved.browser.screenshotDirectory = resolve(resolved.root, resolved.browser.screenshotDirectory);
447
464
  if (resolved.inspector.enabled) resolved.browser.trackUnhandledErrors ??= false;
448
465
  resolved.browser.viewport ??= {};
@@ -465,7 +482,7 @@ function resolveConfig$1(vitest, options, viteConfig) {
465
482
  resolved.browser.screenshotFailures = false;
466
483
  } else resolved.browser.screenshotFailures ??= !isPreview && !resolved.browser.ui;
467
484
  if (resolved.browser.provider && resolved.browser.provider.options == null) resolved.browser.provider.options = {};
468
- resolved.browser.api = resolveApiServerConfig(resolved.browser, defaultBrowserPort) || { port: defaultBrowserPort };
485
+ resolved.browser.api = resolveApiServerConfig(resolved.browser, defaultBrowserPort, resolved.api, logger) || { port: defaultBrowserPort };
469
486
  // enable includeTaskLocation by default in UI mode
470
487
  if (resolved.browser.enabled) {
471
488
  if (resolved.browser.ui) resolved.includeTaskLocation ??= true;
@@ -494,6 +511,16 @@ function resolveConfig$1(vitest, options, viteConfig) {
494
511
  resolved.experimental.openTelemetry.browserSdkPath = browserSdkPath;
495
512
  }
496
513
  if (resolved.experimental.fsModuleCachePath) resolved.experimental.fsModuleCachePath = resolve(resolved.root, resolved.experimental.fsModuleCachePath);
514
+ resolved.experimental.importDurations ??= {};
515
+ resolved.experimental.importDurations.print ??= false;
516
+ resolved.experimental.importDurations.failOnDanger ??= false;
517
+ if (resolved.experimental.importDurations.limit == null) {
518
+ const shouldCollect = resolved.experimental.importDurations.print || resolved.experimental.importDurations.failOnDanger || resolved.ui;
519
+ resolved.experimental.importDurations.limit = shouldCollect ? 10 : 0;
520
+ }
521
+ resolved.experimental.importDurations.thresholds ??= {};
522
+ resolved.experimental.importDurations.thresholds.warn ??= 100;
523
+ resolved.experimental.importDurations.thresholds.danger ??= 500;
497
524
  return resolved;
498
525
  }
499
526
  function isBrowserEnabled(config) {
@@ -998,4 +1025,4 @@ function resolveMergeConfig(mod) {
998
1025
  }
999
1026
  }
1000
1027
 
1001
- export { BaseCoverageProvider as B, RandomSequencer as R, resolveApiServerConfig as a, BaseSequencer as b, getCoverageProvider as g, hash as h, isBrowserEnabled as i, resolveConfig$1 as r };
1028
+ export { BaseCoverageProvider as B, RandomSequencer as R, BaseSequencer as a, resolveApiServerConfig as b, getCoverageProvider as g, hash as h, isBrowserEnabled as i, resolveConfig$1 as r };
@@ -1,11 +1,11 @@
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.D3XRDfWc.js';
5
- import { p as prompt, a as any } from './index.D4KonVSU.js';
4
+ import { detectPackageManager, installPackage } from './index.CMESou6r.js';
5
+ import { p as prompt, a as any } from './index.og1WyBLx.js';
6
6
  import { x } from 'tinyexec';
7
7
  import c from 'tinyrainbow';
8
- import { c as configFiles } from './constants.B63TT-Bl.js';
8
+ import { c as configFiles } from './constants.CPYnjOGj.js';
9
9
  import 'node:process';
10
10
  import 'node:module';
11
11
  import 'node:url';
@@ -2,7 +2,7 @@ import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
2
2
  import { Plugin } from '@vitest/pretty-format';
3
3
  import { SnapshotState } from '@vitest/snapshot';
4
4
  import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
5
- import { U as UserConsoleLog } from './rpc.d.CM7x9-sm.js';
5
+ import { U as UserConsoleLog } from './rpc.d.CUhiUEld.js';
6
6
 
7
7
  interface SnapshotMatcher<T> {
8
8
  <U extends { [P in keyof T] : any }>(snapshot: Partial<U>, hint?: string): void;
@@ -1,6 +1,6 @@
1
- import { g as globalApis } from './constants.B63TT-Bl.js';
2
- import { i as index } from './index.CouFDptX.js';
3
- import './test.G82XYNFk.js';
1
+ import { g as globalApis } from './constants.CPYnjOGj.js';
2
+ import { i as index } from './index.D3wDRGBz.js';
3
+ import './test.CnO2BIt2.js';
4
4
  import '@vitest/runner';
5
5
  import '@vitest/utils/helpers';
6
6
  import '@vitest/utils/timers';
@@ -1,8 +1,8 @@
1
1
  import { chai } from '@vitest/expect';
2
- import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.cvFp-ao9.js';
2
+ import { l as loadDiffConfig, a as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.BoY7R7rC.js';
3
3
  import { r as rpc } from './rpc.DcRWTy5G.js';
4
4
  import { g as getWorkerState } from './utils.DT4VyRyl.js';
5
- import { T as TestRunner, N as NodeBenchmarkRunner } from './test.G82XYNFk.js';
5
+ import { T as TestRunner, N as NodeBenchmarkRunner } from './test.CnO2BIt2.js';
6
6
 
7
7
  function setupChaiConfig(config) {
8
8
  Object.assign(chai.config, config);
@@ -209,5 +209,30 @@ async function installPackage(names, options = {}) {
209
209
  }
210
210
  );
211
211
  }
212
+ async function uninstallPackage(names, options = {}) {
213
+ const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
214
+ const [agent] = detectedAgent.split("@");
215
+ if (!Array.isArray(names))
216
+ names = [names];
217
+ const args = options.additionalArgs || [];
218
+ if (agent === "pnpm" && existsSync(resolve(options.cwd ?? process.cwd(), "pnpm-workspace.yaml")))
219
+ args.unshift("-w");
220
+ return x(
221
+ agent,
222
+ [
223
+ agent === "yarn" ? "remove" : "uninstall",
224
+ options.dev ? "-D" : "",
225
+ ...args,
226
+ ...names
227
+ ].filter(Boolean),
228
+ {
229
+ nodeOptions: {
230
+ stdio: options.silent ? "ignore" : "inherit",
231
+ cwd: options.cwd
232
+ },
233
+ throwOnError: true
234
+ }
235
+ );
236
+ }
212
237
 
213
- export { detectPackageManager, installPackage };
238
+ export { detectPackageManager, installPackage, uninstallPackage };
@@ -1,8 +1,8 @@
1
- import { N as NodeBenchmarkRunner, T as TestRunner, a as assert, c as createExpect, g as globalExpect, i as inject, s as should, v as vi, b as vitest } from './test.G82XYNFk.js';
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.CnO2BIt2.js';
2
2
  import { b as bench } from './benchmark.BoqSLF53.js';
3
3
  import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
4
4
  import { expectTypeOf } from 'expect-type';
5
- import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, recordArtifact, suite, test } from '@vitest/runner';
5
+ import { afterAll, afterEach, aroundAll, aroundEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, recordArtifact, suite, test } from '@vitest/runner';
6
6
  import { chai } from '@vitest/expect';
7
7
 
8
8
  const assertType = function assertType() {};
@@ -14,6 +14,8 @@ var index = /*#__PURE__*/Object.freeze({
14
14
  TestRunner: TestRunner,
15
15
  afterAll: afterAll,
16
16
  afterEach: afterEach,
17
+ aroundAll: aroundAll,
18
+ aroundEach: aroundEach,
17
19
  assert: assert,
18
20
  assertType: assertType,
19
21
  beforeAll: beforeAll,