vitest 0.31.4 → 0.32.0

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,6 +1,6 @@
1
1
  import { resolve as resolve$2, relative, isAbsolute, dirname, basename, normalize, join, extname, toNamespacedPath } from 'pathe';
2
2
  import { E as EXIT_CODE_RESTART, c as configFiles, d as defaultPort, a as defaultBrowserPort, w as workspacesFiles, C as CONFIG_NAMES } from './vendor-constants.538d9b49.js';
3
- import { g as getCoverageProvider, C as CoverageProviderMap } from './vendor-coverage.c8fd34c3.js';
3
+ import { g as getCoverageProvider, C as CoverageProviderMap } from './vendor-coverage.de2180ed.js';
4
4
  import { g as getEnvPackageName } from './vendor-index.75f2b63d.js';
5
5
  import url, { fileURLToPath, pathToFileURL } from 'node:url';
6
6
  import c from 'picocolors';
@@ -25,7 +25,7 @@ import { ViteNodeServer } from 'vite-node/server';
25
25
  import { d as distDir, r as rootDir } from './vendor-paths.84fc7a99.js';
26
26
  import v8 from 'node:v8';
27
27
  import { fork } from 'node:child_process';
28
- import { g as groupBy, a as getEnvironmentTransformMode, c as createBirpc, A as AggregateErrorPonyfill, s as slash$1, t as toArray, i as isPrimitive, d as deepMerge, n as noop$1, b as stdout } from './vendor-index.5037f2c0.js';
28
+ import { g as groupBy, a as getEnvironmentTransformMode, c as createBirpc, A as AggregateErrorPonyfill, s as slash$1, t as toArray, i as isPrimitive, d as deepMerge, n as noop$1, b as stdout } from './vendor-index.87ab04c3.js';
29
29
  import { MessageChannel } from 'node:worker_threads';
30
30
  import { cpus, hostname } from 'node:os';
31
31
  import Tinypool from 'tinypool';
@@ -60,13 +60,15 @@ function _mergeNamespaces(n, m) {
60
60
  return Object.freeze(n);
61
61
  }
62
62
 
63
- var version$1 = "0.31.4";
63
+ var version$1 = "0.32.0";
64
64
 
65
65
  const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
