vitest 3.1.2 → 3.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.
@@ -1,5 +1,5 @@
1
1
  import { ModuleCacheMap } from 'vite-node/client';
2
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.CwmnH2oH.js';
2
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.BpmIjFTD.js';
3
3
  import { p as provideWorkerState } from './utils.CgTj3MsC.js';
4
4
 
5
5
  let _viteNode;
@@ -618,7 +618,7 @@ class CAC extends EventEmitter {
618
618
 
619
619
  const cac = (name = "") => new CAC(name);
620
620
 
621
- var version = "3.1.2";
621
+ var version = "3.1.4";
622
622
 
623
623
  const apiConfig = (port) => ({
624
624
  port: {
@@ -864,10 +864,7 @@ const cliOptionsConfig = {
864
864
  return { enabled: browser === "yes" };
865
865
  }
866
866
  if (typeof browser === "string") {
867
- return {
868
- enabled: true,
869
- name: browser
870
- };
867
+ return { name: browser };
871
868
  }
872
869
  return browser;
873
870
  },
@@ -1451,9 +1448,6 @@ function normalizeCliOptions(cliFilters, argv) {
1451
1448
  if (cliFilters.some((filter) => filter.includes(":"))) {
1452
1449
  argv.includeTaskLocation ??= true;
1453
1450
  }
1454
- if (typeof argv.browser === "object" && !("enabled" in argv.browser)) {
1455
- argv.browser.enabled = true;
1456
- }
1457
1451
  if (typeof argv.typecheck?.only === "boolean") {
1458
1452
  argv.typecheck.enabled ??= true;
1459
1453
  }
@@ -1464,7 +1458,7 @@ async function start(mode, cliFilters, options) {
1464
1458
  process.title = "node (vitest)";
1465
1459
  } catch {}
1466
1460
  try {
1467
- const { startVitest } = await import('./cli-api.z029PxYZ.js').then(function (n) { return n.f; });
1461
+ const { startVitest } = await import('./cli-api.BzebkJv7.js').then(function (n) { return n.f; });
1468
1462
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1469
1463
  if (!ctx.shouldKeepServer()) {
1470
1464
  await ctx.exit();
@@ -1493,7 +1487,7 @@ async function collect(mode, cliFilters, options) {
1493
1487
  process.title = "node (vitest)";
1494
1488
  } catch {}
1495
1489
  try {
1496
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.z029PxYZ.js').then(function (n) { return n.f; });
1490
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BzebkJv7.js').then(function (n) { return n.f; });
1497
1491
  const ctx = await prepareVitest(mode, {
1498
1492
  ...normalizeCliOptions(cliFilters, options),
1499
1493
  watch: false,
@@ -11,9 +11,9 @@ import { generateFileHash, createFileTask, limitConcurrency, hasFailed, getTasks
11
11
  import { SnapshotManager } from '@vitest/snapshot/manager';
12
12
  import { ViteNodeRunner } from 'vite-node/client';
13
13
  import { ViteNodeServer } from 'vite-node/server';
14
- import { v as version$1 } from './cac.C5_4mAsf.js';
14
+ import { v as version$1 } from './cac.KrMo52r1.js';
15
15
  import { c as createBirpc } from './index.CJ0plNrh.js';
16
- import { p as parse, s as stringify, g as printError, h as generateCodeFrame, b as BenchmarkReportsMap, R as ReportersMap, i as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index._vwY_KdO.js';
16
+ import { p as parse, s as stringify, g as printError, h as generateCodeFrame, b as BenchmarkReportsMap, R as ReportersMap, i as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.De2FqGmR.js';
17
17
  import require$$0$3 from 'events';
18
18
  import require$$1$1 from 'https';
19
19
  import require$$2 from 'http';
@@ -28,7 +28,7 @@ import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
28
28
  import { parseErrorStacktrace } from '@vitest/utils/source-map';
29
29
  import crypto from 'node:crypto';
30
30
  import { distDir, rootDir } from '../path.js';
31
- import { R as RandomSequencer, i as isPackageExists, h as hash, V as VitestCache, g as getFilePoolName, d as isBrowserEnabled, m as mm, r as resolveConfig, e as groupBy, f as getCoverageProvider, j as createPool, w as wildcardPatternToRegExp, a as resolveApiServerConfig, s as stdout } from './coverage.BUdIvXbr.js';
31
+ import { R as RandomSequencer, i as isPackageExists, h as hash, V as VitestCache, g as getFilePoolName, d as isBrowserEnabled, m as mm, r as resolveConfig, e as groupBy, f as getCoverageProvider, j as createPool, w as wildcardPatternToRegExp, a as resolveApiServerConfig, s as stdout } from './coverage.D6LCUsnS.js';
32
32
  import { c as convertTasksToEvents } from './typechecker.DYQbn8uK.js';
33
33
  import { Console } from 'node:console';
34
34
  import c from 'tinyrainbow';
@@ -5252,6 +5252,7 @@ var setup$1 = /*#__PURE__*/Object.freeze({
5252
5252
 
5253
5253
  class BrowserSessions {
5254
5254
  sessions = new Map();
5255
+ sessionIds = new Set();
5255
5256
  getSession(sessionId) {
5256
5257
  return this.sessions.get(sessionId);
5257
5258
  }
@@ -6702,26 +6703,6 @@ function WorkspaceVitestPlugin(project, options) {
6702
6703
  name = options.workspacePath.toString();
6703
6704
  }
6704
6705
  }
6705
- const workspaceNames = [name];
6706
- if (viteConfig.test?.browser?.enabled) {
6707
- if (viteConfig.test.browser.name) {
6708
- const browser = viteConfig.test.browser.name;
6709
- workspaceNames.push(name ? `${name} (${browser})` : browser);
6710
- }
6711
- viteConfig.test.browser.instances?.forEach((instance) => {
6712
- instance.name ??= name ? `${name} (${instance.browser})` : instance.browser;
6713
- workspaceNames.push(instance.name);
6714
- });
6715
- }
6716
- const filters = project.vitest.config.project;
6717
- if (filters.length) {
6718
- const hasProject = workspaceNames.some((name) => {
6719
- return project.vitest.matchesProjectFilter(name);
6720
- });
6721
- if (!hasProject) {
6722
- throw new VitestFilteredOutProjectError();
6723
- }
6724
- }
6725
6706
  const resolveOptions = getDefaultResolveOptions();
6726
6707
  const config = {
6727
6708
  root,
@@ -6748,6 +6729,28 @@ function WorkspaceVitestPlugin(project, options) {
6748
6729
  test: { name }
6749
6730
  };
6750
6731
  config.test.defines = defines;
6732
+ const isUserBrowserEnabled = viteConfig.test?.browser?.enabled;
6733
+ const isBrowserEnabled = isUserBrowserEnabled ?? (viteConfig.test?.browser && project.vitest._cliOptions.browser?.enabled);
6734
+ const workspaceNames = [name];
6735
+ const browser = viteConfig.test.browser || {};
6736
+ if (isBrowserEnabled && browser.name && !browser.instances?.length) {
6737
+ workspaceNames.push(name ? `${name} (${browser.name})` : browser.name);
6738
+ }
6739
+ viteConfig.test?.browser?.instances?.forEach((instance) => {
6740
+ instance.name ??= name ? `${name} (${instance.browser})` : instance.browser;
6741
+ if (isBrowserEnabled) {
6742
+ workspaceNames.push(instance.name);
6743
+ }
6744
+ });
6745
+ const filters = project.vitest.config.project;
6746
+ if (filters.length) {
6747
+ const hasProject = workspaceNames.some((name) => {
6748
+ return project.vitest.matchesProjectFilter(name);
6749
+ });
6750
+ if (!hasProject) {
6751
+ throw new VitestFilteredOutProjectError();
6752
+ }
6753
+ }
6751
6754
  const classNameStrategy = typeof testConfig.css !== "boolean" && testConfig.css?.modules?.classNameStrategy || "stable";
6752
6755
  if (classNameStrategy !== "scoped") {
6753
6756
  config.css ??= {};
@@ -7994,6 +7997,7 @@ class StateManager {
7994
7997
  errorsSet = new Set();
7995
7998
  processTimeoutCauses = new Set();
7996
7999
  reportedTasksMap = new WeakMap();
8000
+ blobs;
7997
8001
  catchError(err, type) {
7998
8002
  if (isAggregateError(err)) {
7999
8003
  return err.errors.forEach((error) => this.catchError(error, type));
@@ -8505,8 +8509,8 @@ async function resolveBrowserWorkspace(vitest, names, resolvedProjects) {
8505
8509
  return;
8506
8510
  }
8507
8511
  const instances = project.config.browser.instances || [];
8508
- if (instances.length === 0) {
8509
- const browser = project.config.browser.name;
8512
+ const browser = project.config.browser.name;
8513
+ if (instances.length === 0 && browser) {
8510
8514
  instances.push({
8511
8515
  browser,
8512
8516
  name: project.name ? `${project.name} (${browser})` : browser
@@ -8595,7 +8599,7 @@ function cloneConfig(project, { browser,...config }) {
8595
8599
  testerHtmlPath: testerHtmlPath ?? currentConfig.testerHtmlPath,
8596
8600
  screenshotDirectory: screenshotDirectory ?? currentConfig.screenshotDirectory,
8597
8601
  screenshotFailures: screenshotFailures ?? currentConfig.screenshotFailures,
8598
- headless: project.vitest._options?.browser?.headless ?? headless ?? currentConfig.headless,
8602
+ headless: headless ?? currentConfig.headless,
8599
8603
  name: browser,
8600
8604
  providerOptions: config,
8601
8605
  instances: undefined
@@ -8755,7 +8759,7 @@ class Vitest {
8755
8759
  resolvedProjects = [];
8756
8760
  /** @internal */ _browserLastPort = defaultBrowserPort;
8757
8761
  /** @internal */ _browserSessions = new BrowserSessions();
8758
- /** @internal */ _options = {};
8762
+ /** @internal */ _cliOptions = {};
8759
8763
  /** @internal */ reporters = [];
8760
8764
  /** @internal */ vitenode = undefined;
8761
8765
  /** @internal */ runner = undefined;
@@ -8771,8 +8775,9 @@ class Vitest {
8771
8775
  _cache;
8772
8776
  _snapshot;
8773
8777
  _workspaceConfigPath;
8774
- constructor(mode, options = {}) {
8778
+ constructor(mode, cliOptions, options = {}) {
8775
8779
  this.mode = mode;
8780
+ this._cliOptions = cliOptions;
8776
8781
  this.logger = new Logger(this, options.stdout, options.stderr);
8777
8782
  this.packageInstaller = options.packageInstaller || new VitestPackageInstaller();
8778
8783
  this.specifications = new VitestSpecifications(this);
@@ -8833,12 +8838,11 @@ class Vitest {
8833
8838
  return this._cache;
8834
8839
  }
8835
8840
  /** @deprecated internal */
8836
- setServer(options, server, cliOptions) {
8837
- return this._setServer(options, server, cliOptions);
8841
+ setServer(options, server) {
8842
+ return this._setServer(options, server);
8838
8843
  }
8839
8844
  /** @internal */
8840
- async _setServer(options, server, cliOptions) {
8841
- this._options = options;
8845
+ async _setServer(options, server) {
8842
8846
  this.watcher.unregisterWatcher();
8843
8847
  clearTimeout(this._rerunTimer);
8844
8848
  this.restartsCount += 1;
@@ -8899,7 +8903,7 @@ class Vitest {
8899
8903
  try {
8900
8904
  await this.cache.results.readFromCache();
8901
8905
  } catch {}
8902
- const projects = await this.resolveWorkspace(cliOptions);
8906
+ const projects = await this.resolveWorkspace(this._cliOptions);
8903
8907
  this.resolvedProjects = projects;
8904
8908
  this.projects = projects;
8905
8909
  await Promise.all(projects.flatMap((project) => {
@@ -8910,8 +8914,19 @@ class Vitest {
8910
8914
  injectTestProjects: this.injectTestProject
8911
8915
  }));
8912
8916
  }));
8917
+ if (this._cliOptions.browser?.enabled) {
8918
+ const browserProjects = this.projects.filter((p) => p.config.browser.enabled);
8919
+ if (!browserProjects.length) {
8920
+ throw new Error(`Vitest received --browser flag, but no project had a browser configuration.`);
8921
+ }
8922
+ }
8913
8923
  if (!this.projects.length) {
8914
- throw new Error(`No projects matched the filter "${toArray(resolved.project).join("\", \"")}".`);
8924
+ const filter = toArray(resolved.project).join("\", \"");
8925
+ if (filter) {
8926
+ throw new Error(`No projects matched the filter "${filter}".`);
8927
+ } else {
8928
+ throw new Error(`Vitest wasn't able to resolve any project.`);
8929
+ }
8915
8930
  }
8916
8931
  if (!this.coreWorkspaceProject) {
8917
8932
  this.coreWorkspaceProject = TestProject._createBasicProject(this);
@@ -8929,7 +8944,7 @@ class Vitest {
8929
8944
  */
8930
8945
  injectTestProject = async (config) => {
8931
8946
  const currentNames = new Set(this.projects.map((p) => p.name));
8932
- const workspace = await resolveWorkspace(this, this._options, undefined, Array.isArray(config) ? config : [config], currentNames);
8947
+ const workspace = await resolveWorkspace(this, this._cliOptions, undefined, Array.isArray(config) ? config : [config], currentNames);
8933
8948
  this.projects.push(...workspace);
8934
8949
  return workspace;
8935
8950
  };
@@ -9047,7 +9062,13 @@ class Vitest {
9047
9062
  if (this.reporters.some((r) => r instanceof BlobReporter)) {
9048
9063
  throw new Error("Cannot merge reports when `--reporter=blob` is used. Remove blob reporter from the config first.");
9049
9064
  }
9050
- const { files, errors, coverages } = await readBlobs(this.version, directory || this.config.mergeReports, this.projects);
9065
+ const { files, errors, coverages, executionTimes } = await readBlobs(this.version, directory || this.config.mergeReports, this.projects);
9066
+ this.state.blobs = {
9067
+ files,
9068
+ errors,
9069
+ coverages,
9070
+ executionTimes
9071
+ };
9051
9072
  await this.report("onInit", this);
9052
9073
  await this.report("onPathsCollected", files.flatMap((f) => f.filepath));
9053
9074
  const specifications = [];
@@ -9246,7 +9267,9 @@ class Vitest {
9246
9267
  process.exitCode = 1;
9247
9268
  }
9248
9269
  this.cache.results.updateResults(files);
9249
- await this.cache.results.writeToCache();
9270
+ try {
9271
+ await this.cache.results.writeToCache();
9272
+ } catch {}
9250
9273
  return {
9251
9274
  testModules: this.state.getTestModules(),
9252
9275
  unhandledErrors: this.state.getUnhandledErrors()
@@ -9663,7 +9686,7 @@ class Vitest {
9663
9686
  * Check if the project with a given name should be included.
9664
9687
  */
9665
9688
  matchesProjectFilter(name) {
9666
- const projects = this._config?.project || this._options?.project;
9689
+ const projects = this._config?.project || this._cliOptions?.project;
9667
9690
  if (!projects || !projects.length) {
9668
9691
  return true;
9669
9692
  }
@@ -9679,11 +9702,11 @@ function assert(condition, property, name = property) {
9679
9702
  }
9680
9703
  }
9681
9704
 
9682
- async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
9705
+ async function VitestPlugin(options = {}, vitest = new Vitest("test", deepClone(options))) {
9683
9706
  const userConfig = deepMerge({}, options);
9684
9707
  async function UIPlugin() {
9685
- await ctx.packageInstaller.ensureInstalled("@vitest/ui", options.root || process.cwd(), ctx.version);
9686
- return (await import('@vitest/ui')).default(ctx);
9708
+ await vitest.packageInstaller.ensureInstalled("@vitest/ui", options.root || process.cwd(), vitest.version);
9709
+ return (await import('@vitest/ui')).default(vitest);
9687
9710
  }
9688
9711
  return [
9689
9712
  {
@@ -9739,10 +9762,10 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
9739
9762
  deps: testConfig.deps ?? viteConfig.test?.deps
9740
9763
  }
9741
9764
  };
9742
- if (ctx.configOverride.project) {
9743
- options.project = ctx.configOverride.project;
9765
+ if (vitest.configOverride.project) {
9766
+ options.project = vitest.configOverride.project;
9744
9767
  }
9745
- config.customLogger = createViteLogger(ctx.logger, viteConfig.logLevel || "warn", { allowClearScreen: false });
9768
+ config.customLogger = createViteLogger(vitest.logger, viteConfig.logLevel || "warn", { allowClearScreen: false });
9746
9769
  config.customLogger = silenceImportViteIgnoreWarning(config.customLogger);
9747
9770
  if (viteConfig.ssr?.noExternal !== true) {
9748
9771
  const inline = testConfig.server?.deps?.inline;
@@ -9768,7 +9791,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
9768
9791
  config.css.modules ??= {};
9769
9792
  if (config.css.modules) {
9770
9793
  config.css.modules.generateScopedName = (name, filename) => {
9771
- const root = ctx.config.root || options.root || process.cwd();
9794
+ const root = vitest.config.root || options.root || process.cwd();
9772
9795
  return generateScopedClassName(classNameStrategy, name, relative(root, filename));
9773
9796
  };
9774
9797
  }
@@ -9800,7 +9823,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
9800
9823
  configurable: true
9801
9824
  });
9802
9825
  const originalName = options.name;
9803
- if (options.browser?.enabled && options.browser?.instances) {
9826
+ if (options.browser?.instances) {
9804
9827
  options.browser.instances.forEach((instance) => {
9805
9828
  instance.name ??= originalName ? `${originalName} (${instance.browser})` : instance.browser;
9806
9829
  });
@@ -9814,9 +9837,9 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
9814
9837
  console.log("[debug] watcher is ready");
9815
9838
  });
9816
9839
  }
9817
- await ctx._setServer(options, server, userConfig);
9840
+ await vitest._setServer(options, server);
9818
9841
  if (options.api && options.watch) {
9819
- (await Promise.resolve().then(function () { return setup$1; })).setup(ctx);
9842
+ (await Promise.resolve().then(function () { return setup$1; })).setup(vitest);
9820
9843
  }
9821
9844
  if (!options.watch) {
9822
9845
  await server.watcher.close();
@@ -9825,9 +9848,9 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
9825
9848
  }
9826
9849
  },
9827
9850
  SsrReplacerPlugin(),
9828
- ...CSSEnablerPlugin(ctx),
9829
- CoverageTransform(ctx),
9830
- VitestCoreResolver(ctx),
9851
+ ...CSSEnablerPlugin(vitest),
9852
+ CoverageTransform(vitest),
9853
+ VitestCoreResolver(vitest),
9831
9854
  options.ui ? await UIPlugin() : null,
9832
9855
  ...MocksPlugins(),
9833
9856
  VitestOptimizer(),
@@ -9844,15 +9867,16 @@ function removeUndefinedValues(obj) {
9844
9867
  }
9845
9868
 
9846
9869
  async function createVitest(mode, options, viteOverrides = {}, vitestOptions = {}) {
9847
- const ctx = new Vitest(mode, vitestOptions);
9870
+ const ctx = new Vitest(mode, deepClone(options), vitestOptions);
9848
9871
  const root = slash(resolve$1(options.root || process.cwd()));
9849
9872
  const configPath = options.config === false ? false : options.config ? resolve$1(root, options.config) : await findUp(configFiles, { cwd: root });
9850
9873
  options.config = configPath;
9874
+ const { browser: _removeBrowser,...restOptions } = options;
9851
9875
  const config = {
9852
9876
  configFile: configPath,
9853
9877
  configLoader: options.configLoader,
9854
9878
  mode: options.mode || mode,
9855
- plugins: await VitestPlugin(options, ctx)
9879
+ plugins: await VitestPlugin(restOptions, ctx)
9856
9880
  };
9857
9881
  const server = await createViteServer(mergeConfig(config, mergeConfig(viteOverrides, { root: options.root })));
9858
9882
  if (ctx.config.api?.port) {
@@ -15,12 +15,12 @@ import { fileURLToPath as fileURLToPath$1, pathToFileURL as pathToFileURL$1, URL
15
15
  import assert from 'node:assert';
16
16
  import v8 from 'node:v8';
17
17
  import { format, inspect } from 'node:util';
18
+ import { version, mergeConfig } from 'vite';
18
19
  import { e as extraInlineDeps, d as defaultBrowserPort, b as defaultInspectPort, a as defaultPort } from './constants.BZZyIeIE.js';
19
20
  import { a as isWindows } from './env.Dq0hM4Xv.js';
20
21
  import * as nodeos from 'node:os';
21
22
  import nodeos__default from 'node:os';
22
23
  import { isatty } from 'node:tty';
23
- import { version } from 'vite';
24
24
  import EventEmitter from 'node:events';
25
25
  import { c as createBirpc } from './index.CJ0plNrh.js';
26
26
  import Tinypool$1, { Tinypool } from 'tinypool';
@@ -7913,7 +7913,6 @@ function resolveConfig$1(vitest, options, viteConfig) {
7913
7913
  if (resolved.minWorkers) {
7914
7914
  resolved.minWorkers = resolveInlineWorkerOption(resolved.minWorkers);
7915
7915
  }
7916
- resolved.browser ??= {};
7917
7916
  resolved.fileParallelism ??= mode !== "benchmark";
7918
7917
  if (!resolved.fileParallelism) {
7919
7918
  resolved.maxWorkers = 1;
@@ -7931,18 +7930,21 @@ function resolveConfig$1(vitest, options, viteConfig) {
7931
7930
  throw new Error(`You cannot use ${inspectOption} without "--no-file-parallelism", "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
7932
7931
  }
7933
7932
  }
7933
+ if (vitest._cliOptions.browser && resolved.browser && (resolved.browser.enabled !== false || vitest._cliOptions.browser.enabled)) {
7934
+ resolved.browser = mergeConfig(resolved.browser, vitest._cliOptions.browser);
7935
+ }
7936
+ resolved.browser ??= {};
7934
7937
  const browser = resolved.browser;
7935
7938
  if (browser.enabled) {
7936
7939
  if (!browser.name && !browser.instances) {
7937
- browser.enabled = false;
7938
- } else {
7939
- const instances = browser.instances;
7940
- if (browser.name && browser.instances) {
7941
- browser.instances = browser.instances.filter((instance) => instance.browser === browser.name);
7942
- }
7943
- if (browser.instances && !browser.instances.length) {
7944
- throw new Error([`"browser.instances" was set in the config, but the array is empty. Define at least one browser config.`, browser.name && instances?.length ? ` The "browser.name" was set to "${browser.name}" which filtered all configs (${instances.map((c) => c.browser).join(", ")}). Did you mean to use another name?` : ""].join(""));
7945
- }
7940
+ throw new Error(`Vitest Browser Mode requires "browser.name" (deprecated) or "browser.instances" options, none were set.`);
7941
+ }
7942
+ const instances = browser.instances;
7943
+ if (browser.name && browser.instances) {
7944
+ browser.instances = browser.instances.filter((instance) => instance.browser === browser.name);
7945
+ }
7946
+ if (browser.instances && !browser.instances.length) {
7947
+ throw new Error([`"browser.instances" was set in the config, but the array is empty. Define at least one browser config.`, browser.name && instances?.length ? ` The "browser.name" was set to "${browser.name}" which filtered all configs (${instances.map((c) => c.browser).join(", ")}). Did you mean to use another name?` : ""].join(""));
7946
7948
  }
7947
7949
  }
7948
7950
  const playwrightChromiumOnly = isPlaywrightChromiumOnly(vitest, resolved);
@@ -8277,7 +8279,6 @@ function resolveConfig$1(vitest, options, viteConfig) {
8277
8279
  if (resolved.typecheck.enabled) {
8278
8280
  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."));
8279
8281
  }
8280
- resolved.browser ??= {};
8281
8282
  resolved.browser.enabled ??= false;
8282
8283
  resolved.browser.headless ??= isCI;
8283
8284
  resolved.browser.isolate ??= true;
@@ -573,6 +573,25 @@ function listenForErrors(state) {
573
573
  process.off("unhandledRejection", unhandledRejection);
574
574
  });
575
575
  }
576
+ const relativeIds = {};
577
+ function getVitestImport(id, state) {
578
+ if (externalizeMap.has(id)) {
579
+ return { externalize: externalizeMap.get(id) };
580
+ }
581
+ const root = state().config.root;
582
+ const relativeRoot = relativeIds[root] ?? (relativeIds[root] = normalizedDistDir.slice(root.length));
583
+ if (id.includes(distDir) || id.includes(normalizedDistDir) || relativeRoot && relativeRoot !== "/" && id.startsWith(relativeRoot)) {
584
+ const { path } = toFilePath(id, root);
585
+ const externalize = pathToFileURL(path).toString();
586
+ externalizeMap.set(id, externalize);
587
+ return { externalize };
588
+ }
589
+ if (bareVitestRegexp.test(id)) {
590
+ externalizeMap.set(id, id);
591
+ return { externalize: id };
592
+ }
593
+ return null;
594
+ }
576
595
  async function startVitestExecutor(options) {
577
596
  const state = () => globalThis.__vitest_worker__ || options.state;
578
597
  const rpc = () => state().rpc;
@@ -585,18 +604,9 @@ async function startVitestExecutor(options) {
585
604
  };
586
605
  return await createVitestExecutor({
587
606
  async fetchModule(id) {
588
- if (externalizeMap.has(id)) {
589
- return { externalize: externalizeMap.get(id) };
590
- }
591
- if (id.includes(distDir) || id.includes(normalizedDistDir)) {
592
- const { path } = toFilePath(id, state().config.root);
593
- const externalize = pathToFileURL(path).toString();
594
- externalizeMap.set(id, externalize);
595
- return { externalize };
596
- }
597
- if (bareVitestRegexp.test(id)) {
598
- externalizeMap.set(id, id);
599
- return { externalize: id };
607
+ const vitest = getVitestImport(id, state);
608
+ if (vitest) {
609
+ return vitest;
600
610
  }
601
611
  const result = await rpc().fetch(id, getTransformMode());
602
612
  if (result.id && !result.externalize) {
@@ -10,7 +10,7 @@ import { performance as performance$1 } from 'node:perf_hooks';
10
10
  import { parseErrorStacktrace, parseStacktrace } from '@vitest/utils/source-map';
11
11
  import { i as isTTY } from './env.Dq0hM4Xv.js';
12
12
  import { T as TypeCheckError, g as getOutputFile, h as hasFailedSnapshot } from './typechecker.DYQbn8uK.js';
13
- import { mkdir, writeFile, readdir, stat, readFile } from 'node:fs/promises';
13
+ import { readdir, stat, readFile, mkdir, writeFile } from 'node:fs/promises';
14
14
  import { Console } from 'node:console';
15
15
  import { Writable } from 'node:stream';
16
16
  import { createRequire } from 'node:module';
@@ -406,6 +406,7 @@ function lineNo(no = "") {
406
406
  }
407
407
 
408
408
  class BlobReporter {
409
+ start = 0;
409
410
  ctx;
410
411
  options;
411
412
  constructor(options) {
@@ -416,8 +417,10 @@ class BlobReporter {
416
417
  throw new Error("Blob reporter is not supported in watch mode");
417
418
  }
418
419
  this.ctx = ctx;
420
+ this.start = performance.now();
419
421
  }
420
422
  async onFinished(files = [], errors = [], coverage) {
423
+ const executionTime = performance.now() - this.start;
421
424
  let outputFile = this.options.outputFile ?? getOutputFile(this.ctx.config, "blob");
422
425
  if (!outputFile) {
423
426
  const shard = this.ctx.config.shard;
@@ -435,22 +438,27 @@ class BlobReporter {
435
438
  ];
436
439
  }).filter((x) => x != null)];
437
440
  });
438
- const report = stringify([
441
+ const report = [
439
442
  this.ctx.version,
440
443
  files,
441
444
  errors,
442
445
  modules,
443
- coverage
444
- ]);
446
+ coverage,
447
+ executionTime
448
+ ];
445
449
  const reportFile = resolve(this.ctx.config.root, outputFile);
446
- const dir = dirname(reportFile);
447
- if (!existsSync(dir)) {
448
- await mkdir(dir, { recursive: true });
449
- }
450
- await writeFile(reportFile, report, "utf-8");
450
+ await writeBlob(report, reportFile);
451
451
  this.ctx.logger.log("blob report written to", reportFile);
452
452
  }
453
453
  }
454
+ async function writeBlob(content, filename) {
455
+ const report = stringify(content);
456
+ const dir = dirname(filename);
457
+ if (!existsSync(dir)) {
458
+ await mkdir(dir, { recursive: true });
459
+ }
460
+ await writeFile(filename, report, "utf-8");
461
+ }
454
462
  async function readBlobs(currentVersion, blobsDirectory, projectsArray) {
455
463
  const resolvedDir = resolve(process.cwd(), blobsDirectory);
456
464
  const blobsFiles = await readdir(resolvedDir);
@@ -461,7 +469,7 @@ async function readBlobs(currentVersion, blobsDirectory, projectsArray) {
461
469
  throw new TypeError(`vitest.mergeReports() expects all paths in "${blobsDirectory}" to be files generated by the blob reporter, but "${filename}" is not a file`);
462
470
  }
463
471
  const content = await readFile(fullPath, "utf-8");
464
- const [version, files, errors, moduleKeys, coverage] = parse(content);
472
+ const [version, files, errors, moduleKeys, coverage, executionTime] = parse(content);
465
473
  if (!version) {
466
474
  throw new TypeError(`vitest.mergeReports() expects all paths in "${blobsDirectory}" to be files generated by the blob reporter, but "${filename}" is not a valid blob file`);
467
475
  }
@@ -471,7 +479,8 @@ async function readBlobs(currentVersion, blobsDirectory, projectsArray) {
471
479
  errors,
472
480
  moduleKeys,
473
481
  coverage,
474
- file: filename
482
+ file: filename,
483
+ executionTime
475
484
  };
476
485
  });
477
486
  const blobs = await Promise.all(promises);
@@ -507,10 +516,12 @@ async function readBlobs(currentVersion, blobsDirectory, projectsArray) {
507
516
  });
508
517
  const errors = blobs.flatMap((blob) => blob.errors);
509
518
  const coverages = blobs.map((blob) => blob.coverage);
519
+ const executionTimes = blobs.map((blob) => blob.executionTime);
510
520
  return {
511
521
  files,
512
522
  errors,
513
- coverages
523
+ coverages,
524
+ executionTimes
514
525
  };
515
526
  }
516
527
 
@@ -829,7 +840,8 @@ class BaseReporter {
829
840
  if (this.watchFilters) {
830
841
  this.log(padSummaryTitle("Duration"), formatTime(collectTime + testsTime + setupTime));
831
842
  } else {
832
- const executionTime = this.end - this.start;
843
+ const blobs = this.ctx.state.blobs;
844
+ const executionTime = blobs?.executionTimes ? sum(blobs.executionTimes, (time) => time) : this.end - this.start;
833
845
  const environmentTime = sum(files, (file) => file.environmentLoad);
834
846
  const prepareTime = sum(files, (file) => file.prepareDuration);
835
847
  const transformTime = sum(this.ctx.projects, (project) => project.vitenode.getTotalDuration());
@@ -844,6 +856,9 @@ class BaseReporter {
844
856
  typecheck && `typecheck ${formatTime(typecheck)}`
845
857
  ].filter(Boolean).join(", ");
846
858
  this.log(padSummaryTitle("Duration"), formatTime(executionTime) + c.dim(` (${timers})`));
859
+ if (blobs?.executionTimes) {
860
+ this.log(padSummaryTitle("Per blob") + blobs.executionTimes.map((time) => ` ${formatTime(time)}`).join(""));
861
+ }
847
862
  }
848
863
  this.log();
849
864
  }
@@ -683,12 +683,19 @@ interface BlobOptions {
683
683
  outputFile?: string;
684
684
  }
685
685
  declare class BlobReporter implements Reporter {
686
+ start: number;
686
687
  ctx: Vitest;
687
688
  options: BlobOptions;
688
689
  constructor(options: BlobOptions);
689
690
  onInit(ctx: Vitest): void;
690
691
  onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
691
692
  }
693
+ interface MergedBlobs {
694
+ files: File[];
695
+ errors: unknown[];
696
+ coverages: unknown[];
697
+ executionTimes: number[];
698
+ }
692
699
 
693
700
  interface DefaultReporterOptions extends BaseOptions {
694
701
  summary?: boolean;
@@ -2741,6 +2748,7 @@ declare class StateManager {
2741
2748
  errorsSet: Set<unknown>;
2742
2749
  processTimeoutCauses: Set<string>;
2743
2750
  reportedTasksMap: WeakMap<Task, TestModule | TestCase | TestSuite>;
2751
+ blobs?: MergedBlobs;
2744
2752
  catchError(err: unknown, type: string): void;
2745
2753
  clearErrors(): void;
2746
2754
  getUnhandledErrors(): unknown[];
@@ -2814,7 +2822,7 @@ declare class Vitest {
2814
2822
  private _cache?;
2815
2823
  private _snapshot?;
2816
2824
  private _workspaceConfigPath?;
2817
- constructor(mode: VitestRunMode, options?: VitestOptions);
2825
+ constructor(mode: VitestRunMode, cliOptions: UserConfig, options?: VitestOptions);
2818
2826
  private _onRestartListeners;
2819
2827
  private _onClose;
2820
2828
  private _onSetServer;
@@ -2849,7 +2857,7 @@ declare class Vitest {
2849
2857
  */
2850
2858
  get cache(): VitestCache;
2851
2859
  /** @deprecated internal */
2852
- setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
2860
+ setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
2853
2861
  /**
2854
2862
  * Inject new test projects into the workspace.
2855
2863
  * @param config Glob, config path or a custom config options.
@@ -1,5 +1,5 @@
1
1
  import { HookHandler } from 'vite';
2
- import { V as Vitest, T as TestProject, b as TestProjectConfiguration, I as InlineConfig } from './reporters.d.79o4mouw.js';
2
+ import { V as Vitest, T as TestProject, b as TestProjectConfiguration, I as InlineConfig } from './reporters.d.C-cu31ET.js';
3
3
 
4
4
  interface VitestPluginContext {
5
5
  vitest: Vitest;
@@ -3,7 +3,7 @@ import vm, { isContext } from 'node:vm';
3
3
  import { dirname, basename, extname, normalize, join, resolve } from 'pathe';
4
4
  import { distDir } from '../path.js';
5
5
  import { createCustomConsole } from './console.K1NMVOSc.js';
6
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.CwmnH2oH.js';
6
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.BpmIjFTD.js';
7
7
  import fs from 'node:fs';
8
8
  import { dirname as dirname$1 } from 'node:path';
9
9
  import { isPrimitive, isNodeBuiltin, toArray, getCachedData, setCacheData, isBareImport } from 'vite-node/utils';
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createCLI } from './chunks/cac.C5_4mAsf.js';
1
+ import { c as createCLI } from './chunks/cac.KrMo52r1.js';
2
2
  import '@vitest/utils';
3
3
  import 'events';
4
4
  import 'pathe';
package/dist/config.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';
3
- import { c as CoverageV8Options, R as ResolvedCoverageOptions, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport, b as TestProjectConfiguration } from './chunks/reporters.d.79o4mouw.js';
4
- export { f as TestProjectInlineConfiguration, W as WorkspaceProjectConfiguration } from './chunks/reporters.d.79o4mouw.js';
5
- import './chunks/vite.d.BVr6Nvdj.js';
3
+ import { c as CoverageV8Options, R as ResolvedCoverageOptions, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport, b as TestProjectConfiguration } from './chunks/reporters.d.C-cu31ET.js';
4
+ export { f as TestProjectInlineConfiguration, W as WorkspaceProjectConfiguration } from './chunks/reporters.d.C-cu31ET.js';
5
+ import './chunks/vite.d.iXCEVtFP.js';
6
6
  import { F as FakeTimerInstallOpts } from './chunks/config.d.UqE-KR0o.js';
7
7
  import '@vitest/runner';
8
8
  import './chunks/environment.d.Dmw5ulng.js';
@@ -1,4 +1,4 @@
1
- import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, a as ReportContext } from './chunks/reporters.d.79o4mouw.js';
1
+ import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, a as ReportContext } from './chunks/reporters.d.C-cu31ET.js';
2
2
  import { TransformResult } from 'vite';
3
3
  import { A as AfterSuiteRunMeta } from './chunks/environment.d.Dmw5ulng.js';
4
4
  import '@vitest/runner';
package/dist/coverage.js CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BaseCoverageProvider } from './chunks/coverage.BUdIvXbr.js';
1
+ export { B as BaseCoverageProvider } from './chunks/coverage.D6LCUsnS.js';
2
2
  import 'node:fs';
3
3
  import './chunks/_commonjsHelpers.BFTU3MAI.js';
4
4
  import 'util';
@@ -19,9 +19,9 @@ import 'node:url';
19
19
  import 'node:assert';
20
20
  import 'node:v8';
21
21
  import 'node:util';
22
+ import 'vite';
22
23
  import './chunks/constants.BZZyIeIE.js';
23
24
  import 'node:tty';
24
- import 'vite';
25
25
  import 'node:events';
26
26
  import './chunks/index.CJ0plNrh.js';
27
27
  import 'tinypool';
package/dist/execute.js CHANGED
@@ -1,4 +1,4 @@
1
- export { V as VitestExecutor } from './chunks/execute.CwmnH2oH.js';
1
+ export { V as VitestExecutor } from './chunks/execute.BpmIjFTD.js';
2
2
  import 'node:fs';
3
3
  import 'node:url';
4
4
  import 'node:vm';
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { File as File$1, TaskResultPack as TaskResultPack$1, TaskEventPack, TaskPopulated, Suite as Suite$1, Test as Test$1, Custom as Custom$1, Task as Task$1, TaskBase as TaskBase$1, TaskResult as TaskResult$1, DoneCallback as DoneCallback$1, RuntimeContext as RuntimeContext$1, SuiteHooks as SuiteHooks$1, SequenceHooks as SequenceHooks$1, SequenceSetupFiles as SequenceSetupFiles$1 } from '@vitest/runner';
2
2
  export { CancelReason, ExtendedContext, HookCleanupCallback, HookListener, OnTestFailedHandler, OnTestFinishedHandler, RunMode, Custom as RunnerCustomCase, Task as RunnerTask, TaskBase as RunnerTaskBase, TaskEventPack as RunnerTaskEventPack, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SuiteAPI, SuiteCollector, SuiteFactory, TaskContext, TaskCustomOptions, TaskMeta, TaskState, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
3
- import { S as SerializedTestSpecification, g as CoverageProvider$1, a as ReportContext$1, h as CoverageProviderModule$1, i as CoverageReporter$1, j as CoverageProviderName, k as CoverageOptions$1, R as ResolvedCoverageOptions$1, B as BaseCoverageOptions$1, l as CoverageIstanbulOptions$1, c as CoverageV8Options$1, m as CustomProviderOptions$1, n as Reporter$1, V as Vitest$1, o as BrowserScript$1, p as BrowserConfigOptions$1, q as BuiltinEnvironment$1, r as VitestEnvironment$1, P as Pool$1, s as PoolOptions$1, t as CSSModuleScopeStrategy$1, A as ApiConfig$1, u as VitestRunMode$1, D as DepsOptimizationOptions$1, v as TransformModePatterns$1, I as InlineConfig$1, w as TypecheckConfig$1, x as UserConfig$1, y as ResolvedConfig$1, z as ProjectConfig$1, U as UserWorkspaceConfig$1, E as BenchmarkUserOptions$1 } from './chunks/reporters.d.79o4mouw.js';
4
- export { F as BrowserTesterOptions } from './chunks/reporters.d.79o4mouw.js';
3
+ import { S as SerializedTestSpecification, g as CoverageProvider$1, a as ReportContext$1, h as CoverageProviderModule$1, i as CoverageReporter$1, j as CoverageProviderName, k as CoverageOptions$1, R as ResolvedCoverageOptions$1, B as BaseCoverageOptions$1, l as CoverageIstanbulOptions$1, c as CoverageV8Options$1, m as CustomProviderOptions$1, n as Reporter$1, V as Vitest$1, o as BrowserScript$1, p as BrowserConfigOptions$1, q as BuiltinEnvironment$1, r as VitestEnvironment$1, P as Pool$1, s as PoolOptions$1, t as CSSModuleScopeStrategy$1, A as ApiConfig$1, u as VitestRunMode$1, D as DepsOptimizationOptions$1, v as TransformModePatterns$1, I as InlineConfig$1, w as TypecheckConfig$1, x as UserConfig$1, y as ResolvedConfig$1, z as ProjectConfig$1, U as UserWorkspaceConfig$1, E as BenchmarkUserOptions$1 } from './chunks/reporters.d.C-cu31ET.js';
4
+ export { F as BrowserTesterOptions } from './chunks/reporters.d.C-cu31ET.js';
5
5
  import { W as WorkerContext$1 } from './chunks/worker.d.C-KN07Ls.js';
6
6
  import { R as RawErrsMap$1, T as TscErrorInfo$1, C as CollectLineNumbers$1, a as CollectLines$1, b as RootAndTarget$1, c as Context$1 } from './chunks/global.d.CXRAxnWc.js';
7
7
  import { b as Awaitable$1, U as UserConsoleLog, M as ModuleGraphData, P as ProvidedContext, N as Nullable$1, c as Arrayable$1, d as ArgumentsType$1, e as MutableArray$1, C as Constructable$1, a as EnvironmentReturn$1, V as VmEnvironmentReturn$1, E as Environment$1, R as ResolvedTestEnvironment$1, J as JSDOMOptions$1, H as HappyDOMOptions$1, f as EnvironmentOptions$1 } from './chunks/environment.d.Dmw5ulng.js';
8
8
  export { A as AfterSuiteRunMeta, g as ModuleCache } from './chunks/environment.d.Dmw5ulng.js';
9
9
  import { a as BirpcReturn, b as WorkerRPC$1 } from './chunks/worker.d.CHGSOG0s.js';
10
10
  export { C as ContextRPC, d as ContextTestEnvironment, e as ResolveIdFunction, c as RunnerRPC, R as RuntimeRPC, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.CHGSOG0s.js';
11
- import './chunks/vite.d.BVr6Nvdj.js';
11
+ import './chunks/vite.d.iXCEVtFP.js';
12
12
  import { a as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.UqE-KR0o.js';
13
13
  export { b as RuntimeConfig, S as SerializedCoverageConfig } from './chunks/config.d.UqE-KR0o.js';
14
14
  import { ExpectStatic } from '@vitest/expect';
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { y as ResolvedConfig, x as UserConfig, u as VitestRunMode, G as VitestOptions, V as Vitest, A as ApiConfig, T as TestProject, H as TestSequencer, J as TestSpecification, L as Logger, K as TestModule, M as ModuleDiagnostic } from './chunks/reporters.d.79o4mouw.js';
2
- export { B as BaseCoverageOptions, E as BenchmarkUserOptions, af as BrowserBuiltinProvider, ag as BrowserCommand, ah as BrowserCommandContext, p as BrowserConfigOptions, ai as BrowserInstanceOption, aj as BrowserModuleMocker, ak as BrowserOrchestrator, al as BrowserProvider, am as BrowserProviderInitializationOptions, an as BrowserProviderModule, ao as BrowserProviderOptions, o as BrowserScript, ap as BrowserServerState, aq as BrowserServerStateSession, q as BuiltinEnvironment, ar as CDPSession, t as CSSModuleScopeStrategy, l as CoverageIstanbulOptions, k as CoverageOptions, g as CoverageProvider, h as CoverageProviderModule, i as CoverageReporter, c as CoverageV8Options, m as CustomProviderOptions, D as DepsOptimizationOptions, $ as HTMLOptions, I as InlineConfig, a1 as JUnitOptions, a0 as JsonOptions, O as OnServerRestartHandler, N as OnTestsRerunHandler, as as ParentProjectBrowser, P as Pool, s as PoolOptions, X as ProcessPool, at as ProjectBrowser, z as ProjectConfig, a as ReportContext, az as ReportedHookContext, n as Reporter, aw as ResolveSnapshotPathHandler, ax as ResolveSnapshotPathHandlerContext, au as ResolvedBrowserOptions, R as ResolvedCoverageOptions, av as ResolvedProjectConfig, _ as SerializedTestProject, a2 as TaskOptions, a3 as TestCase, a4 as TestCollection, a5 as TestDiagnostic, a6 as TestModuleState, a7 as TestResult, a8 as TestResultFailed, a9 as TestResultPassed, aa as TestResultSkipped, aA as TestRunEndReason, ay as TestRunResult, ae as TestSequencerConstructor, ab as TestState, ac as TestSuite, ad as TestSuiteState, v as TransformModePatterns, w as TypecheckConfig, U as UserWorkspaceConfig, r as VitestEnvironment, Q as VitestPackageInstaller, Y as WorkspaceSpec, Z as getFilePoolName } from './chunks/reporters.d.79o4mouw.js';
1
+ import { y as ResolvedConfig, x as UserConfig, u as VitestRunMode, G as VitestOptions, V as Vitest, A as ApiConfig, T as TestProject, H as TestSequencer, J as TestSpecification, L as Logger, K as TestModule, M as ModuleDiagnostic } from './chunks/reporters.d.C-cu31ET.js';
2
+ export { B as BaseCoverageOptions, E as BenchmarkUserOptions, af as BrowserBuiltinProvider, ag as BrowserCommand, ah as BrowserCommandContext, p as BrowserConfigOptions, ai as BrowserInstanceOption, aj as BrowserModuleMocker, ak as BrowserOrchestrator, al as BrowserProvider, am as BrowserProviderInitializationOptions, an as BrowserProviderModule, ao as BrowserProviderOptions, o as BrowserScript, ap as BrowserServerState, aq as BrowserServerStateSession, q as BuiltinEnvironment, ar as CDPSession, t as CSSModuleScopeStrategy, l as CoverageIstanbulOptions, k as CoverageOptions, g as CoverageProvider, h as CoverageProviderModule, i as CoverageReporter, c as CoverageV8Options, m as CustomProviderOptions, D as DepsOptimizationOptions, $ as HTMLOptions, I as InlineConfig, a1 as JUnitOptions, a0 as JsonOptions, O as OnServerRestartHandler, N as OnTestsRerunHandler, as as ParentProjectBrowser, P as Pool, s as PoolOptions, X as ProcessPool, at as ProjectBrowser, z as ProjectConfig, a as ReportContext, az as ReportedHookContext, n as Reporter, aw as ResolveSnapshotPathHandler, ax as ResolveSnapshotPathHandlerContext, au as ResolvedBrowserOptions, R as ResolvedCoverageOptions, av as ResolvedProjectConfig, _ as SerializedTestProject, a2 as TaskOptions, a3 as TestCase, a4 as TestCollection, a5 as TestDiagnostic, a6 as TestModuleState, a7 as TestResult, a8 as TestResultFailed, a9 as TestResultPassed, aa as TestResultSkipped, aA as TestRunEndReason, ay as TestRunResult, ae as TestSequencerConstructor, ab as TestState, ac as TestSuite, ad as TestSuiteState, v as TransformModePatterns, w as TypecheckConfig, U as UserWorkspaceConfig, r as VitestEnvironment, Q as VitestPackageInstaller, Y as WorkspaceSpec, Z as getFilePoolName } from './chunks/reporters.d.C-cu31ET.js';
3
3
  import { InlineConfig, UserConfig as UserConfig$1, Plugin, ResolvedConfig as ResolvedConfig$1, LogLevel, LoggerOptions, Logger as Logger$1, createServer as createServer$1 } from 'vite';
4
4
  import * as vite from 'vite';
5
5
  export { vite as Vite };
@@ -8,7 +8,7 @@ import { IncomingMessage } from 'node:http';
8
8
  import { R as RuntimeRPC } from './chunks/worker.d.CHGSOG0s.js';
9
9
  export { T as TestExecutionType } from './chunks/worker.d.CHGSOG0s.js';
10
10
  import { Writable } from 'node:stream';
11
- export { V as VitestPluginContext } from './chunks/vite.d.BVr6Nvdj.js';
11
+ export { V as VitestPluginContext } from './chunks/vite.d.iXCEVtFP.js';
12
12
  export { W as WorkerContext } from './chunks/worker.d.C-KN07Ls.js';
13
13
  export { C as TypeCheckCollectLineNumbers, a as TypeCheckCollectLines, c as TypeCheckContext, T as TypeCheckErrorInfo, R as TypeCheckRawErrorsMap, b as TypeCheckRootAndTarget } from './chunks/global.d.CXRAxnWc.js';
14
14
  import { Debugger } from 'debug';
@@ -96,7 +96,7 @@ declare class GitNotFoundError extends Error {
96
96
  /** @deprecated use `TestProject` instead */
97
97
  type GlobalSetupContext = TestProject;
98
98
 
99
- declare function VitestPlugin(options?: UserConfig, ctx?: Vitest): Promise<Plugin[]>;
99
+ declare function VitestPlugin(options?: UserConfig, vitest?: Vitest): Promise<Plugin[]>;
100
100
 
101
101
  declare function resolveConfig(options?: UserConfig, viteOverrides?: UserConfig$1): Promise<{
102
102
  vitestConfig: ResolvedConfig
package/dist/node.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { resolveConfig as resolveConfig$1, mergeConfig, createServer as createServer$1 } from 'vite';
2
2
  export { esbuildVersion, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
3
- import { V as Vitest, a as VitestPlugin, T as TestModule } from './chunks/cli-api.z029PxYZ.js';
4
- export { G as GitNotFoundError, F as TestsNotFoundError, b as VitestPackageInstaller, e as createViteLogger, c as createVitest, i as isValidApiRequest, d as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.z029PxYZ.js';
5
- export { p as parseCLI } from './chunks/cac.C5_4mAsf.js';
6
- import { r as resolveConfig$2 } from './chunks/coverage.BUdIvXbr.js';
7
- export { b as BaseSequencer, c as createMethodsRPC, g as getFilePoolName, a as resolveApiServerConfig } from './chunks/coverage.BUdIvXbr.js';
8
- import { slash } from '@vitest/utils';
3
+ import { V as Vitest, a as VitestPlugin, T as TestModule } from './chunks/cli-api.BzebkJv7.js';
4
+ export { G as GitNotFoundError, F as TestsNotFoundError, b as VitestPackageInstaller, e as createViteLogger, c as createVitest, i as isValidApiRequest, d as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.BzebkJv7.js';
5
+ export { p as parseCLI } from './chunks/cac.KrMo52r1.js';
6
+ import { r as resolveConfig$2 } from './chunks/coverage.D6LCUsnS.js';
7
+ export { b as BaseSequencer, c as createMethodsRPC, g as getFilePoolName, a as resolveApiServerConfig } from './chunks/coverage.D6LCUsnS.js';
8
+ import { slash, deepClone } from '@vitest/utils';
9
9
  import { f as findUp } from './chunks/index.DBIGubLC.js';
10
10
  import { resolve } from 'pathe';
11
11
  import { c as configFiles } from './chunks/constants.BZZyIeIE.js';
@@ -19,7 +19,7 @@ import '@vitest/snapshot/manager';
19
19
  import 'vite-node/client';
20
20
  import 'vite-node/server';
21
21
  import './chunks/index.CJ0plNrh.js';
22
- import './chunks/index._vwY_KdO.js';
22
+ import './chunks/index.De2FqGmR.js';
23
23
  import 'tinyrainbow';
24
24
  import './chunks/utils.Cc45eY3L.js';
25
25
  import 'node:util';
@@ -70,7 +70,7 @@ async function resolveConfig(options = {}, viteOverrides = {}) {
70
70
  const root = slash(resolve(options.root || process.cwd()));
71
71
  const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
72
72
  options.config = configPath;
73
- const vitest = new Vitest("test");
73
+ const vitest = new Vitest("test", deepClone(options));
74
74
  const config = await resolveConfig$1(mergeConfig({
75
75
  configFile: configPath,
76
76
  mode: options.mode || "test",
@@ -1,4 +1,4 @@
1
- export { aP as BaseReporter, aB as BasicReporter, aQ as BenchmarkBuiltinReporters, aC as BenchmarkReporter, aD as BenchmarkReportsMap, aR as BuiltinReporterOptions, aS as BuiltinReporters, aE as DefaultReporter, aF as DotReporter, aG as GithubActionsReporter, aH as HangingProcessReporter, aJ as JUnitReporter, aT as JsonAssertionResult, aI as JsonReporter, aU as JsonTestResult, aV as JsonTestResults, az as ReportedHookContext, n as Reporter, aK as ReportersMap, aL as TapFlatReporter, aM as TapReporter, aA as TestRunEndReason, aN as VerboseBenchmarkReporter, aO as VerboseReporter } from './chunks/reporters.d.79o4mouw.js';
1
+ export { aP as BaseReporter, aB as BasicReporter, aQ as BenchmarkBuiltinReporters, aC as BenchmarkReporter, aD as BenchmarkReportsMap, aR as BuiltinReporterOptions, aS as BuiltinReporters, aE as DefaultReporter, aF as DotReporter, aG as GithubActionsReporter, aH as HangingProcessReporter, aJ as JUnitReporter, aT as JsonAssertionResult, aI as JsonReporter, aU as JsonTestResult, aV as JsonTestResults, az as ReportedHookContext, n as Reporter, aK as ReportersMap, aL as TapFlatReporter, aM as TapReporter, aA as TestRunEndReason, aN as VerboseBenchmarkReporter, aO as VerboseReporter } from './chunks/reporters.d.C-cu31ET.js';
2
2
  import '@vitest/runner';
3
3
  import './chunks/environment.d.Dmw5ulng.js';
4
4
  import 'vitest/optional-types.js';
package/dist/reporters.js CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BasicReporter, a as BenchmarkReporter, b as BenchmarkReportsMap, D as DefaultReporter, c as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, d as JUnitReporter, J as JsonReporter, R as ReportersMap, T as TapFlatReporter, e as TapReporter, V as VerboseBenchmarkReporter, f as VerboseReporter } from './chunks/index._vwY_KdO.js';
1
+ export { B as BasicReporter, a as BenchmarkReporter, b as BenchmarkReportsMap, D as DefaultReporter, c as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, d as JUnitReporter, J as JsonReporter, R as ReportersMap, T as TapFlatReporter, e as TapReporter, V as VerboseBenchmarkReporter, f as VerboseReporter } from './chunks/index.De2FqGmR.js';
2
2
  import 'node:fs';
3
3
  import '@vitest/runner/utils';
4
4
  import 'pathe';
package/dist/runners.js CHANGED
@@ -183,7 +183,6 @@ class VitestTestRunner {
183
183
  if (test.mode !== "run" && test.mode !== "queued") {
184
184
  return;
185
185
  }
186
- clearModuleMocks(this.config);
187
186
  this.workerState.current = test;
188
187
  }
189
188
  async onBeforeRunSuite(suite) {
@@ -196,6 +195,7 @@ class VitestTestRunner {
196
195
  this.workerState.current = suite;
197
196
  }
198
197
  onBeforeTryTask(test) {
198
+ clearModuleMocks(this.config);
199
199
  this.snapshotClient.clearTest(test.file.filepath, test.id);
200
200
  setState({
201
201
  assertionCalls: 0,
@@ -1,8 +1,8 @@
1
1
  import v8 from 'node:v8';
2
- import { r as runBaseTests } from '../chunks/base.k5EeHg0m.js';
2
+ import { r as runBaseTests } from '../chunks/base.DslwPSCy.js';
3
3
  import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.BfxieIyZ.js';
4
4
  import 'vite-node/client';
5
- import '../chunks/execute.CwmnH2oH.js';
5
+ import '../chunks/execute.BpmIjFTD.js';
6
6
  import 'node:fs';
7
7
  import 'node:url';
8
8
  import 'node:vm';
@@ -1,7 +1,7 @@
1
- import { r as runBaseTests } from '../chunks/base.k5EeHg0m.js';
1
+ import { r as runBaseTests } from '../chunks/base.DslwPSCy.js';
2
2
  import { a as createThreadsRpcOptions } from '../chunks/utils.BfxieIyZ.js';
3
3
  import 'vite-node/client';
4
- import '../chunks/execute.CwmnH2oH.js';
4
+ import '../chunks/execute.BpmIjFTD.js';
5
5
  import 'node:fs';
6
6
  import 'node:url';
7
7
  import 'node:vm';
@@ -1,6 +1,6 @@
1
1
  import v8 from 'node:v8';
2
2
  import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.BfxieIyZ.js';
3
- import { r as runVmTests } from '../chunks/vm.BmHENIuV.js';
3
+ import { r as runVmTests } from '../chunks/vm.CuLHT1BG.js';
4
4
  import '@vitest/utils';
5
5
  import 'node:url';
6
6
  import 'node:vm';
@@ -13,7 +13,7 @@ import 'node:stream';
13
13
  import 'tinyrainbow';
14
14
  import '../chunks/date.CDOsz-HY.js';
15
15
  import '../chunks/utils.CgTj3MsC.js';
16
- import '../chunks/execute.CwmnH2oH.js';
16
+ import '../chunks/execute.BpmIjFTD.js';
17
17
  import 'node:fs';
18
18
  import '@vitest/utils/error';
19
19
  import 'vite-node/client';
@@ -1,5 +1,5 @@
1
1
  import { a as createThreadsRpcOptions } from '../chunks/utils.BfxieIyZ.js';
2
- import { r as runVmTests } from '../chunks/vm.BmHENIuV.js';
2
+ import { r as runVmTests } from '../chunks/vm.CuLHT1BG.js';
3
3
  import '@vitest/utils';
4
4
  import 'node:url';
5
5
  import 'node:vm';
@@ -12,7 +12,7 @@ import 'node:stream';
12
12
  import 'tinyrainbow';
13
13
  import '../chunks/date.CDOsz-HY.js';
14
14
  import '../chunks/utils.CgTj3MsC.js';
15
- import '../chunks/execute.CwmnH2oH.js';
15
+ import '../chunks/execute.BpmIjFTD.js';
16
16
  import 'node:fs';
17
17
  import '@vitest/utils/error';
18
18
  import 'vite-node/client';
package/dist/workers.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { p as provideWorkerState } from './chunks/utils.CgTj3MsC.js';
2
2
  export { collect as collectVitestWorkerTests, run as runVitestWorker } from './worker.js';
3
- export { r as runBaseTests } from './chunks/base.k5EeHg0m.js';
3
+ export { r as runBaseTests } from './chunks/base.DslwPSCy.js';
4
4
  export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './chunks/utils.BfxieIyZ.js';
5
- export { r as runVmTests } from './chunks/vm.BmHENIuV.js';
5
+ export { r as runVmTests } from './chunks/vm.CuLHT1BG.js';
6
6
  import '@vitest/utils';
7
7
  import 'node:url';
8
8
  import '@vitest/utils/source-map';
@@ -16,7 +16,7 @@ import './chunks/inspector.DbDkSkFn.js';
16
16
  import 'node:module';
17
17
  import './chunks/rpc.D9_013TY.js';
18
18
  import './chunks/index.CJ0plNrh.js';
19
- import './chunks/execute.CwmnH2oH.js';
19
+ import './chunks/execute.BpmIjFTD.js';
20
20
  import 'node:vm';
21
21
  import '@vitest/utils/error';
22
22
  import 'vite-node/utils';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "3.1.2",
4
+ "version": "3.1.4",
5
5
  "description": "Next generation testing framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -123,8 +123,8 @@
123
123
  "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
124
124
  "happy-dom": "*",
125
125
  "jsdom": "*",
126
- "@vitest/ui": "3.1.2",
127
- "@vitest/browser": "3.1.2"
126
+ "@vitest/browser": "3.1.4",
127
+ "@vitest/ui": "3.1.4"
128
128
  },
129
129
  "peerDependenciesMeta": {
130
130
  "@edge-runtime/vm": {
@@ -163,14 +163,14 @@
163
163
  "tinyrainbow": "^2.0.0",
164
164
  "vite": "^5.0.0 || ^6.0.0",
165
165
  "why-is-node-running": "^2.3.0",
166
- "@vitest/expect": "3.1.2",
167
- "@vitest/mocker": "3.1.2",
168
- "@vitest/runner": "3.1.2",
169
- "@vitest/snapshot": "3.1.2",
170
- "@vitest/spy": "3.1.2",
171
- "@vitest/pretty-format": "^3.1.2",
172
- "@vitest/utils": "3.1.2",
173
- "vite-node": "3.1.2"
166
+ "@vitest/expect": "3.1.4",
167
+ "@vitest/pretty-format": "^3.1.4",
168
+ "@vitest/runner": "3.1.4",
169
+ "@vitest/utils": "3.1.4",
170
+ "@vitest/snapshot": "3.1.4",
171
+ "@vitest/spy": "3.1.4",
172
+ "vite-node": "3.1.4",
173
+ "@vitest/mocker": "3.1.4"
174
174
  },
175
175
  "devDependencies": {
176
176
  "@ampproject/remapping": "^2.3.0",