vitest 5.0.5 → 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 (62) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/browser.d.ts +6 -5
  3. package/dist/browser.js +6 -6
  4. package/dist/chunks/{base.CzXt2BO_.js → base.Cof-UHJf.js} +17 -21
  5. package/dist/chunks/{browser.d.FGQ9_rK6.d.ts → browser.d.C7tWgUvw.d.ts} +4 -3
  6. package/dist/chunks/{cac.CLrZKo1g.js → cac.BYbt0aJp.js} +30 -16
  7. package/dist/chunks/{cli-api.De07GUeT.js → cli-api.COfZo8lK.js} +5226 -4385
  8. package/dist/chunks/{config.d.QBNYCgFU.d.ts → config.d.B3YV4t0O.d.ts} +169 -93
  9. package/dist/chunks/{console.DtI4yxfN.js → console.CQZ877Hi.js} +6 -3
  10. package/dist/chunks/{constants.-juJ8b_4.js → constants.DLYM6cZY.js} +1 -1
  11. package/dist/chunks/{coverage.-bm5IxnW.js → coverage.9iqXE2gN.js} +1 -1
  12. package/dist/chunks/{coverage.cTDc4uSS.js → coverage.jGCktcGP.js} +1 -1
  13. package/dist/chunks/{creator.C5g4egeG.js → creator.DHWmytIK.js} +11 -11
  14. package/dist/chunks/{doctor.BK86Cncq.js → doctor.B-oPbwps.js} +2 -2
  15. package/dist/chunks/{environment.d.BY56MoGs.d.ts → environment.d.BFQtFKdZ.d.ts} +1 -1
  16. package/dist/chunks/{globals.CXEE6_2C.js → globals.ZKtKSkEf.js} +7 -6
  17. package/dist/chunks/{index.CK-t0WMg.js → index.Bi0NXYPf.js} +165 -62
  18. package/dist/chunks/{index.aTZaPVhf.js → index.CZzC1gGg.js} +299 -440
  19. package/dist/chunks/{index.1TqnEahn.js → index.Di8au7q4.js} +104 -72
  20. package/dist/chunks/{index.CoUIxZd4.js → index.w_oBZ9N8.js} +5 -5
  21. package/dist/chunks/{init-forks.CRxIPOJR.js → init-forks.BaDXQSD8.js} +1 -1
  22. package/dist/chunks/{init-threads.Dv3kwST_.js → init-threads.ZX_Vov0z.js} +1 -1
  23. package/dist/chunks/{init.PvxYpuCm.js → init.CO4AB7HZ.js} +4 -4
  24. package/dist/chunks/{module-dependencies.CwNPkcV4.js → module-dependencies._2Eei3FO.js} +1 -1
  25. package/dist/chunks/{native.cdzHIdmv.js → native.upB-V0CK.js} +1 -1
  26. package/dist/chunks/{nativeModuleMocker.BxrHJNAF.js → nativeModuleMocker.Dh5azSB4.js} +4 -3
  27. package/dist/chunks/{nativeModuleRunner.xi64Afb2.js → nativeModuleRunner.9xPIMzi7.js} +1 -1
  28. package/dist/chunks/{node.uQulW0ei.js → node.B9mkVmLH.js} +1 -1
  29. package/dist/chunks/{pathe.M-eThtNZ.Ba-7h1rE.js → pathe.M-eThtNZ.zq3TM4NT.js} +1 -1
  30. package/dist/chunks/{plugin.d.C8mmycim.d.ts → plugin.d.LRFSN46m.d.ts} +191 -32
  31. package/dist/chunks/rawSnapshot.DqSiqIEx.js +356 -0
  32. package/dist/chunks/{resolver.CtCcxIy1.js → resolver.BzpmeQeT.js} +1 -1
  33. package/dist/chunks/{rpc.DpkUyY1N.js → rpc.Uhkwr2NM.js} +2 -2
  34. package/dist/chunks/{rpc.d.Cft1biqy.d.ts → rpc.d.3FOhdFx8.d.ts} +1 -1
  35. package/dist/chunks/{run.BPv-BBRv.js → run.CjdgFZiW.js} +28 -7
  36. package/dist/chunks/{setup-common.HGAqWOnX.js → setup-common.CqAQCXzx.js} +2 -2
  37. package/dist/chunks/{source-map.DdKI5IHB.js → source-map.DakdQc29.js} +43 -37
  38. package/dist/chunks/{source-map.d.kzFtk_dj.d.ts → source-map.d.BkG8YK_3.d.ts} +2 -1
  39. package/dist/chunks/{task-utils.d.PFh2BV6Q.d.ts → task-utils.d.D-gFPNFi.d.ts} +2 -1
  40. package/dist/chunks/{utils.DSfl_w8V.js → utils.BBk_icFG.js} +6 -3
  41. package/dist/chunks/{vm.FGl2rw_t.js → vm.b4MbCAJQ.js} +27 -14
  42. package/dist/chunks/{worker.d.BH-r1bPu.d.ts → worker.d.CyJRpyfZ.d.ts} +3 -3
  43. package/dist/cli.js +3 -3
  44. package/dist/config.cjs +1 -1
  45. package/dist/config.d.ts +11 -11
  46. package/dist/config.js +1 -1
  47. package/dist/index.d.ts +21 -15
  48. package/dist/index.js +6 -5
  49. package/dist/module-evaluator.d.ts +3 -2
  50. package/dist/node.d.ts +30 -12
  51. package/dist/node.js +16 -14
  52. package/dist/runtime.d.ts +4 -4
  53. package/dist/runtime.js +5 -4
  54. package/dist/task-utils.js +10 -4
  55. package/dist/worker.d.ts +4 -4
  56. package/dist/worker.js +14 -13
  57. package/dist/workers/forks.js +15 -14
  58. package/dist/workers/runVmTests.js +16 -12
  59. package/dist/workers/threads.js +15 -14
  60. package/dist/workers/vmForks.js +11 -10
  61. package/dist/workers/vmThreads.js +11 -10
  62. package/package.json +17 -17
