vitest 5.1.0-beta.1 → 5.1.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.
Files changed (58) hide show
  1. package/dist/browser.d.ts +6 -5
  2. package/dist/browser.js +6 -6
  3. package/dist/chunks/{base.PJyN9N0u.js → base.Cof-UHJf.js} +14 -19
  4. package/dist/chunks/{browser.d.D7a15z82.d.ts → browser.d.C7tWgUvw.d.ts} +3 -3
  5. package/dist/chunks/{cac.Ccf5Je_F.js → cac.BYbt0aJp.js} +22 -20
  6. package/dist/chunks/{cli-api.DE22LIzq.js → cli-api.COfZo8lK.js} +714 -73
  7. package/dist/chunks/{config.d.BgktgHfG.d.ts → config.d.B3YV4t0O.d.ts} +37 -2
  8. package/dist/chunks/{console.DrMPSuFo.js → console.CQZ877Hi.js} +2 -2
  9. package/dist/chunks/{coverage.-bm5IxnW.js → coverage.9iqXE2gN.js} +1 -1
  10. package/dist/chunks/{coverage.cTDc4uSS.js → coverage.jGCktcGP.js} +1 -1
  11. package/dist/chunks/{creator.BQ3onxbh.js → creator.DHWmytIK.js} +10 -10
  12. package/dist/chunks/{doctor.CPlMs7-y.js → doctor.B-oPbwps.js} +2 -2
  13. package/dist/chunks/{environment.d.CbTLsZSj.d.ts → environment.d.BFQtFKdZ.d.ts} +1 -1
  14. package/dist/chunks/{globals.TipXUFcZ.js → globals.ZKtKSkEf.js} +6 -5
  15. package/dist/chunks/{index.BFXLpwll.js → index.Bi0NXYPf.js} +58 -32
  16. package/dist/chunks/{index.BXttT2gP.js → index.CZzC1gGg.js} +265 -425
  17. package/dist/chunks/{index.D14IAvnE.js → index.Di8au7q4.js} +68 -62
  18. package/dist/chunks/{index.B03wg4V0.js → index.w_oBZ9N8.js} +5 -5
  19. package/dist/chunks/{init-forks.BL1E3__4.js → init-forks.BaDXQSD8.js} +1 -1
  20. package/dist/chunks/{init-threads.CYXAGzKQ.js → init-threads.ZX_Vov0z.js} +1 -1
  21. package/dist/chunks/{init.DVorxUyL.js → init.CO4AB7HZ.js} +4 -4
  22. package/dist/chunks/{module-dependencies.CwNPkcV4.js → module-dependencies._2Eei3FO.js} +1 -1
  23. package/dist/chunks/{native.cdzHIdmv.js → native.upB-V0CK.js} +1 -1
  24. package/dist/chunks/{nativeModuleMocker.3uBcOd84.js → nativeModuleMocker.Dh5azSB4.js} +3 -3
  25. package/dist/chunks/{nativeModuleRunner.xi64Afb2.js → nativeModuleRunner.9xPIMzi7.js} +1 -1
  26. package/dist/chunks/{node.uQulW0ei.js → node.B9mkVmLH.js} +1 -1
  27. package/dist/chunks/{pathe.M-eThtNZ.Ba-7h1rE.js → pathe.M-eThtNZ.zq3TM4NT.js} +1 -1
  28. package/dist/chunks/{plugin.d.olEn8IL9.d.ts → plugin.d.LRFSN46m.d.ts} +90 -19
  29. package/dist/chunks/rawSnapshot.DqSiqIEx.js +356 -0
  30. package/dist/chunks/{resolver.CtCcxIy1.js → resolver.BzpmeQeT.js} +1 -1
  31. package/dist/chunks/{rpc.BV0XpJ5q.js → rpc.Uhkwr2NM.js} +2 -2
  32. package/dist/chunks/{rpc.d.DGFP7vWr.d.ts → rpc.d.3FOhdFx8.d.ts} +1 -1
  33. package/dist/chunks/{run.BfrMbGVD.js → run.CjdgFZiW.js} +7 -4
  34. package/dist/chunks/{setup-common.llxJkJaD.js → setup-common.CqAQCXzx.js} +2 -2
  35. package/dist/chunks/{source-map.BjWcsIL9.js → source-map.DakdQc29.js} +11 -13
  36. package/dist/chunks/{source-map.d.C5A_Tr6V.d.ts → source-map.d.BkG8YK_3.d.ts} +1 -1
  37. package/dist/chunks/{task-utils.d.BUh7ylUT.d.ts → task-utils.d.D-gFPNFi.d.ts} +1 -1
  38. package/dist/chunks/{utils.DSfl_w8V.js → utils.BBk_icFG.js} +6 -3
  39. package/dist/chunks/{vm.Cwj01UFE.js → vm.b4MbCAJQ.js} +15 -13
  40. package/dist/chunks/{worker.d.gsA26mmR.d.ts → worker.d.CyJRpyfZ.d.ts} +3 -3
  41. package/dist/cli.js +2 -2
  42. package/dist/config.d.ts +8 -8
  43. package/dist/index.d.ts +17 -12
  44. package/dist/index.js +6 -5
  45. package/dist/module-evaluator.d.ts +2 -2
  46. package/dist/node.d.ts +10 -10
  47. package/dist/node.js +15 -13
  48. package/dist/runtime.d.ts +4 -4
  49. package/dist/runtime.js +4 -4
  50. package/dist/task-utils.js +7 -3
  51. package/dist/worker.d.ts +4 -4
  52. package/dist/worker.js +14 -13
  53. package/dist/workers/forks.js +15 -14
  54. package/dist/workers/runVmTests.js +13 -10
  55. package/dist/workers/threads.js +15 -14
  56. package/dist/workers/vmForks.js +10 -10
  57. package/dist/workers/vmThreads.js +10 -10
  58. package/package.json +15 -15