66
- async function ensurePackageInstalled(dependency, root) {
66
+ async function ensurePackageInstalled(dependency, root, errorMessage) {
67
67
  if (isPackageExists(dependency, { paths: [root, __dirname$1] }))
68
68
  return true;
69
69
  const promptInstall = !isCI && process.stdout.isTTY;
70
+ if (errorMessage)
71
+ process.stderr.write(c.red(errorMessage));
70
72
  process.stderr.write(c.red(`${c.inverse(c.red(" MISSING DEP "))} Can not find dependency '${dependency}'
71
73
 
72
74
  `));
@@ -79,7 +81,7 @@ async function ensurePackageInstalled(dependency, root) {
79
81
  message: c.reset(`Do you want to install ${c.green(dependency)}?`)
80
82
  });
81
83
  if (install) {
82
- await (await import('./chunk-install-pkg.4f68b0aa.js')).installPackage(dependency, { dev: true });
84
+ await (await import('./chunk-install-pkg.ce602c20.js')).installPackage(dependency, { dev: true });
83
85
  process.stderr.write(c.yellow(`
84
86
  Package ${dependency} installed, re-run the command to start.
85
87
  `));
@@ -9503,8 +9505,12 @@ class JUnitReporter {
9503
9505
  await promises.mkdir(outputDirectory, { recursive: true });
9504
9506
  const fileFd = await promises.open(this.reportFile, "w+");
9505
9507
  this.fileFd = fileFd;
9506
- this.baseLog = async (text) => await promises.writeFile(fileFd, `${text}
9508
+ this.baseLog = async (text) => {
9509
+ if (!this.fileFd)
9510
+ this.fileFd = await promises.open(this.reportFile, "w+");
9511
+ await promises.writeFile(this.fileFd, `${text}
9507
9512
  `);
9513
+ };
9508
9514
  } else {
9509
9515
  this.baseLog = async (text) => this.ctx.logger.log(text);
9510
9516
  }
@@ -9635,6 +9641,7 @@ class JUnitReporter {
9635
9641
  if (this.reportFile)
9636
9642
  this.ctx.logger.log(`JUNIT report written to ${this.reportFile}`);
9637
9643
  await ((_a = this.fileFd) == null ? void 0 : _a.close());
9644
+ this.fileFd = void 0;
9638
9645
  }
9639
9646
  }
9640
9647
 
@@ -10144,10 +10151,10 @@ class StateManager {
10144
10151
  }
10145
10152
  }
10146
10153
 
10147
- const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
10154
+ const defaultInclude = ["**/__tests__/**/*.?(c|m)[jt]s?(x)", "**/?(*.){test,spec}.?(c|m)[jt]s?(x)"];
10148
10155
  const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**", "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*"];
10149
10156
  const benchmarkConfigDefaults = {
10150
- include: ["**/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
10157
+ include: ["**/*.{bench,benchmark}.?(c|m)[jt]s?(x)"],
10151
10158
  exclude: defaultExclude,
10152
10159
  includeSource: [],
10153
10160
  reporters: ["default"]
@@ -10155,19 +10162,18 @@ const benchmarkConfigDefaults = {
10155
10162
  const defaultCoverageExcludes = [
10156
10163
  "coverage/**",
10157
10164
  "dist/**",
10158
- "packages/*/test{,s}/**",
10165
+ "packages/*/test?(s)/**",
10159
10166
  "**/*.d.ts",
10160
10167
  "cypress/**",
10161
- "test{,s}/**",
10162
- "test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
10163
- "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
10164
- "**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
10168
+ "test?(s)/**",
10169
+ "test?(-*).?(c|m)[jt]s?(x)",
10170
+ "**/*{.,-}{test,spec}.?(c|m)[jt]s?(x)",
10165
10171
  "**/__tests__/**",
10166
10172
  "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*",
10167
- "**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
10173
+ "**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}"
10168
10174
  ];
10169
10175
  const coverageConfigDefaults = {
10170
- provider: "c8",
10176
+ provider: "v8",
10171
10177
  enabled: false,
10172
10178
  clean: true,
10173
10179
  cleanOnRerun: true,
@@ -10229,7 +10235,7 @@ const config = {
10229
10235
  dangerouslyIgnoreUnhandledErrors: false,
10230
10236
  typecheck: {
10231
10237
  checker: "tsc",
10232
- include: ["**/*.{test,spec}-d.{ts,js}"],
10238
+ include: ["**/?(*.){test,spec}-d.?(c|m)[jt]s?(x)"],
10233
10239
  exclude: defaultExclude
10234
10240
  },
10235
10241
  slowTestThreshold: 300
@@ -10495,6 +10501,8 @@ function resolveConfig(mode, options, viteConfig) {
10495
10501
  }
10496
10502
  if (resolved.coverage.provider === "c8" && resolved.coverage.enabled && isBrowserEnabled(resolved))
10497
10503
  throw new Error("@vitest/coverage-c8 does not work with --browser. Use @vitest/coverage-istanbul instead");
10504
+ if (resolved.coverage.provider === "v8" && resolved.coverage.enabled && isBrowserEnabled(resolved))
10505
+ throw new Error("@vitest/coverage-v8 does not work with --browser. Use @vitest/coverage-istanbul instead");
10498
10506
  resolved.deps = resolved.deps || {};
10499
10507
  if (resolved.deps.inline !== true) {
10500
10508
  const ssrOptions = viteConfig.ssr;
@@ -11165,7 +11173,7 @@ createLogUpdate(process$1.stdout);
11165
11173
 
11166
11174
  createLogUpdate(process$1.stderr);
11167
11175
 
11168
- var version = "0.31.4";
11176
+ var version = "0.32.0";
11169
11177
 
11170
11178
  const comma = ','.charCodeAt(0);
11171
11179
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
@@ -12375,11 +12383,8 @@ As a temporary workaround you can try to inline the package by updating your con
12375
12383
  ` + c.gray(c.dim("// vitest.config.js")) + "\n" + c.green(`export default {
12376
12384
  test: {
12377
12385
  deps: {
12378
- experimentalOptimizer: {
12379
- enabled: true,
12380
- include: [
12381
- ${c.yellow(c.bold(`"${name}"`))}
12382
- ]
12386
+ inline: [
12387
+ ${c.yellow(c.bold(`"${name}"`))}
12383
12388
  }
12384
12389
  }
12385
12390
  }
@@ -12759,7 +12764,7 @@ async function createBrowserServer(project, options) {
12759
12764
  });
12760
12765
  await server.listen();
12761
12766
  await server.watcher.close();
12762
- (await import('./chunk-api-setup.3854747a.js')).setup(project, server);
12767
+ (await import('./chunk-api-setup.05e3917b.js')).setup(project, server);
12763
12768
  return server;
12764
12769
  }
12765
12770
 
@@ -13060,6 +13065,52 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
13060
13065
  };
13061
13066
  }
13062
13067
 
13068
+ function resolveOptimizerConfig(testOptionc, viteOptions, testConfig) {
13069
+ var _a;
13070
+ const newConfig = {};
13071
+ const [major, minor] = version$2.split(".").map(Number);
13072
+ const allowed = major >= 5 || major === 4 && minor >= 3;
13073
+ if (!allowed && (testOptionc == null ? void 0 : testOptionc.enabled) === true)
13074
+ console.warn(`Vitest: "deps.optimizer" is only available in Vite >= 4.3.0, current Vite version: ${version$2}`);
13075
+ if (!allowed || (testOptionc == null ? void 0 : testOptionc.enabled) !== true) {
13076
+ newConfig.cacheDir = void 0;
13077
+ newConfig.optimizeDeps = {
13078
+ // experimental in Vite >2.9.2, entries remains to help with older versions
13079
+ disabled: true,
13080
+ entries: []
13081
+ };
13082
+ } else {
13083
+ const cacheDir = testConfig.cache !== false ? (_a = testConfig.cache) == null ? void 0 : _a.dir : null;
13084
+ newConfig.cacheDir = cacheDir ?? "node_modules/.vitest";
13085
+ newConfig.optimizeDeps = {
13086
+ ...viteOptions,
13087
+ ...testOptionc,
13088
+ noDiscovery: true,
13089
+ disabled: false,
13090
+ entries: [],
13091
+ exclude: ["vitest", ...builtinModules, ...testOptionc.exclude || (viteOptions == null ? void 0 : viteOptions.exclude) || []],
13092
+ include: (testOptionc.include || (viteOptions == null ? void 0 : viteOptions.include) || []).filter((n) => n !== "vitest")
13093
+ };
13094
+ }
13095
+ return newConfig;
13096
+ }
13097
+
13098
+ function VitestResolver(ctx) {
13099
+ return {
13100
+ name: "vitest:resolve-root",
13101
+ enforce: "pre",
13102
+ async resolveId(id) {
13103
+ if (id === "vitest" || id.startsWith("@vitest/")) {
13104
+ return this.resolve(
13105
+ id,
13106
+ join(ctx.config.root, "index.html"),
13107
+ { skipSelf: true }
13108
+ );
13109
+ }
13110
+ }
13111
+ };
13112
+ }
13113
+
13063
13114
  function WorkspaceVitestPlugin(project, options) {
13064
13115
  return [
13065
13116
  {
@@ -13070,7 +13121,7 @@ function WorkspaceVitestPlugin(project, options) {
13070
13121
  },
13071
13122
  // TODO: refactor so we don't have the same code here and in plugins/index.ts
13072
13123
  config(viteConfig) {
13073
- var _a, _b, _c, _d, _e, _f, _g;
13124
+ var _a, _b, _c, _d, _e, _f, _g, _h;
13074
13125
  if (viteConfig.define) {
13075
13126
  delete viteConfig.define["import.meta.vitest"];
13076
13127
  delete viteConfig.define["process.env"];
@@ -13148,33 +13199,13 @@ function WorkspaceVitestPlugin(project, options) {
13148
13199
  };
13149
13200
  }
13150
13201
  }
13151
- const optimizeConfig = {};
13152
- const optimizer = (_d = testConfig.deps) == null ? void 0 : _d.experimentalOptimizer;
13153
- const [major, minor] = version$2.split(".").map(Number);
13154
- const allowed = major >= 5 || major === 4 && minor >= 3;
13155
- if (!allowed && (optimizer == null ? void 0 : optimizer.enabled) === true)
13156
- console.warn(`Vitest: "deps.experimentalOptimizer" is only available in Vite >= 4.3.0, current Vite version: ${version$2}`);
13157
- if (!allowed || (optimizer == null ? void 0 : optimizer.enabled) !== true) {
13158
- optimizeConfig.cacheDir = void 0;
13159
- optimizeConfig.optimizeDeps = {
13160
- // experimental in Vite >2.9.2, entries remains to help with older versions
13161
- disabled: true,
13162
- entries: []
13163
- };
13164
- } else {
13165
- const cacheDir = testConfig.cache !== false ? (_e = testConfig.cache) == null ? void 0 : _e.dir : null;
13166
- optimizeConfig.cacheDir = cacheDir ?? "node_modules/.vitest";
13167
- optimizeConfig.optimizeDeps = {
13168
- ...viteConfig.optimizeDeps,
13169
- ...optimizer,
13170
- noDiscovery: true,
13171
- disabled: false,
13172
- entries: [],
13173
- exclude: ["vitest", ...builtinModules, ...optimizer.exclude || ((_f = viteConfig.optimizeDeps) == null ? void 0 : _f.exclude) || []],
13174
- include: (optimizer.include || ((_g = viteConfig.optimizeDeps) == null ? void 0 : _g.include) || []).filter((n) => n !== "vitest")
13175
- };
13176
- }
13177
- Object.assign(config, optimizeConfig);
13202
+ const webOptimizer = resolveOptimizerConfig((_e = (_d = testConfig.deps) == null ? void 0 : _d.experimentalOptimizer) == null ? void 0 : _e.web, viteConfig.optimizeDeps, testConfig);
13203
+ const ssrOptimizer = resolveOptimizerConfig((_g = (_f = testConfig.deps) == null ? void 0 : _f.experimentalOptimizer) == null ? void 0 : _g.ssr, (_h = viteConfig.ssr) == null ? void 0 : _h.optimizeDeps, testConfig);
13204
+ config.cacheDir = webOptimizer.cacheDir || ssrOptimizer.cacheDir || config.cacheDir;
13205
+ config.optimizeDeps = webOptimizer.optimizeDeps;
13206
+ config.ssr = {
13207
+ optimizeDeps: ssrOptimizer.optimizeDeps
13208
+ };
13178
13209
  return config;
13179
13210
  },
13180
13211
  async configureServer(server) {
@@ -13196,12 +13227,13 @@ function WorkspaceVitestPlugin(project, options) {
13196
13227
  ...CSSEnablerPlugin(project),
13197
13228
  CoverageTransform(project.ctx),
13198
13229
  GlobalSetupPlugin(project, project.ctx.logger),
13199
- MocksPlugin()
13230
+ MocksPlugin(),
13231
+ VitestResolver(project.ctx)
13200
13232
  ];
13201
13233
  }
13202
13234
 
13203
13235
  async function initializeProject(workspacePath, ctx, options) {
13204
- var _a, _b, _c;
13236
+ var _a, _b, _c, _d, _e, _f, _g;
13205
13237
  const project = new WorkspaceProject(workspacePath, ctx);
13206
13238
  const configFile = options.extends ? resolve$2(dirname(options.workspaceConfigPath), options.extends) : typeof workspacePath === "number" || workspacePath.endsWith("/") ? false : workspacePath;
13207
13239
  const root = options.root || (typeof workspacePath === "number" ? void 0 : dirname(workspacePath));
@@ -13218,7 +13250,7 @@ async function initializeProject(workspacePath, ctx, options) {
13218
13250
  ]
13219
13251
  };
13220
13252
  const server = await createServer(config);
13221
- if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_c = (_b = project.config.deps) == null ? void 0 : _b.experimentalOptimizer) == null ? void 0 : _c.enabled))
13253
+ if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_d = (_c = (_b = project.config.deps) == null ? void 0 : _b.experimentalOptimizer) == null ? void 0 : _c.web) == null ? void 0 : _d.enabled) || ((_g = (_f = (_e = project.config.deps) == null ? void 0 : _e.experimentalOptimizer) == null ? void 0 : _f.ssr) == null ? void 0 : _g.enabled))
13222
13254
  await server.listen();
13223
13255
  else
13224
13256
  await server.pluginContainer.buildStart({});
@@ -13387,7 +13419,7 @@ class WorkspaceProject {
13387
13419
  return isBrowserEnabled(this.config);
13388
13420
  }
13389
13421
  getSerializableConfig() {
13390
- var _a, _b;
13422
+ var _a, _b, _c, _d, _e, _f;
13391
13423
  return deepMerge(
13392
13424
  {
13393
13425
  ...this.config,
@@ -13395,8 +13427,13 @@ class WorkspaceProject {
13395
13427
  reporters: [],
13396
13428
  deps: {
13397
13429
  ...this.config.deps,
13398
- experimentalOptimizer: {
13399
- enabled: ((_b = (_a = this.config.deps) == null ? void 0 : _a.experimentalOptimizer) == null ? void 0 : _b.enabled) ?? false
13430
+ optimizer: {
13431
+ web: {
13432
+ enabled: ((_c = (_b = (_a = this.config.deps) == null ? void 0 : _a.experimentalOptimizer) == null ? void 0 : _b.web) == null ? void 0 : _c.enabled) ?? false
13433
+ },
13434
+ ssr: {
13435
+ enabled: ((_f = (_e = (_d = this.config.deps) == null ? void 0 : _d.experimentalOptimizer) == null ? void 0 : _e.ssr) == null ? void 0 : _f.enabled) ?? false
13436
+ }
13400
13437
  }
13401
13438
  },
13402
13439
  snapshotOptions: {
@@ -14051,17 +14088,17 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
14051
14088
  this.meta.watchMode = false;
14052
14089
  },
14053
14090
  async config(viteConfig) {
14054
- var _a, _b, _c, _d, _e, _f, _g, _h;
14091
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
14055
14092
  if (options.watch) {
14056
14093
  options = deepMerge({}, userConfig);
14057
14094
  }
14058
- const preOptions = deepMerge(
14095
+ const testConfig = deepMerge(
14059
14096
  {},
14060
14097
  configDefaults,
14061
14098
  options,
14062
14099
  removeUndefinedValues(viteConfig.test ?? {})
14063
14100
  );
14064
- preOptions.api = resolveApiServerConfig(preOptions);
14101
+ testConfig.api = resolveApiServerConfig(testConfig);
14065
14102
  if (viteConfig.define) {
14066
14103
  delete viteConfig.define["import.meta.vitest"];
14067
14104
  delete viteConfig.define["process.env"];
@@ -14090,8 +14127,8 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
14090
14127
  }
14091
14128
  options.defines = defines;
14092
14129
  let open;
14093
- if (preOptions.ui && preOptions.open)
14094
- open = preOptions.uiBase ?? "/__vitest__/";
14130
+ if (testConfig.ui && testConfig.open)
14131
+ open = testConfig.uiBase ?? "/__vitest__/";
14095
14132
  const config = {
14096
14133
  root: ((_a = viteConfig.test) == null ? void 0 : _a.root) || options.root,
14097
14134
  esbuild: {
@@ -14103,23 +14140,23 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
14103
14140
  // by default Vite resolves `module` field, which not always a native ESM module
14104
14141
  // setting this option can bypass that and fallback to cjs version
14105
14142
  mainFields: [],
14106
- alias: preOptions.alias,
14143
+ alias: testConfig.alias,
14107
14144
  conditions: ["node"],
14108
14145
  // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
14109
14146
  // @ts-ignore we support Vite ^3.0, but browserField is available in Vite ^3.2
14110
14147
  browserField: false
14111
14148
  },
14112
14149
  server: {
14113
- ...preOptions.api,
14150
+ ...testConfig.api,
14114
14151
  watch: {
14115
- ignored: preOptions.watchExclude
14152
+ ignored: testConfig.watchExclude
14116
14153
  },
14117
14154
  open,
14118
14155
  hmr: false,
14119
14156
  preTransformRequests: false
14120
14157
  }
14121
14158
  };
14122
- const classNameStrategy = typeof preOptions.css !== "boolean" && ((_c = (_b = preOptions.css) == null ? void 0 : _b.modules) == null ? void 0 : _c.classNameStrategy) || "stable";
14159
+ const classNameStrategy = typeof testConfig.css !== "boolean" && ((_c = (_b = testConfig.css) == null ? void 0 : _b.modules) == null ? void 0 : _c.classNameStrategy) || "stable";
14123
14160
  if (classNameStrategy !== "scoped") {
14124
14161
  config.css ?? (config.css = {});
14125
14162
  (_d = config.css).modules ?? (_d.modules = {});
@@ -14130,33 +14167,13 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
14130
14167
  };
14131
14168
  }
14132
14169
  }
14133
- const optimizeConfig = {};
14134
- const optimizer = (_e = preOptions.deps) == null ? void 0 : _e.experimentalOptimizer;
14135
- const [major, minor] = version$2.split(".").map(Number);
14136
- const allowed = major >= 5 || major === 4 && minor >= 3;
14137
- if (!allowed && (optimizer == null ? void 0 : optimizer.enabled) === true)
14138
- console.warn(`Vitest: "deps.experimentalOptimizer" is only available in Vite >= 4.3.0, current Vite version: ${version$2}`);
14139
- if (!allowed || (optimizer == null ? void 0 : optimizer.enabled) !== true) {
14140
- optimizeConfig.cacheDir = void 0;
14141
- optimizeConfig.optimizeDeps = {
14142
- // experimental in Vite >2.9.2, entries remains to help with older versions
14143
- disabled: true,
14144
- entries: []
14145
- };
14146
- } else {
14147
- const cacheDir = preOptions.cache !== false ? (_f = preOptions.cache) == null ? void 0 : _f.dir : null;
14148
- optimizeConfig.cacheDir = cacheDir ?? "node_modules/.vitest";
14149
- optimizeConfig.optimizeDeps = {
14150
- ...viteConfig.optimizeDeps,
14151
- ...optimizer,
14152
- noDiscovery: true,
14153
- disabled: false,
14154
- entries: [],
14155
- exclude: ["vitest", ...builtinModules, ...optimizer.exclude || ((_g = viteConfig.optimizeDeps) == null ? void 0 : _g.exclude) || []],
14156
- include: (optimizer.include || ((_h = viteConfig.optimizeDeps) == null ? void 0 : _h.include) || []).filter((n) => n !== "vitest")
14157
- };
14158
- }
14159
- Object.assign(config, optimizeConfig);
14170
+ const webOptimizer = resolveOptimizerConfig((_f = (_e = testConfig.deps) == null ? void 0 : _e.experimentalOptimizer) == null ? void 0 : _f.web, viteConfig.optimizeDeps, testConfig);
14171
+ const ssrOptimizer = resolveOptimizerConfig((_h = (_g = testConfig.deps) == null ? void 0 : _g.experimentalOptimizer) == null ? void 0 : _h.ssr, (_i = viteConfig.ssr) == null ? void 0 : _i.optimizeDeps, testConfig);
14172
+ config.cacheDir = webOptimizer.cacheDir || ssrOptimizer.cacheDir || config.cacheDir;
14173
+ config.optimizeDeps = webOptimizer.optimizeDeps;
14174
+ config.ssr = {
14175
+ optimizeDeps: ssrOptimizer.optimizeDeps
14176
+ };
14160
14177
  return config;
14161
14178
  },
14162
14179
  async configResolved(viteConfig) {
@@ -14191,7 +14208,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
14191
14208
  try {
14192
14209
  await ctx.setServer(options, server, userConfig);
14193
14210
  if (options.api && options.watch)
14194
- (await import('./chunk-api-setup.3854747a.js')).setup(ctx);
14211
+ (await import('./chunk-api-setup.05e3917b.js')).setup(ctx);
14195
14212
  } catch (err) {
14196
14213
  await ctx.logger.printError(err, true);
14197
14214
  process.exit(1);
@@ -14205,12 +14222,13 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
14205
14222
  ...CSSEnablerPlugin(ctx),
14206
14223
  CoverageTransform(ctx),
14207
14224
  options.ui ? await UIPlugin() : null,
14208
- MocksPlugin()
14225
+ MocksPlugin(),
14226
+ VitestResolver(ctx)
14209
14227
  ].filter(notNullish);
14210
14228
  }
14211
14229
 
14212
14230
  async function createVitest(mode, options, viteOverrides = {}) {
14213
- var _a, _b, _c;
14231
+ var _a, _b, _c, _d, _e, _f, _g;
14214
14232
  const ctx = new Vitest(mode);
14215
14233
  const root = resolve$2(options.root || process.cwd());
14216
14234
  const configPath = options.config === false ? false : options.config ? resolve$2(root, options.config) : await findUp(configFiles, { cwd: root });
@@ -14222,7 +14240,7 @@ async function createVitest(mode, options, viteOverrides = {}) {
14222
14240
  plugins: await VitestPlugin(options, ctx)
14223
14241
  };
14224
14242
  const server = await createServer(mergeConfig(config, mergeConfig(viteOverrides, { root: options.root })));
14225
- if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_c = (_b = ctx.config.deps) == null ? void 0 : _b.experimentalOptimizer) == null ? void 0 : _c.enabled))
14243
+ if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_d = (_c = (_b = ctx.config.deps) == null ? void 0 : _b.experimentalOptimizer) == null ? void 0 : _c.web) == null ? void 0 : _d.enabled) || ((_g = (_f = (_e = ctx.config.deps) == null ? void 0 : _e.experimentalOptimizer) == null ? void 0 : _f.ssr) == null ? void 0 : _g.enabled))
14226
14244
  await server.listen();
14227
14245
  else
14228
14246
  await server.pluginContainer.buildStart({});
@@ -20606,7 +20624,7 @@ function registerConsoleShortcuts(ctx) {
20606
20624
  }
20607
20625
 
20608
20626
  async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
20609
- var _a;
20627
+ var _a, _b, _c, _d;
20610
20628
  process.env.TEST = "true";
20611
20629
  process.env.VITEST = "true";
20612
20630
  (_a = process.env).NODE_ENV ?? (_a.NODE_ENV = options.mode || "test");
@@ -20627,10 +20645,12 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
20627
20645
  options.browser.enabled = true;
20628
20646
  const ctx = await createVitest(mode, options, viteOverrides);
20629
20647
  if (mode === "test" && ctx.config.coverage.enabled) {
20630
- const provider = ctx.config.coverage.provider || "c8";
20648
+ const provider = ctx.config.coverage.provider || "v8";
20631
20649
  const requiredPackages = CoverageProviderMap[provider];
20632
20650
  if (requiredPackages) {
20633
- if (!await ensurePackageInstalled(requiredPackages, root)) {
20651
+ const defaultProviderInfo = 'Default coverage provider has changed from "c8" to "v8". New package is required to be installed. To use the old deprecated coverage provider use "--coverage.provider c8" option.\nSee https://github.com/vitest-dev/vitest/pull/3339 for more information.\n\n';
20652
+ const isUsingDefaultProvider = ((_c = (_b = ctx.server.config.test) == null ? void 0 : _b.coverage) == null ? void 0 : _c.provider) === void 0 && ((_d = options.coverage) == null ? void 0 : _d.provider) === void 0;
20653
+ if (!await ensurePackageInstalled(requiredPackages, root, isUsingDefaultProvider ? defaultProviderInfo : void 0)) {
20634
20654
  process.exitCode = 1;
20635
20655
  return ctx;
20636
20656
  }
@@ -1,12 +1,13 @@
1
1
  const CoverageProviderMap = {
2
2
  c8: "@vitest/coverage-c8",
3
+ v8: "@vitest/coverage-v8",
3
4
  istanbul: "@vitest/coverage-istanbul"
4
5
  };
5
6
  async function resolveCoverageProviderModule(options, loader) {
6
7
  if (!(options == null ? void 0 : options.enabled) || !options.provider)
7
8
  return null;
8
9
  const provider = options.provider;
9
- if (provider === "c8" || provider === "istanbul") {
10
+ if (provider === "c8" || provider === "v8" || provider === "istanbul") {
10
11
  const { default: coverageModule } = await loader.executeId(CoverageProviderMap[provider]);
11
12
  if (!coverageModule)
12
13
  throw new Error(`Failed to load ${CoverageProviderMap[provider]}. Default export is missing.`);
@@ -2,12 +2,12 @@ import { pathToFileURL } from 'node:url';
2
2
  import { ModuleCacheMap, ViteNodeRunner } from 'vite-node/client';
3
3
  import { isNodeBuiltin, isInternalRequest, isPrimitive } from 'vite-node/utils';
4
4
  import { isAbsolute, dirname, join, basename, extname, resolve, normalize, relative } from 'pathe';
5
- import { processError } from '@vitest/runner/utils';
5
+ import { processError } from '@vitest/utils/error';
6
6
  import { g as getWorkerState, a as getCurrentEnvironment } from './vendor-global.6795f91f.js';
7
7
  import { d as distDir } from './vendor-paths.84fc7a99.js';
8
8
  import { existsSync, readdirSync } from 'node:fs';
9
9
  import { getColors, getType } from '@vitest/utils';
10
- import { e as getAllMockableProperties } from './vendor-index.5037f2c0.js';
10
+ import { e as getAllMockableProperties } from './vendor-index.87ab04c3.js';
11
11
  import { spyOn } from '@vitest/spy';
12
12
  import { r as rpc } from './vendor-rpc.4d3d7a54.js';
13
13
 
@@ -71,7 +71,19 @@ const _VitestMocker = class {
71
71
  };
72
72
  }
73
73
  async resolvePath(rawId, importer) {
74
- const [id, fsPath] = await this.executor.resolveUrl(rawId, importer);
74
+ let id;
75
+ let fsPath;
76
+ try {
77
+ [id, fsPath] = await this.executor.originalResolveUrl(rawId, importer);
78
+ } catch (error) {
79
+ if (error.code === "ERR_MODULE_NOT_FOUND") {
80
+ const { id: unresolvedId } = error[Symbol.for("vitest.error.not_found.data")];
81
+ id = unresolvedId;
82
+ fsPath = unresolvedId;
83
+ } else {
84
+ throw error;
85
+ }
86
+ }
75
87
  const external = !isAbsolute(fsPath) || this.isAModuleDirectory(fsPath) ? rawId : null;
76
88
  return {
77
89
  id,
@@ -80,6 +92,8 @@ const _VitestMocker = class {
80
92
  };
81
93
  }
82
94
  async resolveMocks() {
95
+ if (!_VitestMocker.pendingIds.length)
96
+ return;
83
97
  await Promise.all(_VitestMocker.pendingIds.map(async (mock) => {
84
98
  const { fsPath, external } = await this.resolvePath(mock.id, mock.importer);
85
99
  if (mock.type === "unmock")
@@ -214,7 +228,7 @@ ${c.green(`vi.mock("${mockpath}", async () => {
214
228
  const mock = spyOn(newContainer, property).mockImplementation(() => void 0);
215
229
  mock.mockRestore = () => {
216
230
  mock.mockReset();
217
- mock.mockImplementation(void 0);
231
+ mock.mockImplementation(() => void 0);
218
232
  return mock;
219
233
  };
220
234
  Object.defineProperty(newContainer[property], "length", { value: 0 });
@@ -268,8 +282,6 @@ ${c.green(`vi.mock("${mockpath}", async () => {
268
282
  return this.executor.dependencyRequest(mock, mock, [importee]);
269
283
  }
270
284
  async requestWithMock(url, callstack) {
271
- if (_VitestMocker.pendingIds.length)
272
- await this.resolveMocks();
273
285
  const id = this.normalizePath(url);
274
286
  const mock = this.getDependencyMock(id);
275
287
  const mockPath = this.getMockPath(id);
@@ -365,15 +377,31 @@ class VitestExecutor extends ViteNodeRunner {
365
377
  });
366
378
  }
367
379
  shouldResolveId(id, _importee) {
368
- if (isInternalRequest(id))
380
+ if (isInternalRequest(id) || id.startsWith("data:"))
369
381
  return false;
370
382
  const environment = getCurrentEnvironment();
371
383
  return environment === "node" ? !isNodeBuiltin(id) : !id.startsWith("node:");
372
384
  }
385
+ async originalResolveUrl(id, importer) {
386
+ return super.resolveUrl(id, importer);
387
+ }
373
388
  async resolveUrl(id, importer) {
389
+ if (VitestMocker.pendingIds.length)
390
+ await this.mocker.resolveMocks();
374
391
  if (importer && importer.startsWith("mock:"))
375
392
  importer = importer.slice(5);
376
- return super.resolveUrl(id, importer);
393
+ try {
394
+ return await super.resolveUrl(id, importer);
395
+ } catch (error) {
396
+ if (error.code === "ERR_MODULE_NOT_FOUND") {
397
+ const { id: id2 } = error[Symbol.for("vitest.error.not_found.data")];
398
+ const path = this.mocker.normalizePath(id2);
399
+ const mock = this.mocker.getDependencyMock(path);
400
+ if (mock !== void 0)
401
+ return [id2, id2];
402
+ }
403
+ throw error;
404
+ }
377
405
  }
378
406
  async dependencyRequest(id, fsPath, callstack) {
379
407
  const mocked = await this.mocker.requestWithMock(fsPath, callstack);
@@ -82,8 +82,8 @@ function stdout() {
82
82
  return console._stdout || process.stdout;
83
83
  }
84
84
  function getEnvironmentTransformMode(config, environment) {
85
- var _a, _b;
86
- if (!((_b = (_a = config.deps) == null ? void 0 : _a.experimentalOptimizer) == null ? void 0 : _b.enabled))
85
+ var _a, _b, _c, _d, _e, _f;
86
+ if (!((_c = (_b = (_a = config.deps) == null ? void 0 : _a.experimentalOptimizer) == null ? void 0 : _b.ssr) == null ? void 0 : _c.enabled) && !((_f = (_e = (_d = config.deps) == null ? void 0 : _d.experimentalOptimizer) == null ? void 0 : _e.web) == null ? void 0 : _f.enabled))
87
87
  return void 0;
88
88
  return environment === "happy-dom" || environment === "jsdom" ? "web" : "ssr";
89
89
  }
@@ -1,5 +1,5 @@
1
1
  import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
2
- import { e as bench, c as createExpect, d as globalExpect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.23b98fa1.js';
2
+ import { e as bench, c as createExpect, d as globalExpect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.55d2bc52.js';
3
3
  import { i as isFirstRun, a as runOnce } from './vendor-run-once.69ce7172.js';
4
4
  import * as chai from 'chai';
5
5
  import { assert, should } from 'chai';
@@ -10,7 +10,7 @@ async function setupCommonEnv(config) {
10
10
  globalSetup = true;
11
11
  setSafeTimers();
12
12
  if (config.globals)
13
- (await import('./chunk-integrations-globals.6a234998.js')).registerApiGlobally();
13
+ (await import('./chunk-integrations-globals.277730ba.js')).registerApiGlobally();
14
14
  }
15
15
  function setupDefines(defines) {
16
16
  for (const key in defines)