@@ -1,12 +1,12 @@
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';
8
8
  import { createServer, normalizePath, isFileLoadingAllowed, fetchModule, parseAst, searchForWorkspaceRoot, version, isRunnableDevEnvironment, mergeConfig, resolveConfig as resolveConfig$1 } from 'vite';
9
- import { a as defaultPort, c as configFiles, d as defaultBrowserPort, b as defaultInspectPort } from './constants.-juJ8b_4.js';
9
+ import { a as defaultPort, c as configFiles, d as defaultBrowserPort, b as defaultInspectPort } from './constants.DLYM6cZY.js';
10
10
  import { c as configDefaults, e as benchmarkConfigDefaults } from './defaults.B1FCaFfh.js';
11
11
  import { b as isWindows, i as isForceColor, a as isTTY } from './env.BKKtU2WC.js';
12
12
  import * as os from 'node:os';
@@ -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.DdKI5IHB.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.BPv-BBRv.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.CLrZKo1g.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");
@@ -915,14 +915,16 @@ class ModuleTransformService {
915
915
  */
916
916
  async transform(id, environment) {
917
917
  await this.traces.waitInit();
918
- const result = await this.traces.$("vitest.module.transform", (span) => this.fetchInSpan(span, id, void 0, environment));
918
+ // the module graph keeps the url of the first request, so it has to be the url that workers import
919
+ const url = normalizeResolvedIdToUrl(environment, id);
920
+ const result = await this.traces.$("vitest.module.transform", (span) => this.fetchInSpan(span, url, void 0, environment));
919
921
  // externalized modules are loaded by Node without a transform, like in a normal run
920
922
  if ("externalize" in result) return null;
921
923
  if ("id" in result) {
922
924
  const transformResult = environment.moduleGraph.getModuleById(result.id)?.transformResult;
923
925
  if (transformResult) return transformResult;
924
926
  }
925
- return environment.transformRequest(id);
927
+ return environment.transformRequest(url);
926
928
  }
927
929
  async fetchInSpan(trace, url, importer, environment, makeTmpCopies, options) {
928
930
  if (url.startsWith("data:")) {
@@ -995,7 +997,8 @@ class ModuleTransformService {
995
997
  const imports = this.getCachedImports(environment, moduleGraphModule);
996
998
  const map = moduleGraphModule.transformResult?.map;
997
999
  const mappings = map && !("version" in map) && map.mappings === "";
998
- 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);
999
1002
  // remember where the code is stored on disk so that repeat fetches and the
1000
1003
  // `fetchWarmModules` snapshot can point at it in this session already, not
1001
1004
  // only after the cache is read back in the next one
@@ -1031,7 +1034,7 @@ class ModuleTransformService {
1031
1034
  if ("code" in result) trace.setAttribute("vitest.fetched_module.code_length", result.code.length);
1032
1035
  }
1033
1036
  async getCachePath(environment, moduleGraphModule) {
1034
- if (!this.fsCacheEnabled) return null;
1037
+ if (!this.fsCacheEnabled || this.fsCache.getCacheRoot(this.config) == null) return null;
1035
1038
  const moduleId = moduleGraphModule.id;
1036
1039
  const memoryCacheKey = this.fsCache.getMemoryCachePath(environment, moduleId);
1037
1040
  // undefined means there is no key in memory
@@ -1071,6 +1074,8 @@ class ModuleTransformService {
1071
1074
  if (!cachedModule) return;
1072
1075
  const importedModules = await this.resolveCachedImports(environment, cachedModule);
1073
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);
1074
1079
  // keep the module graph in sync
1075
1080
  let map = extractSourceMap(cachedModule.code);
1076
1081
  if (map && cachedModule.file) map.file = cachedModule.file;
@@ -1101,7 +1106,7 @@ class ModuleTransformService {
1101
1106
  file: cachedModule.file,
1102
1107
  id: cachedModule.id,
1103
1108
  tmp: cachePath,
1104
- url: cachedModule.url,
1109
+ url: moduleGraphModule.url,
1105
1110
  invalidate: false,
1106
1111
  moduleType
1107
1112
  };
@@ -1151,10 +1156,10 @@ class ModuleTransformService {
1151
1156
  if (transformResult) transformResult.__vitestModuleType = moduleType;
1152
1157
  return moduleType;
1153
1158
  }
1154
- async cacheResult(result, cachePath, transformResult, imports, mappings = false) {
1159
+ async cacheResult(result, cachePath, transformResult, imports, mappings = false, coverageData) {
1155
1160
  const returnResult = "code" in result ? getCachedResult(result, cachePath) : result;
1156
1161
  if (saveCachePromises.has(cachePath)) return saveCachePromises.get(cachePath);
1157
- 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) => {
1158
1163
  debugFs?.(`failed to cache ${cachePath}, serving it inline: ${error}`);
1159
1164
  return result;
1160
1165
  }).finally(() => {
@@ -1422,6 +1427,7 @@ function createFailedFileTask(project, filepath, error, options) {
1422
1427
  return file;
1423
1428
  }
1424
1429
  function serializeError(error) {
1430
+ if (error?.__vitest_rollup_error__) return [error];
1425
1431
  return [toRollupError(error) ?? {
1426
1432
  name: error.name,
1427
1433
  stack: error.stack,
@@ -1574,7 +1580,8 @@ async function transformSSR(project, filepath) {
1574
1580
  const { env: pragmaEnv, tags: fileTags } = detectCodeBlock(originalCode);
1575
1581
  // Use environment from pragma if defined, otherwise fall back to config
1576
1582
  const environment = pragmaEnv || project.config.environment;
1577
- const transformResult = await (environment === "jsdom" || environment === "happy-dom" ? project.vite.environments.client : project.vite.environments.ssr).transformRequest(filepath);
1583
+ const env = environment === "jsdom" || environment === "happy-dom" ? project.vite.environments.client : project.vite.environments.ssr;
1584
+ const transformResult = await project._transformService.transform(filepath, env);
1578
1585
  return transformResult ? {
1579
1586
  ...transformResult,
1580
1587
  fileTags
@@ -1834,7 +1841,7 @@ async function createClusterServer(vitest, viteConfig, config, children) {
1834
1841
  const contribution = config._browserContribution;
1835
1842
  if (!contribution) {
1836
1843
  const server = await createViteServer(viteConfig);
1837
- if (config.api.port) await server.listen(config.api.port);
1844
+ if (config.api.port != null) await server.listen(config.api.port);
1838
1845
  return { server };
1839
1846
  }
1840
1847
  const parent = contribution.createParent({
@@ -3579,7 +3586,7 @@ class ServerModuleRunner extends ModuleRunner {
3579
3586
  try {
3580
3587
  const result = await transformService.fetch(data[0], data[1], environment, false, data[2]);
3581
3588
  if ("tmp" in result) {
3582
- const code = await readFile(result.tmp);
3589
+ const code = await readFile(result.tmp, "utf-8");
3583
3590
  return { result: {
3584
3591
  ...result,
3585
3592
  code
@@ -4121,6 +4128,7 @@ function serializeConfig(project) {
4121
4128
  },
4122
4129
  providerOptions: provider?.name === "playwright" ? { actionTimeout: provider?.options?.actionTimeout } : {},
4123
4130
  trackUnhandledErrors: browser.trackUnhandledErrors ?? true,
4131
+ importMapMocks: browser.importMapMocks,
4124
4132
  trace: browser.trace.mode,
4125
4133
  traceView: browser.traceView
4126
4134
  };
@@ -4142,6 +4150,8 @@ function serializeConfig(project) {
4142
4150
  viteModuleRunner: config.experimental.viteModuleRunner ?? true,
4143
4151
  nodeLoader: config.experimental.nodeLoader ?? true,
4144
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,
4145
4155
  openTelemetry: config.experimental.openTelemetry
4146
4156
  },
4147
4157
  tags: config.tags || [],
@@ -4413,7 +4423,7 @@ function createBrowserPool(vitest) {
4413
4423
  project,
4414
4424
  files,
4415
4425
  method,
4416
- exclusive: !provider.mocker || !provider.supportsParallelism,
4426
+ exclusive: !provider.supportsParallelism || !provider.mocker && project.config.browser.importMapMocks !== true,
4417
4427
  result: createDefer()
4418
4428
  };
4419
4429
  }));
@@ -4462,12 +4472,13 @@ async function groupSpecifications(specs) {
4462
4472
  const code = /* @__PURE__ */ new Map();
4463
4473
  const docblocks = await Promise.all(specs.map((spec) => getSpecificationDocblock(spec, code)));
4464
4474
  specs.forEach((spec, index) => {
4465
- const { project, moduleId, testLines, testIds, testNamePattern, testTagsFilter } = spec;
4475
+ const { project, moduleId, testLines, testIds, testNames, testNamePattern, testTagsFilter } = spec;
4466
4476
  const files = groupedFiles.get(project) || [];
4467
4477
  files.push({
4468
4478
  filepath: moduleId,
4469
4479
  testLocations: testLines,
4470
4480
  testIds,
4481
+ testNames,
4471
4482
  testNamePattern,
4472
4483
  testTagsFilter,
4473
4484
  fileTags: docblocks[index].tags
@@ -6142,8 +6153,10 @@ function createPool(ctx) {
6142
6153
  testLocations: spec.testLines,
6143
6154
  testNamePattern: spec.testNamePattern,
6144
6155
  testIds: spec.testIds,
6156
+ testNames: spec.testNames,
6145
6157
  testTagsFilter: spec.testTagsFilter
6146
6158
  })),
6159
+ // Vitest's own pools don't read it, but a custom pool whose worker outlives a run can use it
6147
6160
  invalidates,
6148
6161
  providedContext: project.getProvidedContext(),
6149
6162
  workerId: workerId++,
@@ -6347,6 +6360,22 @@ async function globProjectTestFiles(include, exclude, includeSource, cwd) {
6347
6360
  }
6348
6361
  return testFiles;
6349
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
+ }
6350
6379
 
6351
6380
  class TestSpecification {
6352
6381
  /**
@@ -6378,6 +6407,10 @@ class TestSpecification {
6378
6407
  */
6379
6408
  testIds;
6380
6409
  /**
6410
+ * The full names of the tests inside of this specification to run, including the parent suites separated with `>`.
6411
+ */
6412
+ testNames;
6413
+ /**
6381
6414
  * The tags of tests to run.
6382
6415
  */
6383
6416
  testTagsFilter;
@@ -6401,6 +6434,7 @@ class TestSpecification {
6401
6434
  this.testLines = testLinesOrOptions.testLines;
6402
6435
  this.testNamePattern = testLinesOrOptions.testNamePattern;
6403
6436
  this.testIds = testLinesOrOptions.testIds;
6437
+ this.testNames = testLinesOrOptions.testNames;
6404
6438
  this.testTagsFilter = testLinesOrOptions.testTagsFilter;
6405
6439
  }
6406
6440
  }
@@ -6423,6 +6457,7 @@ class TestSpecification {
6423
6457
  pool: this.pool,
6424
6458
  testLines: this.testLines,
6425
6459
  testIds: this.testIds,
6460
+ testNames: this.testNames,
6426
6461
  testNamePattern: this.testNamePattern,
6427
6462
  testTagsFilter: this.testTagsFilter
6428
6463
  }
@@ -6597,8 +6632,8 @@ class TestProject {
6597
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) : []]);
6598
6633
  this.typecheckFilesList = typecheckTestFiles;
6599
6634
  return {
6600
- testFiles: this.filterFiles(testFiles, filters, dir),
6601
- typecheckTestFiles: this.filterFiles(typecheckTestFiles, filters, dir)
6635
+ testFiles: filterTestFiles(testFiles, filters, dir),
6636
+ typecheckTestFiles: filterTestFiles(typecheckTestFiles, filters, dir)
6602
6637
  };
6603
6638
  });
6604
6639
  }
@@ -6656,19 +6691,6 @@ class TestProject {
6656
6691
  }
6657
6692
  return false;
6658
6693
  }
6659
- filterFiles(testFiles, filters, dir) {
6660
- if (filters.length && process.platform === "win32") filters = filters.map((f) => slash(f));
6661
- if (filters.length) return testFiles.filter((t) => {
6662
- const testFile = relative(dir, t).toLocaleLowerCase();
6663
- return filters.some((f) => {
6664
- // if filter is a full file path, we should include it if it's in the same folder
6665
- if (isAbsolute(f) && t.startsWith(f)) return true;
6666
- const relativePath = f.endsWith("/") ? join(relative(dir, f), "/") : relative(dir, f);
6667
- return testFile.includes(f.toLocaleLowerCase()) || testFile.includes(relativePath.toLocaleLowerCase());
6668
- });
6669
- });
6670
- return testFiles;
6671
- }
6672
6694
  /**
6673
6695
  * The parent browser project that owns this cluster's single Vite server.
6674
6696
  * Set on the primary (the hidden parent of a browser cluster) at server
@@ -6949,10 +6971,10 @@ async function resolveProjectEntries(harness, globalViteConfig, globalConfig, de
6949
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)}.`
6950
6972
  ].join(""));
6951
6973
  debug?.(`resolved projects: ${filtered.filter((e) => !e.hidden).map((e) => projectLabel(e.projectConfig.name)).join(", ")}`);
6952
- await applyBrowserOptimizeDeps(harness, filtered);
6974
+ await applyBrowserOptimizeDeps(harness, filtered, globalConfig._cliFilters ?? []);
6953
6975
  return filtered;
6954
6976
  }
6955
- async function applyBrowserOptimizeDeps(harness, entries) {
6977
+ async function applyBrowserOptimizeDeps(harness, entries, cliFilters) {
6956
6978
  const groups = /* @__PURE__ */ new Map();
6957
6979
  for (const entry of entries) {
6958
6980
  const { viteConfig } = entry;
@@ -6988,7 +7010,8 @@ async function applyBrowserOptimizeDeps(harness, entries) {
6988
7010
  if (!contribution) return;
6989
7011
  const fileLists = await Promise.all(projectConfigs.map(globTestFiles));
6990
7012
  projectEntries.forEach((entry, index) => {
6991
- entry.hasTestFiles = fileLists[index].length > 0;
7013
+ const config = projectConfigs[index];
7014
+ entry.hasTestFiles = filterTestFiles(fileLists[index], cliFilters, config.dir || config.root).length > 0;
6992
7015
  });
6993
7016
  const testFiles = [...new Set(fileLists.flat())];
6994
7017
  debug?.(`aggregating browser optimizeDeps from ${testFiles.length} test files of ${projectEntries.map((e) => projectLabel(e.projectConfig.name)).join(", ")}`);
@@ -7575,7 +7598,7 @@ async function resolveTestProjectConfigs(parentViteConfig, parentConfig, project
7575
7598
  // directories that don't have a config file inside, but should be treated as projects
7576
7599
  const nonConfigProjectDirectories = [];
7577
7600
  for (const definition of projectsDefinition) if (typeof definition === "string") {
7578
- const stringOption = definition.replace("<rootDir>", parentConfig.root);
7601
+ const stringOption = definition.replace("<rootDir>", () => parentConfig.root);
7579
7602
  // if the string doesn't contain a glob, we can resolve it directly
7580
7603
  // ['./vitest.config.js']
7581
7604
  if (!isDynamicPattern(stringOption)) {
@@ -8493,12 +8516,14 @@ class Logger {
8493
8516
  const config = this.ctx.config;
8494
8517
  // test files were found, but none of them depend on the changed files
8495
8518
  const noAffectedTests = !!this.ctx._sourceFilterResult?.total;
8496
- const message = !noAffectedTests ? "No test files found" : config.related?.length ? "No affected test files found" : "No changed files found";
8497
- if (config.watch && noAffectedTests) this.log(`${message}\n`);
8519
+ // test files were found, but none of them failed in the last run
8520
+ const noFailedTests = !!this.ctx._failedFilterResult?.total;
8521
+ const message = noFailedTests ? "No failed tests found" : !noAffectedTests ? "No test files found" : config.related?.length ? "No affected test files found" : "No changed files found";
8522
+ if (config.watch && (noAffectedTests || noFailedTests)) this.log(`${message}\n`);
8498
8523
  else if (config.watch) this.log($.red(`${message}. You can change the file name pattern by pressing "p"\n`));
8499
8524
  else if (config.passWithNoTests) this.log(`${message}, exiting with code 0\n`);
8500
8525
  else this.error($.red(`${message}, exiting with code 1\n`));
8501
- if (noAffectedTests) return;
8526
+ if (noAffectedTests || noFailedTests) return;
8502
8527
  const comma = $.dim(", ");
8503
8528
  if (filters?.length) this.console.error($.dim("filter: ") + $.yellow(filters.join(comma)));
8504
8529
  const projectsFilter = toArray(config.project);
@@ -8522,18 +8547,14 @@ class Logger {
8522
8547
  this.log(withLabel(color, mode, `v${this.ctx.version} `) + $.gray(this.ctx.config.root));
8523
8548
  const seed = this.ctx.getSeed();
8524
8549
  if (seed != null) this.log(PAD + $.gray(`Running tests with seed "${seed}"`));
8525
- if (this.ctx.config.ui) {
8526
- const host = this.ctx.config.api?.host || "localhost";
8527
- const port = this.ctx.vite.config.server.port;
8528
- const url = new URL(this.ctx.config.uiBase, `http://${host}:${port}`);
8529
- url.searchParams.set("token", this.ctx.config.api.token);
8530
- this.log(PAD + $.dim($.green(`UI started at ${url}`)));
8531
- } else if (this.ctx.config.api?.port && this.ctx.config._apiRequested) {
8532
- const resolvedUrls = this.ctx.vite.resolvedUrls;
8533
- // workaround for https://github.com/vitejs/vite/issues/15438, it was fixed in vite 5.1
8534
- const fallbackUrl = `http://${this.ctx.config.api.host || "localhost"}:${this.ctx.config.api.port}`;
8535
- const origin = resolvedUrls?.local[0] ?? resolvedUrls?.network[0] ?? fallbackUrl;
8536
- 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)}`)));
8537
8558
  }
8538
8559
  if (this.ctx.coverageProvider) this.log(PAD + $.dim("Coverage enabled with ") + $.yellow(this.ctx.coverageProvider.name));
8539
8560
  if (this.ctx.config.standalone) this.log($.yellow(`\nVitest is running in standalone mode. Edit a test file to rerun tests.\n`));
@@ -8668,6 +8689,7 @@ class PluginHarness {
8668
8689
  }
8669
8690
  }
8670
8691
 
8692
+ const builtinVCSProviders = /* @__PURE__ */ new Set(["git", "mtime"]);
8671
8693
  function resolvePath(path, root) {
8672
8694
  // local-pkg (mlly)'s resolveModule("./file", { paths: ["/some/root"] }) tries
8673
8695
  // /some/file
@@ -8714,14 +8736,14 @@ function resolveApiServerConfig(config, defaultPort, logger) {
8714
8736
  } else api = { ...config.api };
8715
8737
  }
8716
8738
  if (api) {
8717
- if (!api.port && !api.middlewareMode) api.port = defaultPort;
8739
+ if (api.port == null && !api.middlewareMode) api.port = defaultPort;
8718
8740
  } else api = { middlewareMode: true };
8719
8741
  if (api && isBrowserEnabled) {
8720
8742
  // Always force middlewareMode to false in browser mode
8721
8743
  api.middlewareMode = false;
8722
8744
  // The browser server is standalone, so it always needs a port even when the
8723
8745
  // user didn't configure `api`/`ui` (in which case `api` defaulted above)
8724
- if (!api.port) api.port = defaultPort;
8746
+ if (api.port == null) api.port = defaultPort;
8725
8747
  }
8726
8748
  // if the API server is exposed to network, disable write operations by default
8727
8749
  if (!api.middlewareMode && api.host && api.host !== "localhost" && api.host !== "127.0.0.1") {
@@ -8783,6 +8805,7 @@ function resolveTestConfig(logger, options, viteConfig, globalConfig) {
8783
8805
  resolved.coverage = globalConfig.coverage;
8784
8806
  resolved.attachmentsDir = globalConfig.attachmentsDir;
8785
8807
  resolved.mergeReportsLabel = globalConfig.mergeReportsLabel;
8808
+ resolved.watch = globalConfig.watch;
8786
8809
  }
8787
8810
  if (!statSync(resolved.root, { throwIfNoEntry: false })?.isDirectory()) throw new Error(`Root path does not exist or is not a directory: ${resolved.root}`);
8788
8811
  resolved.mode ??= viteConfig.mode ?? "test";
@@ -8919,6 +8942,14 @@ function resolveTestConfig(logger, options, viteConfig, globalConfig) {
8919
8942
  if (!textSummary) resolved.coverage.reporter.push(["text-summary", {}]);
8920
8943
  }
8921
8944
  }
8945
+ // CLI options are merged into the test config
8946
+ if (options.sinceLastRun) {
8947
+ if (resolved.cache === false) throw new Error("The \"--since-last-run\" flag requires the \"cache\" option to store the dependencies of the test files.");
8948
+ resolved.changed ||= true;
8949
+ resolved.experimental ??= {};
8950
+ resolved.experimental.recordDependencies = true;
8951
+ resolved.experimental.vcsProvider = "mtime";
8952
+ }
8922
8953
  if (resolved.coverage.changed === void 0 && resolved.changed !== void 0) resolved.coverage.changed = resolved.changed;
8923
8954
  if (resolved.coverage.enabled && resolved.coverage.reportsDirectory) {
8924
8955
  const reportsDirectory = resolve(resolved.root, resolved.coverage.reportsDirectory);
@@ -9137,22 +9168,22 @@ function resolveTestConfig(logger, options, viteConfig, globalConfig) {
9137
9168
  } else if (resolved.ui) resolved.includeTaskLocation ??= true;
9138
9169
  if (typeof resolved.browser.trace === "string" || !resolved.browser.trace) resolved.browser.trace = { mode: resolved.browser.trace || "off" };
9139
9170
  const traceView = resolved.browser.traceView;
9140
- resolved.browser.traceView = typeof traceView === "object" ? {
9141
- enabled: traceView.enabled ?? false,
9142
- recordCanvas: traceView.recordCanvas ?? false,
9143
- inlineImages: traceView.inlineImages ?? false
9144
- } : {
9145
- enabled: traceView ?? false,
9146
- recordCanvas: false,
9147
- inlineImages: false
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
9148
9180
  };
9149
- 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";
9150
9182
  if (resolved.browser.trace.tracesDir != null) resolved.browser.trace.tracesDir = resolvePath(resolved.browser.trace.tracesDir, resolved.root);
9151
9183
  if (toArray(resolved.reporters).some((reporter) => {
9152
9184
  if (Array.isArray(reporter)) return reporter[0] === "html";
9153
9185
  return false;
9154
9186
  })) resolved.includeTaskLocation ??= true;
9155
- 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.")));
9156
9187
  resolved.server ??= {};
9157
9188
  resolved.server.deps ??= {};
9158
9189
  if (resolved.server.debug?.dump || process.env.VITEST_DEBUG_DUMP) {
@@ -9193,7 +9224,7 @@ function resolveTestConfig(logger, options, viteConfig, globalConfig) {
9193
9224
  import: diagnostics.import ?? true,
9194
9225
  transform: diagnostics.transform ?? true
9195
9226
  };
9196
- if (typeof resolved.experimental.vcsProvider === "string" && resolved.experimental.vcsProvider !== "git") resolved.experimental.vcsProvider = resolvePath(resolved.experimental.vcsProvider, resolved.root);
9227
+ if (typeof resolved.experimental.vcsProvider === "string" && !builtinVCSProviders.has(resolved.experimental.vcsProvider)) resolved.experimental.vcsProvider = resolvePath(resolved.experimental.vcsProvider, resolved.root);
9197
9228
  // `experimental.fsModuleCache` / `experimental.fsModuleCachePath` were promoted to
9198
9229
  // the top-level `fsModuleCache` / `fsModuleCachePath` options.
9199
9230
  const legacyExperimental = options.experimental;
@@ -9243,7 +9274,7 @@ function resolveConfigPath(root, options) {
9243
9274
  if (options.config) return resolveModule(options.config, { paths: [root] }) ?? resolve(root, options.config);
9244
9275
  return findConfigFile(root);
9245
9276
  }
9246
- async function resolveConfig(options = {}, viteOverrides = {}, pluginsHarness = new PluginHarness()) {
9277
+ async function resolveConfig(options = {}, viteOverrides = {}, pluginsHarness = new PluginHarness(), cliFilters = []) {
9247
9278
  // We clone CLI Options and Vite overrides to reuse when a watch mode is triggered.
9248
9279
  const cliOptionsCopy = deepMerge({}, options);
9249
9280
  const viteOverridesCopy = deepMerge({}, viteOverrides);
@@ -9300,6 +9331,7 @@ async function resolveConfig(options = {}, viteOverrides = {}, pluginsHarness =
9300
9331
  rootConfig.cliOptions = cliOptionsCopy;
9301
9332
  rootConfig.viteOverrides = viteOverridesCopy;
9302
9333
  rootConfig._browserContribution = captures.browserContribution;
9334
+ rootConfig._cliFilters = cliFilters;
9303
9335
  // projects never inherit `tagsFilter` and `browser` from the programmatic
9304
9336
  // config (see `inheritRootViteOverrides`), so remove them from the base too
9305
9337
  if (captures.rawTestConfig) {
@@ -15630,4 +15662,4 @@ var index = /*#__PURE__*/_mergeNamespaces({
15630
15662
  default: prompt
15631
15663
  }, [promptsExports]);
15632
15664
 
15633
- export { resolveStaticMocks as A, BaseSequencer as B, getStaticMocks as C, LocationFilterFileNotFoundError as D, GitCommandError as E, ForksPoolWorker as F, GitNotFoundError as G, VitestResolver as H, IncludeTaskLocationDisabledError as I, createClusterServer as J, attachProjectsFromEntries as K, Logger as L, ModuleTransformService as M, TestProject as N, resolveAndAttachProjects as O, PluginHarness as P, RandomSequencer as Q, RangeLocationFilterProvidedError as R, ServerModuleRunner as S, ThreadsPoolWorker as T, createPool as U, VitestPackageInstaller as V, astCollectTests as W, createFailedFileTask as X, matchesProjectFilter as Y, nanoid as Z, stdout as _, BrowserConnectionError as a, FilesNotFoundError as b, TypecheckPoolWorker as c, VmForksPoolWorker as d, VmThreadsPoolWorker as e, createDebugger as f, createMethodsRPC as g, createViteLogger as h, escapeTestName as i, getFilePoolName as j, isFileServingAllowed as k, resolveConfig as l, resolveFsAllow as m, findConfigFile as n, parse as o, prompt as p, hash as q, resolveApiServerConfig as r, stringify as s, resolveCoverageReporters as t, createIndexLocationsMap as u, getOutputFile as v, groupBy as w, generateCodeFrame as x, printStack as y, getSpecificationDocblock as z };
15665
+ export { generateCodeFrame as A, BaseSequencer as B, printStack as C, LocationFilterFileNotFoundError as D, GitCommandError as E, ForksPoolWorker as F, GitNotFoundError as G, VitestResolver as H, IncludeTaskLocationDisabledError as I, createClusterServer as J, attachProjectsFromEntries as K, Logger as L, ModuleTransformService as M, TestProject as N, resolveAndAttachProjects as O, PluginHarness as P, RandomSequencer as Q, RangeLocationFilterProvidedError as R, ServerModuleRunner as S, ThreadsPoolWorker as T, createPool as U, VitestPackageInstaller as V, astCollectTests as W, createFailedFileTask as X, matchesProjectFilter as Y, nanoid as Z, stdout as _, BrowserConnectionError as a, FilesNotFoundError as b, TypecheckPoolWorker as c, VmForksPoolWorker as d, VmThreadsPoolWorker as e, createDebugger as f, createMethodsRPC as g, createViteLogger as h, escapeTestName as i, getFilePoolName as j, isFileServingAllowed as k, resolveConfig as l, resolveFsAllow as m, findConfigFile as n, parse as o, prompt as p, getSpecificationDocblock as q, resolveApiServerConfig as r, stringify as s, resolveStaticMocks as t, getStaticMocks as u, hash as v, resolveCoverageReporters as w, createIndexLocationsMap as x, getOutputFile as y, groupBy as z };
@@ -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.DpkUyY1N.js';
5
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.HGAqWOnX.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.aTZaPVhf.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.PvxYpuCm.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.PvxYpuCm.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.CK-t0WMg.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.DdKI5IHB.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.DpkUyY1N.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.CK-t0WMg.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';
@@ -13,6 +13,7 @@ import '../module-evaluator.js';
13
13
  import 'node:vm';
14
14
  import 'vite/module-runner';
15
15
  import '../traces.js';
16
+ import 'node:async_hooks';
16
17
  import '@vitest/mocker';
17
18
  import '@vitest/mocker/redirect';
18
19
  import 'node:console';
@@ -184,7 +185,7 @@ export { __${index} as "${key}" }
184
185
  const filename = fileURLToPath(resolvedId);
185
186
  const external = !isAbsolute(filename) || this.isModuleDirectory(resolvedId) ? normalizeModuleId(rawId) : null;
186
187
  // file is not mocked, automock or redirect it
187
- const redirect = this.findMockRedirect(filename, external);
188
+ const redirect = this.findMockRedirect(filename, external, rawId);
188
189
  if (redirect) return import(pathToFileURL(redirect).toString());
189
190
  const url = new URL(resolvedId);
190
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 };