vitest 4.0.12 → 4.0.14

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 (42) hide show
  1. package/dist/browser.d.ts +7 -10
  2. package/dist/chunks/{base.CDEiaaLz.js → base.BEv8sRbK.js} +2 -2
  3. package/dist/chunks/{browser.d.Bq3zc1l_.d.ts → browser.d.F6jMf15V.d.ts} +1 -1
  4. package/dist/chunks/{cac.D9QaLeSz.js → cac.DnEx6DOX.js} +6 -6
  5. package/dist/chunks/{cli-api.BJh-POxZ.js → cli-api.CbjxIXjQ.js} +80 -71
  6. package/dist/chunks/{traces.d.Brik_NWu.d.ts → config.d.g6OOauRt.d.ts} +1 -18
  7. package/dist/chunks/{global.d.Dheepru6.d.ts → global.d.B15mdLcR.d.ts} +1 -1
  8. package/dist/chunks/{index.CMvpbrsJ.js → index.B88tjlE5.js} +1 -1
  9. package/dist/chunks/{index.QWbK7rHY.js → index.BspFP3mn.js} +12 -7
  10. package/dist/chunks/{index.DWDW6mLz.js → index.D6PC4Dpu.js} +9 -4
  11. package/dist/chunks/{init-forks.FphdQhPI.js → init-forks.DmvIFK4U.js} +1 -1
  12. package/dist/chunks/{init-threads.BfqfWDNi.js → init-threads.De6b3S3g.js} +1 -1
  13. package/dist/chunks/{init.D-GGeAxo.js → init.a5SCIJ0x.js} +4 -4
  14. package/dist/chunks/{plugin.d.DGpEw-QV.d.ts → plugin.d.B6hlg3fN.d.ts} +1 -1
  15. package/dist/chunks/{reporters.d.C2PtoEFY.d.ts → reporters.d.DeFcIuza.d.ts} +7 -5
  16. package/dist/chunks/rpc.d.RH3apGEf.d.ts +64 -0
  17. package/dist/chunks/{startModuleRunner.BEYtrq5Y.js → startModuleRunner.W28wBIgJ.js} +3 -0
  18. package/dist/chunks/traces.d.402V_yFI.d.ts +18 -0
  19. package/dist/chunks/{vm.tWlKAMXr.js → vm.BbVD4fJ5.js} +2 -2
  20. package/dist/chunks/{worker.d.Dxl5oW0C.d.ts → worker.d.DhEa3KzY.d.ts} +5 -63
  21. package/dist/cli.js +2 -2
  22. package/dist/config.d.ts +10 -8
  23. package/dist/coverage.d.ts +8 -6
  24. package/dist/environments.js +1 -1
  25. package/dist/index.d.ts +16 -9
  26. package/dist/module-evaluator.d.ts +117 -12
  27. package/dist/module-evaluator.js +4 -1
  28. package/dist/module-runner.js +1 -1
  29. package/dist/node.d.ts +11 -9
  30. package/dist/node.js +6 -6
  31. package/dist/reporters.d.ts +10 -8
  32. package/dist/reporters.js +2 -2
  33. package/dist/runners.d.ts +2 -1
  34. package/dist/worker.d.ts +6 -4
  35. package/dist/worker.js +4 -4
  36. package/dist/workers/forks.js +5 -5
  37. package/dist/workers/threads.js +5 -5
  38. package/dist/workers/vmForks.js +5 -5
  39. package/dist/workers/vmThreads.js +5 -5
  40. package/package.json +13 -18
  41. package/dist/chunks/mocker.d.BE_2ls6u.d.ts +0 -17
  42. package/dist/chunks/moduleRunner.d.RBEiFdiW.d.ts +0 -204
package/dist/browser.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/traces.d.Brik_NWu.js';
1
+ import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/config.d.g6OOauRt.js';
2
2
  import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.BZtK59WP.js';
3
3
  import { SerializedDiffOptions } from '@vitest/utils/diff';
4
- import { V as VitestModuleRunner } from './chunks/moduleRunner.d.RBEiFdiW.js';
5
4
  export { collectTests, startTests } from '@vitest/runner';
6
5
  import * as _vitest_spy from '@vitest/spy';
7
6
  export { _vitest_spy as SpyModule };
@@ -13,12 +12,6 @@ export { DecodedMap, getOriginalPosition } from '@vitest/utils/source-map';
13
12
  export { getSafeTimers, setSafeTimers } from '@vitest/utils/timers';
14
13
  import '@vitest/pretty-format';
15
14
  import '@vitest/snapshot';
16
- import 'node:vm';
17
- import 'vite/module-runner';
18
- import './chunks/worker.d.Dxl5oW0C.js';
19
- import './chunks/environment.d.CrsxCzP1.js';
20
- import '@vitest/mocker';
21
- import './chunks/mocker.d.BE_2ls6u.js';
22
15
 