@@ -1,7 +1,7 @@
1
1
  import { promises, existsSync, mkdirSync, writeFileSync, linkSync, renameSync, rmSync, chmodSync, readFileSync, statfsSync, realpathSync, statSync, readdirSync } from 'node:fs';
2
2
  import url, { pathToFileURL, fileURLToPath } from 'node:url';
3
- import { c as cleanUrl, r as resolve, f as extname, d as dirname, j as join, h as KNOWN_ASSET_RE, H as withTrailingSlash, I as wrapId, i as isAbsolute, J as isExternalUrl, L as unwrapId, a as relative, z as unique, s as slash, t as toArray, b as basename, m as isPrimitive, n as normalize, G as deepMerge, e as createDefer, p as deepClone } from './pathe.M-eThtNZ.Ba-7h1rE.js';
4
- import { N as NativeModuleRunner, i as isPackageExists, r as resolveModule } from './nativeModuleRunner.xi64Afb2.js';
3
+ import { c as cleanUrl, r as resolve, k as extname, d as dirname, j as join, l as KNOWN_ASSET_RE, H as withTrailingSlash, I as wrapId, i as isAbsolute, J as isExternalUrl, L as unwrapId, a as relative, A as unique, s as slash, t as toArray, b as basename, p as isPrimitive, n as normalize, G as deepMerge, e as createDefer, u as deepClone } from './pathe.M-eThtNZ.zq3TM4NT.js';
4
+ import { N as NativeModuleRunner, i as isPackageExists, r as resolveModule } from './nativeModuleRunner.9xPIMzi7.js';
5
5
  import { glob, isDynamicPattern } from 'tinyglobby';
6
6
  import { $ } from './tinyrainbow.Do8I1XRG.js';
7
7
  import * as vite from 'vite';
@@ -22,22 +22,22 @@ import { Writable } from 'node:stream';
22
22
  import { stripVTControlCharacters } from 'node:util';
23
23
  import { i as inspect } from './display.BlTmubjj.js';
24
24
  import { performance as performance$1 } from 'node:perf_hooks';
25
- import { T as TraceMap, o as originalPositionFor, i as generatedPositionFor, j as eachMapping, k as stackIgnorePatterns, e as parseErrorStacktrace } from './source-map.BjWcsIL9.js';
25
+ import { T as TraceMap, o as originalPositionFor, i as generatedPositionFor, j as eachMapping, k as stackIgnorePatterns, e as parseErrorStacktrace } from './source-map.DakdQc29.js';
26
26
  import { x } from 'tinyexec';
27
- import { B as validateTags, z as limitConcurrency, C as shuffle } from './run.BfrMbGVD.js';
27
+ import { C as validateTags, A as limitConcurrency, D as shuffle } from './run.CjdgFZiW.js';
28
28
  import { createDebug } from 'obug';
29
29
  import { createFileTask as createFileTask$1, createTaskName, calculateSuiteHash, convertTasksToEvents, hasFailed, generateFileHash } from '../task-utils.js';
30
30
  import { readFile, mkdir, writeFile, rm, stat } from 'node:fs/promises';
31
- import { l as lookupPackageScopeType } from './resolver.CtCcxIy1.js';
31
+ import { l as lookupPackageScopeType } from './resolver.BzpmeQeT.js';
32
32
  import * as esModuleLexer from 'es-module-lexer';
33
33
  import { ssrImportKey, ssrModuleExportsKey, ssrExportAllKey, ssrImportMetaKey, ModuleRunner } from 'vite/module-runner';
34
34
  import path, { resolve as resolve$1 } from 'node:path';
35
35
  import { p as positionToOffset, l as lineSplitRE } from './offset.Dy-5Fdfn.js';
36
- import { i as errorBanner, a as F_POINTER, j as divider, o as truncateString, w as withLabel, c as formatProjectName } from './utils.DSfl_w8V.js';
36
+ import { k as errorBanner, c as F_POINTER, l as divider, q as truncateString, w as withLabel, e as formatProjectName } from './utils.BBk_icFG.js';
37
37
  import { VitestModuleEvaluator } from '#module-evaluator';
38
38
  import pm from 'picomatch';
39
- import { t as trackNativeImports, c as collectDependencies, n as nativeImports, g as getEvaluatedImports } from './module-dependencies.CwNPkcV4.js';
40
- import { g as getCoverageFilesDirectory } from './coverage.cTDc4uSS.js';
39
+ import { t as trackNativeImports, c as collectDependencies, n as nativeImports, g as getEvaluatedImports } from './module-dependencies._2Eei3FO.js';
40
+ import { g as getCoverageFilesDirectory } from './coverage.jGCktcGP.js';
41
41
  import { isAgent, isCI, provider } from 'std-env';
42
42
  import process$1 from 'node:process';
43
43
  import { isatty } from 'node:tty';
@@ -45,7 +45,7 @@ import EventEmitter$1, { EventEmitter } from 'node:events';
45
45
  import { c as createBirpc } from './index.DmDMHCg8.js';
46
46
  import { fork } from 'node:child_process';
47
47
  import { Worker } from 'node:worker_threads';
48
- import { v as version$1 } from './cac.Ccf5Je_F.js';
48
+ import { v as version$1 } from './cac.BYbt0aJp.js';
49
49
  import { g as getDefaultExportFromCjs } from './index.D0heQG4v.js';
50
50
  import require$$0 from 'readline';
51
51
  import require$$0$1 from 'events';
@@ -877,7 +877,7 @@ function findRedirect(config, specifier, resolvedId) {
877
877
  const id = resolvedId ?? specifier;
878
878
  const moduleDirectories = config.deps.moduleDirectories ?? ["/node_modules/"];
879
879
  const external = !isAbsolute(id) || moduleDirectories.some((dir) => id.includes(dir)) ? specifier : null;
880
- return findMockRedirect(config.root, cleanUrl(id), external);
880
+ return findMockRedirect(config.root, cleanUrl(id), external, specifier);
881
881
  }
882
882
 
883
883
  const debugFs = createDebugger("vitest:cache:fs");