23
16
  declare function startCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader, runtimeOptions: {
24
17
  isolate: boolean;
@@ -28,9 +21,13 @@ declare function stopCoverageInsideWorker(options: SerializedCoverageConfig | un
28
21
  isolate: boolean;
29
22
  }): Promise<unknown>;
30
23
 
24
+ interface PublicModuleRunner {
25
+ import: (id: string) => Promise<any>;
26
+ }
27
+
31
28
  declare function setupCommonEnv(config: SerializedConfig): Promise<void>;
32
- declare function loadDiffConfig(config: SerializedConfig, moduleRunner: VitestModuleRunner): Promise<SerializedDiffOptions | undefined>;
33
- declare function loadSnapshotSerializers(config: SerializedConfig, moduleRunner: VitestModuleRunner): Promise<void>;
29
+ declare function loadDiffConfig(config: SerializedConfig, moduleRunner: PublicModuleRunner): Promise<SerializedDiffOptions | undefined>;
30
+ declare function loadSnapshotSerializers(config: SerializedConfig, moduleRunner: PublicModuleRunner): Promise<void>;
34
31
 
35
32
  interface FsOptions {
36
33
  encoding?: BufferEncoding;
@@ -1,9 +1,9 @@
1
1
  import { runInThisContext } from 'node:vm';
2
2
  import * as spyModule from '@vitest/spy';
3
3
  import { r as resolveTestRunner, a as resolveSnapshotEnvironment, s as setupChaiConfig } from './index.CQwQ_SLL.js';
4
- import { l as loadEnvironment } from './init.D-GGeAxo.js';
4
+ import { l as loadEnvironment } from './init.a5SCIJ0x.js';
5
5
  import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
6
- import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startModuleRunner.BEYtrq5Y.js';
6
+ import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startModuleRunner.W28wBIgJ.js';
7
7
  import { performance as performance$1 } from 'node:perf_hooks';
8
8
  import { startTests, collectTests } from '@vitest/runner';
9
9
  import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.DGHc_BUK.js';
@@ -1,5 +1,5 @@
1
1
  import { FileSpecification } from '@vitest/runner';
2
- import { T as TestExecutionMethod } from './worker.d.Dxl5oW0C.js';
2
+ import { T as TestExecutionMethod } from './worker.d.DhEa3KzY.js';
3
3
 
4
4
  type SerializedTestSpecification = [project: {
5
5
  name: string | undefined;
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
3
3
  import { normalize } from 'pathe';
4
4
  import c from 'tinyrainbow';
5
5
  import { a as defaultPort, d as defaultBrowserPort } from './constants.D_Q9UYh-.js';
6
- import { R as ReportersMap } from './index.DWDW6mLz.js';
6
+ import { R as ReportersMap } from './index.D6PC4Dpu.js';
7
7
 
8
8
  function toArr(any) {
9
9
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -619,7 +619,7 @@ class CAC extends EventEmitter {
619
619
 
620
620
  const cac = (name = "") => new CAC(name);
621
621
 
622
- var version = "4.0.12";
622
+ var version = "4.0.14";
623
623
 
624
624
  const apiConfig = (port) => ({
625
625
  port: {
@@ -1371,11 +1371,11 @@ function normalizeCliOptions(cliFilters, argv) {
1371
1371
  }
1372
1372
  async function start(mode, cliFilters, options) {
1373
1373
  try {
1374
- const { startVitest } = await import('./cli-api.BJh-POxZ.js').then(function (n) { return n.p; });
1374
+ const { startVitest } = await import('./cli-api.CbjxIXjQ.js').then(function (n) { return n.p; });
1375
1375
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1376
1376
  if (!ctx.shouldKeepServer()) await ctx.exit();
1377
1377
  } catch (e) {
1378
- const { errorBanner } = await import('./index.DWDW6mLz.js').then(function (n) { return n.u; });
1378
+ const { errorBanner } = await import('./index.D6PC4Dpu.js').then(function (n) { return n.u; });
1379
1379
  console.error(`\n${errorBanner("Startup Error")}`);
1380
1380
  console.error(e);
1381
1381
  console.error("\n\n");
@@ -1393,7 +1393,7 @@ async function init(project) {
1393
1393
  }
1394
1394
  async function collect(mode, cliFilters, options) {
1395
1395
  try {
1396
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BJh-POxZ.js').then(function (n) { return n.p; });
1396
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.CbjxIXjQ.js').then(function (n) { return n.p; });
1397
1397
  const ctx = await prepareVitest(mode, {
1398
1398
  ...normalizeCliOptions(cliFilters, options),
1399
1399
  watch: false,
@@ -1412,7 +1412,7 @@ async function collect(mode, cliFilters, options) {
1412
1412
  } else outputFileList(await ctx.getRelevantTestSpecifications(cliFilters.map(normalize)), options);
1413
1413
  await ctx.close();
1414
1414
  } catch (e) {
1415
- const { errorBanner } = await import('./index.DWDW6mLz.js').then(function (n) { return n.u; });
1415
+ const { errorBanner } = await import('./index.D6PC4Dpu.js').then(function (n) { return n.u; });
1416
1416
  console.error(`\n${errorBanner("Collect Error")}`);
1417
1417
  console.error(e);
1418
1418
  console.error("\n\n");
@@ -10,12 +10,12 @@ import { parseAst, searchForWorkspaceRoot, fetchModule, version, mergeConfig, cr
10
10
  import { A as API_PATH, c as configFiles, d as defaultBrowserPort, a as defaultPort } from './constants.D_Q9UYh-.js';
11
11
  import * as nodeos from 'node:os';
12
12
  import nodeos__default, { tmpdir } from 'node:os';
13
- import { generateHash as generateHash$1, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, hasFailed, generateFileHash, limitConcurrency, createFileTask as createFileTask$1, getTasks, isTestCase } from '@vitest/runner/utils';
13
+ import { generateHash as generateHash$1, createTaskName, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, hasFailed, generateFileHash, limitConcurrency, createFileTask as createFileTask$1, getTasks, isTestCase } from '@vitest/runner/utils';
14
14
  import { SnapshotManager } from '@vitest/snapshot/manager';
15
- import { v as version$1 } from './cac.D9QaLeSz.js';
15
+ import { v as version$1 } from './cac.DnEx6DOX.js';
16
16
  import { performance as performance$1 } from 'node:perf_hooks';
17
17
  import { c as createBirpc } from './index.0kCJoeWi.js';
18
- import { p as parse, d as stringify, e as TraceMap, o as originalPositionFor, h as ancestor, i as printError, f as formatProjectName, w as withLabel, j as errorBanner, k as divider, l as Typechecker, m as generateCodeFrame, n as createDefinesScript, R as ReportersMap, B as BlobReporter, r as readBlobs, q as convertTasksToEvents, H as HangingProcessReporter } from './index.DWDW6mLz.js';
18
+ import { p as parse, d as stringify, e as TraceMap, o as originalPositionFor, h as ancestor, i as printError, f as formatProjectName, w as withLabel, j as errorBanner, k as divider, l as Typechecker, m as generateCodeFrame, n as createDefinesScript, R as ReportersMap, B as BlobReporter, r as readBlobs, q as convertTasksToEvents, H as HangingProcessReporter } from './index.D6PC4Dpu.js';
19
19
  import require$$0$3 from 'events';
20
20
  import require$$1$1 from 'https';
21
21
  import require$$2 from 'http';
@@ -30,7 +30,7 @@ import { g as getDefaultExportFromCjs } from './_commonjsHelpers.D26ty3Ew.js';
30
30
  import crypto, { createHash } from 'node:crypto';
31
31
  import { rootDir, distDir } from '../path.js';
32
32
  import { T as Traces } from './traces.U4xDYhzZ.js';
33
- import createDebug from 'debug';
33
+ import { createDebug } from 'obug';
34
34
  import { rm, readFile, writeFile, rename, stat, unlink, mkdir, copyFile } from 'node:fs/promises';
35
35
  import c from 'tinyrainbow';
36
36
  import { VitestModuleEvaluator } from '#module-evaluator';
@@ -52,7 +52,7 @@ import { c as configDefaults } from './defaults.BOqNVLsY.js';
52
52
  import { KNOWN_ASSET_RE } from '@vitest/utils/constants';
53
53
  import { findNearestPackageData } from '@vitest/utils/resolver';
54
54
  import * as esModuleLexer from 'es-module-lexer';
55
- import { a as BenchmarkReportsMap } from './index.CMvpbrsJ.js';
55
+ import { a as BenchmarkReportsMap } from './index.B88tjlE5.js';
56
56
  import assert$1 from 'node:assert';
57
57
  import { serializeValue } from '@vitest/utils/serialize';
58
58
  import { parseErrorStacktrace } from '@vitest/utils/source-map';
@@ -5401,6 +5401,7 @@ function createFailedFileTask(project, filepath, error) {
5401
5401
  type: "suite",
5402
5402
  id: /* @__PURE__ */ generateHash$1(`${testFilepath}${project.config.name || ""}`),
5403
5403
  name: testFilepath,
5404
+ fullName: testFilepath,
5404
5405
  mode: "run",
5405
5406
  tasks: [],
5406
5407
  start: 0,
@@ -5438,6 +5439,7 @@ function createFileTask(testFilepath, code, requestMap, options) {
5438
5439
  type: "suite",
5439
5440
  id: /* @__PURE__ */ generateHash$1(`${testFilepath}${options.name || ""}`),
5440
5441
  name: testFilepath,
5442
+ fullName: testFilepath,
5441
5443
  mode: "run",
5442
5444
  tasks: [],
5443
5445
  start: ast.start,
@@ -5482,6 +5484,8 @@ function createFileTask(testFilepath, code, requestMap, options) {
5482
5484
  tasks: [],
5483
5485
  mode,
5484
5486
  name: definition.name,
5487
+ fullName: createTaskName([latestSuite.fullName, definition.name]),
5488
+ fullTestName: createTaskName([latestSuite.fullTestName, definition.name]),
5485
5489
  end: definition.end,
5486
5490
  start: definition.start,
5487
5491
  location,
@@ -5501,6 +5505,8 @@ function createFileTask(testFilepath, code, requestMap, options) {
5501
5505
  mode,
5502
5506
  context: {},
5503
5507
  name: definition.name,
5508
+ fullName: createTaskName([latestSuite.fullName, definition.name]),
5509
+ fullTestName: createTaskName([latestSuite.fullTestName, definition.name]),
5504
5510
  end: definition.end,
5505
5511
  start: definition.start,
5506
5512
  location,
@@ -5747,6 +5753,7 @@ const debugMemory = createDebugger("vitest:cache:memory");
5747
5753
  const cacheComment = "\n//# vitestCache=";
5748
5754
  const cacheCommentLength = 17;
5749
5755
  const METADATA_FILE = "_metadata.json";
5756
+ const parallelFsCacheRead = /* @__PURE__ */ new Map();
5750
5757
  /**
5751
5758
  * @experimental
5752
5759
  */
@@ -5759,7 +5766,7 @@ class FileSystemModuleCache {
5759
5766
  */
5760
5767
  rootCache;
5761
5768
  metadataFilePath;
5762
- version = "1.0.0-beta.1";
5769
+ version = "1.0.0-beta.2";
5763
5770
  fsCacheRoots = /* @__PURE__ */ new WeakMap();
5764
5771
  fsEnvironmentHashMap = /* @__PURE__ */ new WeakMap();
5765
5772
  fsCacheKeyGenerators = /* @__PURE__ */ new Set();
@@ -5786,25 +5793,30 @@ class FileSystemModuleCache {
5786
5793
  })));
5787
5794
  if (log) this.vitest.logger.log(`[cache] cleared fs module cache at ${uniquePaths.join(", ")}`);
5788
5795
  }
5796
+ readCachedFileConcurrently(cachedFilePath) {
5797
+ if (!parallelFsCacheRead.has(cachedFilePath)) parallelFsCacheRead.set(cachedFilePath, readFile(cachedFilePath, "utf-8").then((code) => {
5798
+ const matchIndex = code.lastIndexOf(cacheComment);
5799
+ if (matchIndex === -1) {
5800
+ debugFs?.(`${c.red("[empty]")} ${cachedFilePath} exists, but doesn't have a ${cacheComment} comment, transforming by vite instead`);
5801
+ return;
5802
+ }
5803
+ return {
5804
+ code,
5805
+ meta: this.fromBase64(code.slice(matchIndex + cacheCommentLength))
5806
+ };
5807
+ }).finally(() => {
5808
+ parallelFsCacheRead.delete(cachedFilePath);
5809
+ }));
5810
+ return parallelFsCacheRead.get(cachedFilePath);
5811
+ }
5789
5812
  async getCachedModule(cachedFilePath) {
5790
5813
  if (!existsSync(cachedFilePath)) {
5791
5814
  debugFs?.(`${c.red("[empty]")} ${cachedFilePath} doesn't exist, transforming by vite instead`);
5792
5815
  return;
5793
5816
  }
5794
- const code = await readFile(cachedFilePath, "utf-8");
5795
- const matchIndex = code.lastIndexOf(cacheComment);
5796
- if (matchIndex === -1) {
5797
- debugFs?.(`${c.red("[empty]")} ${cachedFilePath} exists, but doesn't have a ${cacheComment} comment, transforming by vite instead`);
5798
- return;
5799
- }
5800
- const meta = this.fromBase64(code.slice(matchIndex + cacheCommentLength));
5801
- if (meta.externalize) {
5802
- debugFs?.(`${c.green("[read]")} ${meta.externalize} is externalized inside ${cachedFilePath}`);
5803
- return {
5804
- externalize: meta.externalize,
5805
- type: meta.type
5806
- };
5807
- }
5817
+ const fileResult = await this.readCachedFileConcurrently(cachedFilePath);
5818
+ if (!fileResult) return;
5819
+ const { code, meta } = fileResult;
5808
5820
  debugFs?.(`${c.green("[read]")} ${meta.id} is cached in ${cachedFilePath}`);
5809
5821
  return {
5810
5822
  id: meta.id,
@@ -5816,10 +5828,7 @@ class FileSystemModuleCache {
5816
5828
  };
5817
5829
  }
5818
5830
  async saveCachedModule(cachedFilePath, fetchResult, importers = [], mappings = false) {
5819
- if ("externalize" in fetchResult) {
5820
- debugFs?.(`${c.yellow("[write]")} ${fetchResult.externalize} is externalized inside ${cachedFilePath}`);
5821
- await atomicWriteFile(cachedFilePath, `${cacheComment}${this.toBase64(fetchResult)}`);
5822
- } else if ("code" in fetchResult) {
5831
+ if ("code" in fetchResult) {
5823
5832
  const result = {
5824
5833
  file: fetchResult.file,
5825
5834
  id: fetchResult.id,
@@ -5853,7 +5862,6 @@ class FileSystemModuleCache {
5853
5862
  return result;
5854
5863
  }
5855
5864
  generateCachePath(vitestConfig, environment, resolver, id, fileContent) {
5856
- let hashString = "";
5857
5865
  // bail out if file has import.meta.glob because it depends on other files
5858
5866
  // TODO: figure out a way to still support it
5859
5867
  if (fileContent.includes("import.meta.glob(")) {
@@ -5861,6 +5869,7 @@ class FileSystemModuleCache {
5861
5869
  debugMemory?.(`${c.yellow("[write]")} ${id} was bailed out`);
5862
5870
  return null;
5863
5871
  }
5872
+ let hashString = "";
5864
5873
  for (const generator of this.fsCacheKeyGenerators) {
5865
5874
  const result = generator({
5866
5875
  environment,
@@ -5889,13 +5898,7 @@ class FileSystemModuleCache {
5889
5898
  plugins: config.plugins.map((p) => p.name),
5890
5899
  configFileDependencies: config.configFileDependencies.map((file) => tryReadFileSync(file)),
5891
5900
  environment: environment.name,
5892
- css: vitestConfig.css,
5893
- resolver: {
5894
- inline: resolver.options.inline,
5895
- external: resolver.options.external,
5896
- inlineFiles: resolver.options.inlineFiles,
5897
- moduleDirectories: resolver.options.moduleDirectories
5898
- }
5901
+ css: vitestConfig.css
5899
5902
  }, (_, value) => {
5900
5903
  if (typeof value === "function" || value instanceof RegExp) return value.toString();
5901
5904
  return value;
@@ -6111,6 +6114,11 @@ class ModuleFetcher {
6111
6114
  const cached = !!moduleGraphModule.transformResult;
6112
6115
  if (moduleGraphModule.file) trace.setAttribute("code.file.path", moduleGraphModule.file);
6113
6116
  if (options?.cached && cached) return { cache: true };
6117
+ const externalize = await this.resolver.shouldExternalize(moduleGraphModule.id);
6118
+ if (externalize) return {
6119
+ externalize,
6120
+ type: "module"
6121
+ };
6114
6122
  const cachePath = await this.getCachePath(environment, moduleGraphModule);
6115
6123
  // full fs caching is disabled, but we still want to keep tmp files if makeTmpCopies is enabled
6116
6124
  // this is primarily used by the forks pool to avoid using process.send(bigBuffer)
@@ -6156,7 +6164,7 @@ class ModuleFetcher {
6156
6164
  }
6157
6165
  recordResult(trace, result) {
6158
6166
  if ("externalize" in result) trace.setAttributes({
6159
- "vitest.module.external": result.externalize,
6167
+ "vitest.fetched_module.external": result.externalize,
6160
6168
  "vitest.fetched_module.type": result.type
6161
6169
  });
6162
6170
  if ("id" in result) {
@@ -6191,42 +6199,42 @@ class ModuleFetcher {
6191
6199
  return "";
6192
6200
  }
6193
6201
  async getCachedModule(cachePath, environment, moduleGraphModule) {
6202
+ if (moduleGraphModule.transformResult?.__vitestTmp) return {
6203
+ cached: true,
6204
+ file: moduleGraphModule.file,
6205
+ id: moduleGraphModule.id,
6206
+ tmp: moduleGraphModule.transformResult.__vitestTmp,
6207
+ url: moduleGraphModule.url,
6208
+ invalidate: false
6209
+ };
6194
6210
  const cachedModule = await this.fsCache.getCachedModule(cachePath);
6195
- if (cachedModule && "code" in cachedModule) {
6196
- // keep the module graph in sync
6197
- if (!moduleGraphModule.transformResult) {
6198
- let map = extractSourceMap(cachedModule.code);
6199
- if (map && cachedModule.file) map.file = cachedModule.file;
6200
- // mappings is a special source map identifier in rollup
6201
- if (!map && cachedModule.mappings) map = { mappings: "" };
6202
- moduleGraphModule.transformResult = {
6203
- code: cachedModule.code,
6204
- map,
6205
- ssr: true
6206
- };
6207
- // we populate the module graph to make the watch mode work because it relies on importers
6208
- cachedModule.importers.forEach((importer) => {
6209
- const environmentNode = environment.moduleGraph.getModuleById(importer);
6210
- if (environmentNode) moduleGraphModule.importers.add(environmentNode);
6211
- });
6212
- }
6213
- return {
6214
- cached: true,
6215
- file: cachedModule.file,
6216
- id: cachedModule.id,
6217
- tmp: cachePath,
6218
- url: cachedModule.url,
6219
- invalidate: false
6220
- };
6221
- }
6222
- return cachedModule;
6211
+ if (!cachedModule) return;
6212
+ // keep the module graph in sync
6213
+ let map = extractSourceMap(cachedModule.code);
6214
+ if (map && cachedModule.file) map.file = cachedModule.file;
6215
+ // mappings is a special source map identifier in rollup
6216
+ if (!map && cachedModule.mappings) map = { mappings: "" };
6217
+ moduleGraphModule.transformResult = {
6218
+ code: cachedModule.code,
6219
+ map,
6220
+ ssr: true,
6221
+ __vitestTmp: cachePath
6222
+ };
6223
+ // we populate the module graph to make the watch mode work because it relies on importers
6224
+ cachedModule.importers.forEach((importer) => {
6225
+ const environmentNode = environment.moduleGraph.getModuleById(importer);
6226
+ if (environmentNode) moduleGraphModule.importers.add(environmentNode);
6227
+ });
6228
+ return {
6229
+ cached: true,
6230
+ file: cachedModule.file,
6231
+ id: cachedModule.id,
6232
+ tmp: cachePath,
6233
+ url: cachedModule.url,
6234
+ invalidate: false
6235
+ };
6223
6236
  }
6224
6237
  async fetchAndProcess(environment, url, importer, moduleGraphModule, options) {
6225
- const externalize = await this.resolver.shouldExternalize(moduleGraphModule.id);
6226
- if (externalize) return {
6227
- externalize,
6228
- type: "module"
6229
- };
6230
6238
  return processResultSource(environment, await fetchModule(environment, url, importer, {
6231
6239
  ...options,
6232
6240
  inlineSourceMap: false
@@ -7177,7 +7185,6 @@ class PoolRunner {
7177
7185
  __vitest_worker_request__: true,
7178
7186
  type: method,
7179
7187
  context,
7180
- poolId: this.poolId,
7181
7188
  otelCarrier: this.getOTELCarrier()
7182
7189
  });
7183
7190
  }
@@ -7185,7 +7192,7 @@ class PoolRunner {
7185
7192
  const activeContext = this._otel?.currentContext || this._otel?.workerContext;
7186
7193
  return activeContext ? this._traces.getContextCarrier(activeContext) : void 0;
7187
7194
  }
7188
- async start() {
7195
+ async start(options) {
7189
7196
  // Wait for any ongoing operation to complete
7190
7197
  if (this._operationLock) await this._operationLock;
7191
7198
  if (this._state === RunnerState.STARTED || this._state === RunnerState.STARTING) return;
@@ -7209,6 +7216,8 @@ class PoolRunner {
7209
7216
  const tracesSdk = projectConfig?.sdkPath ?? globalConfig?.sdkPath;
7210
7217
  this.postMessage({
7211
7218
  type: "start",
7219
+ poolId: this.poolId,
7220
+ workerId: options.workerId,
7212
7221
  __vitest_worker_request__: true,
7213
7222
  options: { reportMemory: this.worker.reportMemory ?? false },
7214
7223
  context: {
@@ -7714,6 +7723,8 @@ class Pool {
7714
7723
  try {
7715
7724
  let isMemoryLimitReached = false;
7716
7725
  const runner = this.getPoolRunner(task, method);
7726
+ const poolId = runner.poolId ?? this.getWorkerId();
7727
+ runner.poolId = poolId;
7717
7728
  const activeTask = {
7718
7729
  task,
7719
7730
  resolver,
@@ -7740,10 +7751,8 @@ class Pool {
7740
7751
  resolver.reject(new Error(`[vitest-pool]: Worker ${task.worker} emitted error.`, { cause: error }));
7741
7752
  });
7742
7753
  const id = setTimeout(() => resolver.reject(/* @__PURE__ */ new Error(`[vitest-pool]: Timeout starting ${task.worker} runner.`)), WORKER_START_TIMEOUT);
7743
- await runner.start().finally(() => clearTimeout(id));
7754
+ await runner.start({ workerId: task.context.workerId }).finally(() => clearTimeout(id));
7744
7755
  }
7745
- const poolId = runner.poolId ?? this.getWorkerId();
7746
- runner.poolId = poolId;
7747
7756
  const span = runner.startTracesSpan(`vitest.worker.${method}`);
7748
7757
  // Start running the test in the worker
7749
7758
  runner.request(method, task.context);
@@ -201,21 +201,4 @@ type RuntimeConfig = Pick<SerializedConfig, "allowOnly" | "testTimeout" | "hookT
201
201
  type RuntimeOptions = Partial<RuntimeConfig>;
202
202
  type BrowserTraceViewMode = "on" | "off" | "on-first-retry" | "on-all-retries" | "retain-on-failure";
203
203
 
204
- interface OTELCarrier {
205
- traceparent?: string;
206
- tracestate?: string;
207
- }
208
- interface TracesOptions {
209
- enabled: boolean;
210
- watchMode?: boolean;
211
- sdkPath?: string;
212
- tracerName?: string;
213
- }
214
- declare class Traces {
215
- #private;
216
- constructor(options: TracesOptions);
217
- isEnabled(): boolean;
218
- }
219
-
220
- export { Traces as T };
221
- export type { BrowserTraceViewMode as B, FakeTimerInstallOpts as F, OTELCarrier as O, RuntimeOptions as R, SerializedConfig as S, SerializedCoverageConfig as a, RuntimeConfig as b };
204
+ export type { BrowserTraceViewMode as B, FakeTimerInstallOpts as F, RuntimeOptions as R, SerializedConfig as S, SerializedCoverageConfig as a, RuntimeConfig as b };
@@ -2,7 +2,7 @@ import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
2
2
  import { Plugin } from '@vitest/pretty-format';
3
3
  import { SnapshotState } from '@vitest/snapshot';
4
4
  import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
5
- import { U as UserConsoleLog } from './worker.d.Dxl5oW0C.js';
5
+ import { U as UserConsoleLog } from './rpc.d.RH3apGEf.js';
6
6
 
7
7
  interface SnapshotMatcher<T> {
8
8
  <U extends { [P in keyof T] : any }>(snapshot: Partial<U>, hint?: string): void;
@@ -2,7 +2,7 @@ import fs from 'node:fs';
2
2
  import { getTasks, getFullName, getTests } from '@vitest/runner/utils';
3
3
  import * as pathe from 'pathe';
4
4
  import c from 'tinyrainbow';
5
- import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.DWDW6mLz.js';
5
+ import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.D6PC4Dpu.js';
6
6
  import { stripVTControlCharacters } from 'node:util';
7
7
  import { notNullish } from '@vitest/utils/helpers';
8
8
 
@@ -588,9 +588,20 @@ function createCompatUtils(window) {
588
588
  return utils;
589
589
  }
590
590
  function patchAddEventListener(window) {
591
+ const abortControllers = /* @__PURE__ */ new WeakMap();
591
592
  const JSDOMAbortSignal = window.AbortSignal;
592
593
  const JSDOMAbortController = window.AbortController;
593
594
  const originalAddEventListener = window.EventTarget.prototype.addEventListener;
595
+ function getJsdomAbortController(signal) {
596
+ if (!abortControllers.has(signal)) {
597
+ const jsdomAbortController = new JSDOMAbortController();
598
+ signal.addEventListener("abort", () => {
599
+ jsdomAbortController.abort(signal.reason);
600
+ });
601
+ abortControllers.set(signal, jsdomAbortController);
602
+ }
603
+ return abortControllers.get(signal);
604
+ }
594
605
  window.EventTarget.prototype.addEventListener = function addEventListener(type, callback, options) {
595
606
  if (typeof options === "object" && options.signal != null) {
596
607
  const { signal, ...otherOptions } = options;
@@ -601,13 +612,7 @@ function patchAddEventListener(window) {
601
612
  if (!(signal instanceof JSDOMAbortSignal)) {
602
613
  const jsdomCompatOptions = Object.create(null);
603
614
  Object.assign(jsdomCompatOptions, otherOptions);
604
- // use jsdom-native abort controller instead and forward the
605
- // previous one with `addEventListener`
606
- const jsdomAbortController = new JSDOMAbortController();
607
- signal.addEventListener("abort", () => {
608
- jsdomAbortController.abort(signal.reason);
609
- });
610
- jsdomCompatOptions.signal = jsdomAbortController.signal;
615
+ jsdomCompatOptions.signal = getJsdomAbortController(signal).signal;
611
616
  return originalAddEventListener.call(this, type, callback, jsdomCompatOptions);
612
617
  }
613
618
  }
@@ -2,7 +2,7 @@ import { existsSync, readFileSync, promises } from 'node:fs';
2
2
  import { mkdir, writeFile, readdir, stat, readFile } from 'node:fs/promises';
3
3
  import { resolve as resolve$1, dirname, isAbsolute, relative, basename, join, normalize } from 'pathe';
4
4
  import { performance as performance$1 } from 'node:perf_hooks';
5
- import { getTests, getTestName, hasFailed, getSuites, generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, getFullName } from '@vitest/runner/utils';
5
+ import { getTests, getTestName, hasFailed, getSuites, generateHash, createTaskName, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, getFullName } from '@vitest/runner/utils';
6
6
  import { slash, toArray, isPrimitive } from '@vitest/utils/helpers';
7
7
  import { parseStacktrace, defaultStackIgnorePatterns, parseErrorStacktrace } from '@vitest/utils/source-map';
8
8
  import c from 'tinyrainbow';
@@ -795,16 +795,14 @@ class BaseReporter {
795
795
  // Execution time is either sum of all runs of `--merge-reports` or the current run's time
796
796
  const executionTime = blobs?.executionTimes ? sum(blobs.executionTimes, (time) => time) : this.end - this.start;
797
797
  const environmentTime = sum(files, (file) => file.environmentLoad);
798
- const prepareTime = sum(files, (file) => file.prepareDuration);
799
798
  const transformTime = this.ctx.state.transformTime;
800
799
  const typecheck = sum(this.ctx.projects, (project) => project.typechecker?.getResult().time);
801
800
  const timers = [
802
801
  `transform ${formatTime(transformTime)}`,
803
802
  `setup ${formatTime(setupTime)}`,
804
- `collect ${formatTime(collectTime)}`,
803
+ `import ${formatTime(collectTime)}`,
805
804
  `tests ${formatTime(testsTime)}`,
806
805
  `environment ${formatTime(environmentTime)}`,
807
- `prepare ${formatTime(prepareTime)}`,
808
806
  typecheck && `typecheck ${formatTime(typecheck)}`
809
807
  ].filter(Boolean).join(", ");
810
808
  this.log(padSummaryTitle("Duration"), formatTime(executionTime) + c.dim(` (${timers})`));
@@ -2350,6 +2348,7 @@ async function collectTests(ctx, filepath) {
2350
2348
  type: "suite",
2351
2349
  id: generateHash(`${testFilepath}${projectName ? `${projectName}:__typecheck__` : "__typecheck__"}`),
2352
2350
  name: testFilepath,
2351
+ fullName: testFilepath,
2353
2352
  mode: "run",
2354
2353
  tasks: [],
2355
2354
  start: ast.start,
@@ -2442,6 +2441,8 @@ async function collectTests(ctx, filepath) {
2442
2441
  tasks: [],
2443
2442
  mode,
2444
2443
  name: definition.name,
2444
+ fullName: createTaskName([lastSuite.fullName, definition.name]),
2445
+ fullTestName: createTaskName([lastSuite.fullTestName, definition.name]),
2445
2446
  end: definition.end,
2446
2447
  start: definition.start,
2447
2448
  meta: { typecheck: true }
@@ -2460,6 +2461,8 @@ async function collectTests(ctx, filepath) {
2460
2461
  timeout: 0,
2461
2462
  context: {},
2462
2463
  name: definition.name,
2464
+ fullName: createTaskName([lastSuite.fullName, definition.name]),
2465
+ fullTestName: createTaskName([lastSuite.fullTestName, definition.name]),
2463
2466
  end: definition.end,
2464
2467
  start: definition.start,
2465
2468
  annotations: [],
@@ -3500,6 +3503,8 @@ class JUnitReporter {
3500
3503
  id: file.id,
3501
3504
  type: "test",
3502
3505
  name: file.name,
3506
+ fullName: file.name,
3507
+ fullTestName: file.name,
3503
3508
  mode: "run",
3504
3509
  result: file.result,
3505
3510
  meta: {},
@@ -1,4 +1,4 @@
1
- import { i as init } from './init.D-GGeAxo.js';
1
+ import { i as init } from './init.a5SCIJ0x.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.D-GGeAxo.js';
2
+ import { i as init } from './init.a5SCIJ0x.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) {
@@ -3,8 +3,8 @@ import { isBuiltin } from 'node:module';
3
3
  import { pathToFileURL } from 'node:url';
4
4
  import { resolve } from 'pathe';
5
5
  import { ModuleRunner } from 'vite/module-runner';
6
- import { b as VitestTransport } from './startModuleRunner.BEYtrq5Y.js';
7
- import { e as environments } from './index.QWbK7rHY.js';
6
+ import { b as VitestTransport } from './startModuleRunner.W28wBIgJ.js';
7
+ import { e as environments } from './index.BspFP3mn.js';
8
8
  import { serializeError } from '@vitest/utils/error';
9
9
  import { T as Traces } from './traces.U4xDYhzZ.js';
10
10
  import { o as onCancel, a as rpcDone, c as createRuntimeRpc } from './rpc.BytlcPfC.js';
@@ -158,6 +158,8 @@ function init(worker) {
158
158
  if (message?.__vitest_worker_request__ !== true) return;
159
159
  switch (message.type) {
160
160
  case "start": {
161
+ process.env.VITEST_POOL_ID = String(message.poolId);
162
+ process.env.VITEST_WORKER_ID = String(message.workerId);
161
163
  reportMemory = message.options.reportMemory;
162
164
  const tracesStart = performance.now();
163
165
  traces ??= await new Traces({
@@ -203,7 +205,6 @@ function init(worker) {
203
205
  return;
204
206
  }
205
207
  try {
206
- process.env.VITEST_POOL_ID = String(message.poolId);
207
208
  process.env.VITEST_WORKER_ID = String(message.context.workerId);
208
209
  } catch (error) {
209
210
  return send({
@@ -248,7 +249,6 @@ function init(worker) {
248
249
  return;
249
250
  }
250
251
  try {
251
- process.env.VITEST_POOL_ID = String(message.poolId);
252
252
  process.env.VITEST_WORKER_ID = String(message.context.workerId);
253
253
  } catch (error) {
254
254
  return send({
@@ -1,5 +1,5 @@
1
1
  import { DevEnvironment } from 'vite';
2
- import { V as Vitest, T as TestProject, b as TestProjectConfiguration } from './reporters.d.C2PtoEFY.js';
2
+ import { V as Vitest, T as TestProject, b as TestProjectConfiguration } from './reporters.d.DeFcIuza.js';
3
3
 
4
4
  /**
5
5
  * Generate a unique cache identifier.