@@ -997,7 +997,8 @@ class ModuleTransformService {
997
997
  const imports = this.getCachedImports(environment, moduleGraphModule);
998
998
  const map = moduleGraphModule.transformResult?.map;
999
999
  const mappings = map && !("version" in map) && map.mappings === "";
1000
- const cachedResult = await this.cacheResult(result, cachePath, moduleGraphModule.transformResult, imports, !!mappings);
1000
+ const coverageData = this.fsCache.getCoverageData(environment, moduleGraphModule.id);
1001
+ const cachedResult = await this.cacheResult(result, cachePath, moduleGraphModule.transformResult, imports, !!mappings, coverageData);
1001
1002
  // remember where the code is stored on disk so that repeat fetches and the
1002
1003
  // `fetchWarmModules` snapshot can point at it in this session already, not
1003
1004
  // only after the cache is read back in the next one
@@ -1033,7 +1034,7 @@ class ModuleTransformService {
1033
1034
  if ("code" in result) trace.setAttribute("vitest.fetched_module.code_length", result.code.length);
1034
1035
  }
1035
1036
  async getCachePath(environment, moduleGraphModule) {
1036
- if (!this.fsCacheEnabled) return null;
1037
+ if (!this.fsCacheEnabled || this.fsCache.getCacheRoot(this.config) == null) return null;
1037
1038
  const moduleId = moduleGraphModule.id;
1038
1039
  const memoryCacheKey = this.fsCache.getMemoryCachePath(environment, moduleId);
1039
1040
  // undefined means there is no key in memory
@@ -1073,6 +1074,8 @@ class ModuleTransformService {
1073
1074
  if (!cachedModule) return;
1074
1075
  const importedModules = await this.resolveCachedImports(environment, cachedModule);
1075
1076
  if (!importedModules) return;
1077
+ // Notify coverage provider that cached results were read
1078
+ if (cachedModule.hasCoverageData) this.fsCache.restoreCoverageData(environment, cachedModule.id, cachedModule.coverageData);
1076
1079
  // keep the module graph in sync
1077
1080
  let map = extractSourceMap(cachedModule.code);
1078
1081
  if (map && cachedModule.file) map.file = cachedModule.file;
@@ -1153,10 +1156,10 @@ class ModuleTransformService {
1153
1156
  if (transformResult) transformResult.__vitestModuleType = moduleType;
1154
1157
  return moduleType;
1155
1158
  }
1156
- async cacheResult(result, cachePath, transformResult, imports, mappings = false) {
1159
+ async cacheResult(result, cachePath, transformResult, imports, mappings = false, coverageData) {
1157
1160
  const returnResult = "code" in result ? getCachedResult(result, cachePath) : result;
1158
1161
  if (saveCachePromises.has(cachePath)) return saveCachePromises.get(cachePath);
1159
- const savePromise = this.fsCache.saveCachedModule(cachePath, result, transformResult, imports, mappings).then(() => returnResult).catch((error) => {
1162
+ const savePromise = this.fsCache.saveCachedModule(cachePath, result, transformResult, imports, mappings, coverageData).then(() => returnResult).catch((error) => {
1160
1163
  debugFs?.(`failed to cache ${cachePath}, serving it inline: ${error}`);
1161
1164
  return result;
1162
1165
  }).finally(() => {
@@ -1838,7 +1841,7 @@ async function createClusterServer(vitest, viteConfig, config, children) {
1838
1841
  const contribution = config._browserContribution;
1839
1842
  if (!contribution) {
1840
1843
  const server = await createViteServer(viteConfig);
1841
- if (config.api.port) await server.listen(config.api.port);
1844
+ if (config.api.port != null) await server.listen(config.api.port);
1842
1845
  return { server };
1843
1846
  }
1844
1847
  const parent = contribution.createParent({
@@ -3583,7 +3586,7 @@ class ServerModuleRunner extends ModuleRunner {
3583
3586
  try {
3584
3587
  const result = await transformService.fetch(data[0], data[1], environment, false, data[2]);
3585
3588
  if ("tmp" in result) {
3586
- const code = await readFile(result.tmp);
3589
+ const code = await readFile(result.tmp, "utf-8");
3587
3590
  return { result: {
3588
3591
  ...result,
3589
3592
  code
@@ -4147,6 +4150,8 @@ function serializeConfig(project) {
4147
4150
  viteModuleRunner: config.experimental.viteModuleRunner ?? true,
4148
4151
  nodeLoader: config.experimental.nodeLoader ?? true,
4149
4152
  recordDependencies: !!globalConfig.experimental.recordDependencies && !!globalConfig.cache,
4153
+ // browser mode records its own trace through `browser.traceView`
4154
+ traceTimeline: !!config.experimental.traceTimeline && !config.browser.enabled,
4150
4155
  openTelemetry: config.experimental.openTelemetry
4151
4156
  },
4152
4157
  tags: config.tags || [],
@@ -6151,6 +6156,7 @@ function createPool(ctx) {
6151
6156
  testNames: spec.testNames,
6152
6157
  testTagsFilter: spec.testTagsFilter
6153
6158
  })),
6159
+ // Vitest's own pools don't read it, but a custom pool whose worker outlives a run can use it
6154
6160
  invalidates,
6155
6161
  providedContext: project.getProvidedContext(),
6156
6162
  workerId: workerId++,
@@ -6354,6 +6360,22 @@ async function globProjectTestFiles(include, exclude, includeSource, cwd) {
6354
6360
  }
6355
6361
  return testFiles;
6356
6362
  }
6363
+ /**
6364
+ * Keep the test files that match the CLI filters. With no filters, every file matches.
6365
+ */
6366
+ function filterTestFiles(testFiles, filters, dir) {
6367
+ if (!filters.length) return testFiles;
6368
+ if (process.platform === "win32") filters = filters.map((f) => slash(f));
6369
+ return testFiles.filter((t) => {
6370
+ const testFile = relative(dir, t).toLocaleLowerCase();
6371
+ return filters.some((f) => {
6372
+ // if filter is a full file path, we should include it if it's in the same folder
6373
+ if (isAbsolute(f) && t.startsWith(f)) return true;
6374
+ const relativePath = f.endsWith("/") ? join(relative(dir, f), "/") : relative(dir, f);
6375
+ return testFile.includes(f.toLocaleLowerCase()) || testFile.includes(relativePath.toLocaleLowerCase());
6376
+ });
6377
+ });
6378
+ }
6357
6379
 
6358
6380
  class TestSpecification {
6359
6381
  /**
@@ -6610,8 +6632,8 @@ class TestProject {
6610
6632
  const [testFiles, typecheckTestFiles] = await Promise.all([typecheck.enabled && typecheck.only ? [] : this.globAllTestFiles(include, exclude, includeSource, dir), typecheck.enabled ? this.typecheckFilesList || this.globFiles(typecheck.include, typecheck.exclude, dir) : []]);
6611
6633
  this.typecheckFilesList = typecheckTestFiles;
6612
6634
  return {
6613
- testFiles: this.filterFiles(testFiles, filters, dir),
6614
- typecheckTestFiles: this.filterFiles(typecheckTestFiles, filters, dir)
6635
+ testFiles: filterTestFiles(testFiles, filters, dir),
6636
+ typecheckTestFiles: filterTestFiles(typecheckTestFiles, filters, dir)
6615
6637
  };
6616
6638
  });
6617
6639
  }
@@ -6669,19 +6691,6 @@ class TestProject {
6669
6691
  }
6670
6692
  return false;
6671
6693
  }
6672
- filterFiles(testFiles, filters, dir) {
6673
- if (filters.length && process.platform === "win32") filters = filters.map((f) => slash(f));
6674
- if (filters.length) return testFiles.filter((t) => {
6675
- const testFile = relative(dir, t).toLocaleLowerCase();
6676
- return filters.some((f) => {
6677
- // if filter is a full file path, we should include it if it's in the same folder
6678
- if (isAbsolute(f) && t.startsWith(f)) return true;
6679
- const relativePath = f.endsWith("/") ? join(relative(dir, f), "/") : relative(dir, f);
6680
- return testFile.includes(f.toLocaleLowerCase()) || testFile.includes(relativePath.toLocaleLowerCase());
6681
- });
6682
- });
6683
- return testFiles;
6684
- }
6685
6694
  /**
6686
6695
  * The parent browser project that owns this cluster's single Vite server.
6687
6696
  * Set on the primary (the hidden parent of a browser cluster) at server
@@ -6962,10 +6971,10 @@ async function resolveProjectEntries(harness, globalViteConfig, globalConfig, de
6962
6971
  `The projects definition: ${JSON.stringify(definitions.map((p, index) => typeof p === "string" ? p : p instanceof Promise ? "Promise" : typeof p === "function" ? p.name : { name: p.test?.name ?? index }), null, 4)}.`
6963
6972
  ].join(""));
6964
6973
  debug?.(`resolved projects: ${filtered.filter((e) => !e.hidden).map((e) => projectLabel(e.projectConfig.name)).join(", ")}`);
6965
- await applyBrowserOptimizeDeps(harness, filtered);
6974
+ await applyBrowserOptimizeDeps(harness, filtered, globalConfig._cliFilters ?? []);
6966
6975
  return filtered;
6967
6976
  }
6968
- async function applyBrowserOptimizeDeps(harness, entries) {
6977
+ async function applyBrowserOptimizeDeps(harness, entries, cliFilters) {
6969
6978
  const groups = /* @__PURE__ */ new Map();
6970
6979
  for (const entry of entries) {
6971
6980
  const { viteConfig } = entry;
@@ -7001,7 +7010,8 @@ async function applyBrowserOptimizeDeps(harness, entries) {
7001
7010
  if (!contribution) return;
7002
7011
  const fileLists = await Promise.all(projectConfigs.map(globTestFiles));
7003
7012
  projectEntries.forEach((entry, index) => {
7004
- entry.hasTestFiles = fileLists[index].length > 0;
7013
+ const config = projectConfigs[index];
7014
+ entry.hasTestFiles = filterTestFiles(fileLists[index], cliFilters, config.dir || config.root).length > 0;
7005
7015
  });
7006
7016
  const testFiles = [...new Set(fileLists.flat())];
7007
7017
  debug?.(`aggregating browser optimizeDeps from ${testFiles.length} test files of ${projectEntries.map((e) => projectLabel(e.projectConfig.name)).join(", ")}`);
@@ -7588,7 +7598,7 @@ async function resolveTestProjectConfigs(parentViteConfig, parentConfig, project
7588
7598
  // directories that don't have a config file inside, but should be treated as projects
7589
7599
  const nonConfigProjectDirectories = [];
7590
7600
  for (const definition of projectsDefinition) if (typeof definition === "string") {
7591
- const stringOption = definition.replace("<rootDir>", parentConfig.root);
7601
+ const stringOption = definition.replace("<rootDir>", () => parentConfig.root);
7592
7602
  // if the string doesn't contain a glob, we can resolve it directly
7593
7603
  // ['./vitest.config.js']
7594
7604
  if (!isDynamicPattern(stringOption)) {
@@ -8537,18 +8547,14 @@ class Logger {
8537
8547
  this.log(withLabel(color, mode, `v${this.ctx.version} `) + $.gray(this.ctx.config.root));
8538
8548
  const seed = this.ctx.getSeed();
8539
8549
  if (seed != null) this.log(PAD + $.gray(`Running tests with seed "${seed}"`));
8540
- if (this.ctx.config.ui) {
8541
- const host = this.ctx.config.api?.host || "localhost";
8542
- const port = this.ctx.vite.config.server.port;
8543
- const url = new URL(this.ctx.config.uiBase, `http://${host}:${port}`);
8544
- url.searchParams.set("token", this.ctx.config.api.token);
8545
- this.log(PAD + $.dim($.green(`UI started at ${url}`)));
8546
- } else if (this.ctx.config.api?.port && this.ctx.config._apiRequested) {
8547
- const resolvedUrls = this.ctx.vite.resolvedUrls;
8548
- // workaround for https://github.com/vitejs/vite/issues/15438, it was fixed in vite 5.1
8549
- const fallbackUrl = `http://${this.ctx.config.api.host || "localhost"}:${this.ctx.config.api.port}`;
8550
- const origin = resolvedUrls?.local[0] ?? resolvedUrls?.network[0] ?? fallbackUrl;
8551
- this.log(PAD + $.dim($.green(`API started at ${new URL("/", origin)}`)));
8550
+ const resolvedUrls = this.ctx.vite.resolvedUrls;
8551
+ const origin = resolvedUrls?.local[0] ?? resolvedUrls?.network[0];
8552
+ if (origin && this.ctx.config._apiRequested) {
8553
+ if (this.ctx.config.ui) {
8554
+ const url = new URL(this.ctx.config.uiBase, origin);
8555
+ url.searchParams.set("token", this.ctx.config.api.token);
8556
+ this.log(PAD + $.dim($.green(`UI started at ${url}`)));
8557
+ } else this.log(PAD + $.dim($.green(`API started at ${new URL("/", origin)}`)));
8552
8558
  }
8553
8559
  if (this.ctx.coverageProvider) this.log(PAD + $.dim("Coverage enabled with ") + $.yellow(this.ctx.coverageProvider.name));
8554
8560
  if (this.ctx.config.standalone) this.log($.yellow(`\nVitest is running in standalone mode. Edit a test file to rerun tests.\n`));
@@ -8730,14 +8736,14 @@ function resolveApiServerConfig(config, defaultPort, logger) {
8730
8736
  } else api = { ...config.api };
8731
8737
  }
8732
8738
  if (api) {
8733
- if (!api.port && !api.middlewareMode) api.port = defaultPort;
8739
+ if (api.port == null && !api.middlewareMode) api.port = defaultPort;
8734
8740
  } else api = { middlewareMode: true };
8735
8741
  if (api && isBrowserEnabled) {
8736
8742
  // Always force middlewareMode to false in browser mode
8737
8743
  api.middlewareMode = false;
8738
8744
  // The browser server is standalone, so it always needs a port even when the
8739
8745
  // user didn't configure `api`/`ui` (in which case `api` defaulted above)
8740
- if (!api.port) api.port = defaultPort;
8746
+ if (api.port == null) api.port = defaultPort;
8741
8747
  }
8742
8748
  // if the API server is exposed to network, disable write operations by default
8743
8749
  if (!api.middlewareMode && api.host && api.host !== "localhost" && api.host !== "127.0.0.1") {
@@ -8799,6 +8805,7 @@ function resolveTestConfig(logger, options, viteConfig, globalConfig) {
8799
8805
  resolved.coverage = globalConfig.coverage;
8800
8806
  resolved.attachmentsDir = globalConfig.attachmentsDir;
8801
8807
  resolved.mergeReportsLabel = globalConfig.mergeReportsLabel;
8808
+ resolved.watch = globalConfig.watch;
8802
8809
  }
8803
8810
  if (!statSync(resolved.root, { throwIfNoEntry: false })?.isDirectory()) throw new Error(`Root path does not exist or is not a directory: ${resolved.root}`);
8804
8811
  resolved.mode ??= viteConfig.mode ?? "test";
@@ -9161,24 +9168,22 @@ function resolveTestConfig(logger, options, viteConfig, globalConfig) {
9161
9168
  } else if (resolved.ui) resolved.includeTaskLocation ??= true;
9162
9169
  if (typeof resolved.browser.trace === "string" || !resolved.browser.trace) resolved.browser.trace = { mode: resolved.browser.trace || "off" };
9163
9170
  const traceView = resolved.browser.traceView;
9164
- resolved.browser.traceView = typeof traceView === "object" ? {
9165
- enabled: traceView.enabled ?? false,
9166
- recordCanvas: traceView.recordCanvas ?? false,
9167
- inlineImages: traceView.inlineImages ?? false,
9168
- ariaSnapshot: traceView.ariaSnapshot ?? true
9169
- } : {
9170
- enabled: traceView ?? false,
9171
- recordCanvas: false,
9172
- inlineImages: false,
9173
- ariaSnapshot: true
9171
+ const traceViewOptions = typeof traceView === "object" ? traceView : void 0;
9172
+ if (traceViewOptions?.enabled != null) logger.deprecate("`browser.traceView.enabled` is deprecated. Use `browser.traceView.mode` instead.");
9173
+ const traceViewMode = typeof traceView === "string" ? traceView : typeof traceView === "object" ? traceView.mode ?? (traceView.enabled === void 0 ? "failure-only" : traceView.enabled ? "on" : "off") : traceView === void 0 ? "failure-only" : traceView ? "on" : "off";
9174
+ resolved.browser.traceView = {
9175
+ enabled: traceViewMode !== "off",
9176
+ mode: traceViewMode,
9177
+ recordCanvas: traceViewOptions?.recordCanvas ?? false,
9178
+ inlineImages: traceViewOptions?.inlineImages ?? false,
9179
+ ariaSnapshot: traceViewOptions?.ariaSnapshot ?? true
9174
9180
  };
9175
- if (resolved.browser.enabled && resolved.browser.traceView.enabled) resolved.browser.detailsPanelPosition = "bottom";
9181
+ if (resolved.browser.enabled && resolved.browser.traceView.mode === "on") resolved.browser.detailsPanelPosition = "bottom";
9176
9182
  if (resolved.browser.trace.tracesDir != null) resolved.browser.trace.tracesDir = resolvePath(resolved.browser.trace.tracesDir, resolved.root);
9177
9183
  if (toArray(resolved.reporters).some((reporter) => {
9178
9184
  if (Array.isArray(reporter)) return reporter[0] === "html";
9179
9185
  return false;
9180
9186
  })) resolved.includeTaskLocation ??= true;
9181
- else if (resolved.browser.enabled && resolved.browser.traceView.enabled && !resolved.watch) logger.console.warn($.yellow(withLabel("yellow", "Vitest", "--browser.traceView is enabled without the HTML reporter.")));
9182
9187
  resolved.server ??= {};
9183
9188
  resolved.server.deps ??= {};
9184
9189
  if (resolved.server.debug?.dump || process.env.VITEST_DEBUG_DUMP) {
@@ -9269,7 +9274,7 @@ function resolveConfigPath(root, options) {
9269
9274
  if (options.config) return resolveModule(options.config, { paths: [root] }) ?? resolve(root, options.config);
9270
9275
  return findConfigFile(root);
9271
9276
  }
9272
- async function resolveConfig(options = {}, viteOverrides = {}, pluginsHarness = new PluginHarness()) {
9277
+ async function resolveConfig(options = {}, viteOverrides = {}, pluginsHarness = new PluginHarness(), cliFilters = []) {
9273
9278
  // We clone CLI Options and Vite overrides to reuse when a watch mode is triggered.
9274
9279
  const cliOptionsCopy = deepMerge({}, options);
9275
9280
  const viteOverridesCopy = deepMerge({}, viteOverrides);
@@ -9326,6 +9331,7 @@ async function resolveConfig(options = {}, viteOverrides = {}, pluginsHarness =
9326
9331
  rootConfig.cliOptions = cliOptionsCopy;
9327
9332
  rootConfig.viteOverrides = viteOverridesCopy;
9328
9333
  rootConfig._browserContribution = captures.browserContribution;
9334
+ rootConfig._cliFilters = cliFilters;
9329
9335
  // projects never inherit `tagsFilter` and `browser` from the programmatic
9330
9336
  // config (see `inheritRootViteOverrides`), so remove them from the base too
9331
9337
  if (captures.rawTestConfig) {
@@ -1,10 +1,10 @@
1
1
  import * as chai from 'chai';
2
2
  import { createHook } from 'node:async_hooks';
3
- import { t as takeCoverageInsideWorker } from './coverage.-bm5IxnW.js';
4
- import { r as rpc } from './rpc.BV0XpJ5q.js';
5
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.llxJkJaD.js';
3
+ import { t as takeCoverageInsideWorker } from './coverage.9iqXE2gN.js';
4
+ import { r as rpc } from './rpc.Uhkwr2NM.js';
5
+ import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.CqAQCXzx.js';
6
6
  import { g as getWorkerState } from './utils.DYj33du9.js';
7
- import { T as TestRunner } from './index.BXttT2gP.js';
7
+ import { T as TestRunner } from './index.CZzC1gGg.js';
8
8
 
9
9
  function setupChaiConfig(config) {
10
10
  Object.assign(chai.config, config);
@@ -12,7 +12,7 @@ function setupChaiConfig(config) {
12
12
 
13
13
  async function resolveSnapshotEnvironment(config, moduleRunner) {
14
14
  if (!config.snapshotEnvironment) {
15
- const { VitestNodeSnapshotEnvironment } = await import('./node.uQulW0ei.js');
15
+ const { VitestNodeSnapshotEnvironment } = await import('./node.B9mkVmLH.js');
16
16
  return new VitestNodeSnapshotEnvironment();
17
17
  }
18
18
  const mod = await moduleRunner.import(config.snapshotEnvironment);
@@ -1,4 +1,4 @@
1
- import { i as init } from './init.DVorxUyL.js';
1
+ import { i as init } from './init.CO4AB7HZ.js';
2
2
 
3
3
  if (!process.send) throw new Error("Expected worker to be run in node:child_process");
4
4
  // Store globals in case tests overwrite them
@@ -1,5 +1,5 @@
1
1
  import { isMainThread, parentPort } from 'node:worker_threads';
2
- import { i as init } from './init.DVorxUyL.js';
2
+ import { i as init } from './init.CO4AB7HZ.js';
3
3
 
4
4
  if (isMainThread || !parentPort) throw new Error("Expected worker to be run in node:worker_threads");
5
5
  function workerInit(options) {
@@ -2,12 +2,12 @@ import { readFileSync } from 'node:fs';
2
2
  import module$1, { isBuiltin } from 'node:module';
3
3
  import { pathToFileURL } from 'node:url';
4
4
  import { EvaluatedModules, ModuleRunner } from 'vite/module-runner';
5
- import { e as environments, b as VitestTransport } from './index.BFXLpwll.js';
6
- import { r as resolve } from './pathe.M-eThtNZ.Ba-7h1rE.js';
7
- import { b as serializeValue, c as createStackString, p as parseStacktrace } from './source-map.BjWcsIL9.js';
5
+ import { e as environments, b as VitestTransport } from './index.Bi0NXYPf.js';
6
+ import { r as resolve } from './pathe.M-eThtNZ.zq3TM4NT.js';
7
+ import { b as serializeValue, c as createStackString, p as parseStacktrace } from './source-map.DakdQc29.js';
8
8
  import { w } from './tinyrainbow.Do8I1XRG.js';
9
9
  import { Traces } from '../traces.js';
10
- import { o as onCancel, V as VitestEvaluatedModules, a as rpcDone, c as createRuntimeRpc } from './rpc.BV0XpJ5q.js';
10
+ import { o as onCancel, V as VitestEvaluatedModules, a as rpcDone, c as createRuntimeRpc } from './rpc.Uhkwr2NM.js';
11
11
  import { s as setupInspect } from './inspector.CvyFGlXm.js';
12
12
  import { E as EnvironmentTeardownError } from './utils.DYj33du9.js';
13
13
 
@@ -1,6 +1,6 @@
1
1
  import module$1 from 'node:module';
2
2
  import { fileURLToPath } from 'node:url';
3
- import { s as slash } from './pathe.M-eThtNZ.Ba-7h1rE.js';
3
+ import { s as slash } from './pathe.M-eThtNZ.zq3TM4NT.js';
4
4
  import { distDir } from '../path.js';
5
5
 
6
6
  const vitestDistDir = `${slash(distDir)}/`;
@@ -2,7 +2,7 @@ import module$1, { isBuiltin } from 'node:module';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import { MessageChannel } from 'node:worker_threads';
4
4
  import { initSyntaxLexers, hoistMocks } from '@vitest/mocker/transforms';
5
- import { c as cleanUrl, r as resolve } from './pathe.M-eThtNZ.Ba-7h1rE.js';
5
+ import { c as cleanUrl, r as resolve } from './pathe.M-eThtNZ.zq3TM4NT.js';
6
6
  import { p as parse } from './acorn.C1kjbUFw.js';
7
7
  import MagicString from 'magic-string';
8
8
  import { $ } from './tinyrainbow.Do8I1XRG.js';
@@ -1,10 +1,10 @@
1
1
  import module$1, { isBuiltin } from 'node:module';
2
2
  import { fileURLToPath, pathToFileURL } from 'node:url';
3
3
  import { automockModule, createManualModuleSource, collectModuleExports } from '@vitest/mocker/transforms';
4
- import { c as cleanUrl, e as createDefer, i as isAbsolute } from './pathe.M-eThtNZ.Ba-7h1rE.js';
4
+ import { c as cleanUrl, e as createDefer, i as isAbsolute } from './pathe.M-eThtNZ.zq3TM4NT.js';
5
5
  import { p as parse } from './acorn.C1kjbUFw.js';
6
6
  import { t as toBuiltin } from './modules.BJuCwlRJ.js';
7
- import { B as BareModuleMocker, n as normalizeModuleId } from './index.BFXLpwll.js';
7
+ import { B as BareModuleMocker, n as normalizeModuleId } from './index.Bi0NXYPf.js';
8
8
  import 'node:fs';
9
9
  import './utils.DYj33du9.js';
10
10
  import '../path.js';
@@ -185,7 +185,7 @@ export { __${index} as "${key}" }
185
185
  const filename = fileURLToPath(resolvedId);
186
186
  const external = !isAbsolute(filename) || this.isModuleDirectory(resolvedId) ? normalizeModuleId(rawId) : null;
187
187
  // file is not mocked, automock or redirect it
188
- const redirect = this.findMockRedirect(filename, external);
188
+ const redirect = this.findMockRedirect(filename, external, rawId);
189
189
  if (redirect) return import(pathToFileURL(redirect).toString());
190
190
  const url = new URL(resolvedId);
191
191
  url.searchParams.set("mock", "automock");
@@ -7,7 +7,7 @@ import fs from 'node:fs/promises';
7
7
  import assert from 'node:assert';
8
8
  import v8 from 'node:v8';
9
9
  import { format, inspect } from 'node:util';
10
- import { i as isAbsolute, r as resolve } from './pathe.M-eThtNZ.Ba-7h1rE.js';
10
+ import { i as isAbsolute, r as resolve } from './pathe.M-eThtNZ.zq3TM4NT.js';
11
11
  import { ModuleRunner } from 'vite/module-runner';
12
12
 
13
13
  const JOIN_LEADING_SLASH_RE = /^\.?\//;
@@ -1,6 +1,6 @@
1
1
  import { g as getWorkerState } from './utils.DYj33du9.js';
2
2
  import { promises, existsSync } from 'node:fs';
3
- import { i as isAbsolute, r as resolve, d as dirname, j as join, b as basename } from './pathe.M-eThtNZ.Ba-7h1rE.js';
3
+ import { i as isAbsolute, r as resolve, d as dirname, j as join, b as basename } from './pathe.M-eThtNZ.zq3TM4NT.js';
4
4
 
5
5
  class NodeSnapshotEnvironment {
6
6
  options;
@@ -489,4 +489,4 @@ const basename = function(p, extension) {
489
489
  return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
490
490
  };
491
491
 
492
- export { objectAttr as A, getCallLastIndex as B, CSS_LANGS_RE as C, noop as D, createSimpleStackTrace as E, sanitizeFilePath as F, deepMerge as G, withTrailingSlash as H, wrapId as I, isExternalUrl as J, KNOWN_ASSET_TYPES as K, unwrapId as L, relative as a, basename as b, cleanUrl as c, dirname as d, createDefer as e, extname as f, getType as g, KNOWN_ASSET_RE as h, isAbsolute as i, join as j, splitFileAndPostfix as k, isBareImport as l, isPrimitive as m, normalize as n, notNullish as o, deepClone as p, getOwnProperties as q, resolve as r, slash as s, toArray as t, isObject as u, filterOutComments as v, ordinal as w, assertTypes as x, isNegativeNaN as y, unique as z };
492
+ export { unique as A, objectAttr as B, CSS_LANGS_RE as C, noop as D, createSimpleStackTrace as E, sanitizeFilePath as F, deepMerge as G, withTrailingSlash as H, wrapId as I, isExternalUrl as J, KNOWN_ASSET_TYPES as K, unwrapId as L, relative as a, basename as b, cleanUrl as c, dirname as d, createDefer as e, isObject as f, getType as g, getCallLastIndex as h, isAbsolute as i, join as j, extname as k, KNOWN_ASSET_RE as l, splitFileAndPostfix as m, normalize as n, isBareImport as o, isPrimitive as p, notNullish as q, resolve as r, slash as s, toArray as t, deepClone as u, getOwnProperties as v, filterOutComments as w, ordinal as x, assertTypes as y, isNegativeNaN as z };