vitest 4.0.12 → 4.0.13

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 (36) hide show
  1. package/dist/browser.d.ts +7 -10
  2. package/dist/chunks/{base.CDEiaaLz.js → base.Dqf2QAxh.js} +2 -2
  3. package/dist/chunks/{browser.d.Bq3zc1l_.d.ts → browser.d.CDvMh6F9.d.ts} +1 -1
  4. package/dist/chunks/{cac.D9QaLeSz.js → cac.L-UbQ_Ix.js} +3 -3
  5. package/dist/chunks/{cli-api.BJh-POxZ.js → cli-api.CdZ6wo9-.js} +58 -56
  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/{init-forks.FphdQhPI.js → init-forks.CglOH45c.js} +1 -1
  9. package/dist/chunks/{init-threads.BfqfWDNi.js → init-threads.BuMdIy1r.js} +1 -1
  10. package/dist/chunks/{init.D-GGeAxo.js → init.MkYs5nmh.js} +1 -1
  11. package/dist/chunks/{plugin.d.DGpEw-QV.d.ts → plugin.d.B4l3vYM_.d.ts} +1 -1
  12. package/dist/chunks/{reporters.d.C2PtoEFY.d.ts → reporters.d.J2RlBlp9.d.ts} +5 -3
  13. package/dist/chunks/rpc.d.RH3apGEf.d.ts +64 -0
  14. package/dist/chunks/{startModuleRunner.BEYtrq5Y.js → startModuleRunner.W28wBIgJ.js} +3 -0
  15. package/dist/chunks/traces.d.402V_yFI.d.ts +18 -0
  16. package/dist/chunks/{vm.tWlKAMXr.js → vm.Y19jrZy2.js} +2 -2
  17. package/dist/chunks/{worker.d.Dxl5oW0C.d.ts → worker.d.DCy61tzi.d.ts} +5 -63
  18. package/dist/cli.js +1 -1
  19. package/dist/config.d.ts +10 -8
  20. package/dist/coverage.d.ts +8 -6
  21. package/dist/index.d.ts +16 -9
  22. package/dist/module-evaluator.d.ts +117 -12
  23. package/dist/module-runner.js +1 -1
  24. package/dist/node.d.ts +10 -8
  25. package/dist/node.js +3 -3
  26. package/dist/reporters.d.ts +10 -8
  27. package/dist/runners.d.ts +2 -1
  28. package/dist/worker.d.ts +6 -4
  29. package/dist/worker.js +3 -3
  30. package/dist/workers/forks.js +4 -4
  31. package/dist/workers/threads.js +4 -4
  32. package/dist/workers/vmForks.js +4 -4
  33. package/dist/workers/vmThreads.js +4 -4
  34. package/package.json +12 -12
  35. package/dist/chunks/mocker.d.BE_2ls6u.d.ts +0 -17
  36. 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.MkYs5nmh.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.DCy61tzi.js';
3
3
 
4
4
  type SerializedTestSpecification = [project: {
5
5
  name: string | undefined;
@@ -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.13";
623
623
 
624
624
  const apiConfig = (port) => ({
625
625
  port: {
@@ -1371,7 +1371,7 @@ 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.CdZ6wo9-.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) {
@@ -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.CdZ6wo9-.js').then(function (n) { return n.p; });
1397
1397
  const ctx = await prepareVitest(mode, {
1398
1398
  ...normalizeCliOptions(cliFilters, options),
1399
1399
  watch: false,
@@ -12,7 +12,7 @@ import * as nodeos from 'node:os';
12
12
  import nodeos__default, { tmpdir } from 'node:os';
13
13
  import { generateHash as generateHash$1, 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.L-UbQ_Ix.js';
16
16
  import { performance as performance$1 } from 'node:perf_hooks';
17
17
  import { c as createBirpc } from './index.0kCJoeWi.js';
18
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';
@@ -5747,6 +5747,7 @@ const debugMemory = createDebugger("vitest:cache:memory");
5747
5747
  const cacheComment = "\n//# vitestCache=";
5748
5748
  const cacheCommentLength = 17;
5749
5749
  const METADATA_FILE = "_metadata.json";
5750
+ const parallelFsCacheRead = /* @__PURE__ */ new Map();
5750
5751
  /**
5751
5752
  * @experimental
5752
5753
  */
@@ -5786,25 +5787,30 @@ class FileSystemModuleCache {
5786
5787
  })));
5787
5788
  if (log) this.vitest.logger.log(`[cache] cleared fs module cache at ${uniquePaths.join(", ")}`);
5788
5789
  }
5790
+ readCachedFileConcurrently(cachedFilePath) {
5791
+ if (!parallelFsCacheRead.has(cachedFilePath)) parallelFsCacheRead.set(cachedFilePath, readFile(cachedFilePath, "utf-8").then((code) => {
5792
+ const matchIndex = code.lastIndexOf(cacheComment);
5793
+ if (matchIndex === -1) {
5794
+ debugFs?.(`${c.red("[empty]")} ${cachedFilePath} exists, but doesn't have a ${cacheComment} comment, transforming by vite instead`);
5795
+ return;
5796
+ }
5797
+ return {
5798
+ code,
5799
+ meta: this.fromBase64(code.slice(matchIndex + cacheCommentLength))
5800
+ };
5801
+ }).finally(() => {
5802
+ parallelFsCacheRead.delete(cachedFilePath);
5803
+ }));
5804
+ return parallelFsCacheRead.get(cachedFilePath);
5805
+ }
5789
5806
  async getCachedModule(cachedFilePath) {
5790
5807
  if (!existsSync(cachedFilePath)) {
5791
5808
  debugFs?.(`${c.red("[empty]")} ${cachedFilePath} doesn't exist, transforming by vite instead`);
5792
5809
  return;
5793
5810
  }
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
- }
5811
+ const fileResult = await this.readCachedFileConcurrently(cachedFilePath);
5812
+ if (!fileResult) return;
5813
+ const { code, meta } = fileResult;
5808
5814
  debugFs?.(`${c.green("[read]")} ${meta.id} is cached in ${cachedFilePath}`);
5809
5815
  return {
5810
5816
  id: meta.id,
@@ -5816,10 +5822,7 @@ class FileSystemModuleCache {
5816
5822
  };
5817
5823
  }
5818
5824
  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) {
5825
+ if ("code" in fetchResult) {
5823
5826
  const result = {
5824
5827
  file: fetchResult.file,
5825
5828
  id: fetchResult.id,
@@ -5853,7 +5856,6 @@ class FileSystemModuleCache {
5853
5856
  return result;
5854
5857
  }
5855
5858
  generateCachePath(vitestConfig, environment, resolver, id, fileContent) {
5856
- let hashString = "";
5857
5859
  // bail out if file has import.meta.glob because it depends on other files
5858
5860
  // TODO: figure out a way to still support it
5859
5861
  if (fileContent.includes("import.meta.glob(")) {
@@ -5861,6 +5863,7 @@ class FileSystemModuleCache {
5861
5863
  debugMemory?.(`${c.yellow("[write]")} ${id} was bailed out`);
5862
5864
  return null;
5863
5865
  }
5866
+ let hashString = "";
5864
5867
  for (const generator of this.fsCacheKeyGenerators) {
5865
5868
  const result = generator({
5866
5869
  environment,
@@ -5889,13 +5892,7 @@ class FileSystemModuleCache {
5889
5892
  plugins: config.plugins.map((p) => p.name),
5890
5893
  configFileDependencies: config.configFileDependencies.map((file) => tryReadFileSync(file)),
5891
5894
  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
- }
5895
+ css: vitestConfig.css
5899
5896
  }, (_, value) => {
5900
5897
  if (typeof value === "function" || value instanceof RegExp) return value.toString();
5901
5898
  return value;
@@ -6156,7 +6153,7 @@ class ModuleFetcher {
6156
6153
  }
6157
6154
  recordResult(trace, result) {
6158
6155
  if ("externalize" in result) trace.setAttributes({
6159
- "vitest.module.external": result.externalize,
6156
+ "vitest.fetched_module.external": result.externalize,
6160
6157
  "vitest.fetched_module.type": result.type
6161
6158
  });
6162
6159
  if ("id" in result) {
@@ -6191,35 +6188,40 @@ class ModuleFetcher {
6191
6188
  return "";
6192
6189
  }
6193
6190
  async getCachedModule(cachePath, environment, moduleGraphModule) {
6191
+ if (moduleGraphModule.transformResult?.__vitestTmp) return {
6192
+ cached: true,
6193
+ file: moduleGraphModule.file,
6194
+ id: moduleGraphModule.id,
6195
+ tmp: moduleGraphModule.transformResult.__vitestTmp,
6196
+ url: moduleGraphModule.url,
6197
+ invalidate: false
6198
+ };
6194
6199
  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;
6200
+ if (!cachedModule) return;
6201
+ // keep the module graph in sync
6202
+ let map = extractSourceMap(cachedModule.code);
6203
+ if (map && cachedModule.file) map.file = cachedModule.file;
6204
+ // mappings is a special source map identifier in rollup
6205
+ if (!map && cachedModule.mappings) map = { mappings: "" };
6206
+ moduleGraphModule.transformResult = {
6207
+ code: cachedModule.code,
6208
+ map,
6209
+ ssr: true,
6210
+ __vitestTmp: cachePath
6211
+ };
6212
+ // we populate the module graph to make the watch mode work because it relies on importers
6213
+ cachedModule.importers.forEach((importer) => {
6214
+ const environmentNode = environment.moduleGraph.getModuleById(importer);
6215
+ if (environmentNode) moduleGraphModule.importers.add(environmentNode);
6216
+ });
6217
+ return {
6218
+ cached: true,
6219
+ file: cachedModule.file,
6220
+ id: cachedModule.id,
6221
+ tmp: cachePath,
6222
+ url: cachedModule.url,
6223
+ invalidate: false
6224
+ };
6223
6225
  }
6224
6226
  async fetchAndProcess(environment, url, importer, moduleGraphModule, options) {
6225
6227
  const externalize = await this.resolver.shouldExternalize(moduleGraphModule.id);
@@ -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;
@@ -1,4 +1,4 @@
1
- import { i as init } from './init.D-GGeAxo.js';
1
+ import { i as init } from './init.MkYs5nmh.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.MkYs5nmh.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,7 +3,7 @@ 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';
6
+ import { b as VitestTransport } from './startModuleRunner.W28wBIgJ.js';
7
7
  import { e as environments } from './index.QWbK7rHY.js';
8
8
  import { serializeError } from '@vitest/utils/error';
9
9
  import { T as Traces } from './traces.U4xDYhzZ.js';
@@ -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.J2RlBlp9.js';
3
3
 
4
4
  /**
5
5
  * Generate a unique cache identifier.
@@ -1,18 +1,20 @@
1
1
  import { TaskMeta, Suite, File, TestAnnotation, TestArtifact, ImportDuration, Test, Task, TaskResultPack, FileSpecification, CancelReason, SequenceSetupFiles, SequenceHooks } from '@vitest/runner';
2
2
  import { TestError, SerializedError, Arrayable, ParsedStack, Awaitable } from '@vitest/utils';
3
- import { A as AfterSuiteRunMeta, U as UserConsoleLog, P as ProvidedContext, d as ContextTestEnvironment, f as WorkerTestEnvironment, g as WorkerExecuteContext, L as LabelColor } from './worker.d.Dxl5oW0C.js';
3
+ import { A as AfterSuiteRunMeta, U as UserConsoleLog, P as ProvidedContext, L as LabelColor } from './rpc.d.RH3apGEf.js';
4
4
  import { Writable } from 'node:stream';
5
5
  import { TransformResult as TransformResult$1, ViteDevServer, Plugin, UserConfig as UserConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
6
6
  import { MockedModule } from '@vitest/mocker';
7
7
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
8
8
  import { BrowserCommands } from 'vitest/browser';
9
- import { B as BrowserTraceViewMode, S as SerializedConfig, O as OTELCarrier, F as FakeTimerInstallOpts } from './traces.d.Brik_NWu.js';
10
- import { S as SerializedTestSpecification, B as BrowserTesterOptions } from './browser.d.Bq3zc1l_.js';
9
+ import { B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.g6OOauRt.js';
10
+ import { S as SerializedTestSpecification, B as BrowserTesterOptions } from './browser.d.CDvMh6F9.js';
11
11
  import { PrettyFormatOptions } from '@vitest/pretty-format';
12
12
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
13
13
  import { SerializedDiffOptions } from '@vitest/utils/diff';
14
14
  import { chai } from '@vitest/expect';
15
15
  import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
16
+ import { c as ContextTestEnvironment, d as WorkerTestEnvironment, e as WorkerExecuteContext } from './worker.d.DCy61tzi.js';
17
+ import { O as OTELCarrier } from './traces.d.402V_yFI.js';
16
18
  import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
17
19
  import { a as RuntimeCoverageProviderModule } from './coverage.d.BZtK59WP.js';
18
20
  import { SnapshotManager } from '@vitest/snapshot/manager';
@@ -0,0 +1,64 @@
1
+ import { CancelReason, File, TestArtifact, TaskResultPack, TaskEventPack } from '@vitest/runner';
2
+ import { SnapshotResult } from '@vitest/snapshot';
3
+ import { FetchFunctionOptions, FetchResult } from 'vite/module-runner';
4
+ import { O as OTELCarrier } from './traces.d.402V_yFI.js';
5
+
6
+ interface AfterSuiteRunMeta {
7
+ coverage?: unknown;
8
+ testFiles: string[];
9
+ environment: string;
10
+ projectName?: string;
11
+ }
12
+ interface UserConsoleLog {
13
+ content: string;
14
+ origin?: string;
15
+ browser?: boolean;
16
+ type: "stdout" | "stderr";
17
+ taskId?: string;
18
+ time: number;
19
+ size: number;
20
+ }
21
+ interface ModuleGraphData {
22
+ graph: Record<string, string[]>;
23
+ externalized: string[];
24
+ inlined: string[];
25
+ }
26
+ interface ProvidedContext {}
27
+ interface ResolveFunctionResult {
28
+ id: string;
29
+ file: string;
30
+ url: string;
31
+ }
32
+ interface FetchCachedFileSystemResult {
33
+ cached: true;
34
+ tmp: string;
35
+ id: string;
36
+ file: string | null;
37
+ url: string;
38
+ invalidate: boolean;
39
+ }
40
+ type LabelColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white";
41
+
42
+ interface RuntimeRPC {
43
+ fetch: (id: string, importer: string | undefined, environment: string, options?: FetchFunctionOptions, otelCarrier?: OTELCarrier) => Promise<FetchResult | FetchCachedFileSystemResult>;
44
+ resolve: (id: string, importer: string | undefined, environment: string) => Promise<ResolveFunctionResult | null>;
45
+ transform: (id: string) => Promise<{
46
+ code?: string;
47
+ }>;
48
+ onUserConsoleLog: (log: UserConsoleLog) => void;
49
+ onUnhandledError: (err: unknown, type: string) => void;
50
+ onQueued: (file: File) => void;
51
+ onCollected: (files: File[]) => Promise<void>;
52
+ onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
53
+ onTaskArtifactRecord: <Artifact extends TestArtifact>(testId: string, artifact: Artifact) => Promise<Artifact>;
54
+ onTaskUpdate: (pack: TaskResultPack[], events: TaskEventPack[]) => Promise<void>;
55
+ onCancel: (reason: CancelReason) => void;
56
+ getCountOfFailedTests: () => number;
57
+ snapshotSaved: (snapshot: SnapshotResult) => void;
58
+ resolveSnapshotPath: (testPath: string) => string;
59
+ }
60
+ interface RunnerRPC {
61
+ onCancel: (reason: CancelReason) => void;
62
+ }
63
+
64
+ export type { AfterSuiteRunMeta as A, LabelColor as L, ModuleGraphData as M, ProvidedContext as P, RuntimeRPC as R, UserConsoleLog as U, RunnerRPC as a };
@@ -821,6 +821,9 @@ function startVitestModuleRunner(options) {
821
821
  externalize: toBuiltin(rawId),
822
822
  type: "builtin"
823
823
  };
824
+ // if module is invalidated, the worker will be recreated,
825
+ // so cached is always true in a single worker
826
+ if (options?.cached) return { cache: true };
824
827
  const otelCarrier = traces?.getContextCarrier();
825
828
  const result = await rpc().fetch(id, importer, environment(), options, otelCarrier);
826
829
  if ("cached" in result) return {
@@ -0,0 +1,18 @@
1
+ interface OTELCarrier {
2
+ traceparent?: string;
3
+ tracestate?: string;
4
+ }
5
+ interface TracesOptions {
6
+ enabled: boolean;
7
+ watchMode?: boolean;
8
+ sdkPath?: string;
9
+ tracerName?: string;
10
+ }
11
+ declare class Traces {
12
+ #private;
13
+ constructor(options: TracesOptions);
14
+ isEnabled(): boolean;
15
+ }
16
+
17
+ export { Traces as T };
18
+ export type { OTELCarrier as O };
@@ -1,7 +1,7 @@
1
1
  import { fileURLToPath, pathToFileURL } from 'node:url';
2
2
  import vm, { isContext, runInContext } from 'node:vm';
3
3
  import { dirname, basename, extname, normalize, resolve } from 'pathe';
4
- import { l as loadEnvironment } from './init.D-GGeAxo.js';
4
+ import { l as loadEnvironment } from './init.MkYs5nmh.js';
5
5
  import { distDir } from '../path.js';
6
6
  import { createCustomConsole } from './console.Cf-YriPC.js';
7
7
  import fs from 'node:fs';
@@ -11,7 +11,7 @@ import { findNearestPackageData } from '@vitest/utils/resolver';
11
11
  import { dirname as dirname$1 } from 'node:path';
12
12
  import { CSS_LANGS_RE, KNOWN_ASSET_RE } from '@vitest/utils/constants';
13
13
  import { getDefaultRequestStubs } from '../module-evaluator.js';
14
- import { s as startVitestModuleRunner, c as createNodeImportMeta, a as VITEST_VM_CONTEXT_SYMBOL } from './startModuleRunner.BEYtrq5Y.js';
14
+ import { s as startVitestModuleRunner, c as createNodeImportMeta, a as VITEST_VM_CONTEXT_SYMBOL } from './startModuleRunner.W28wBIgJ.js';
15
15
  import { p as provideWorkerState } from './utils.DvEY5TfP.js';
16
16
 
17
17
  function interopCommonJsModule(interopDefault, mod) {
@@ -1,44 +1,8 @@
1
- import { CancelReason, File, TestArtifact, TaskResultPack, TaskEventPack, FileSpecification, Task } from '@vitest/runner';
2
- import { FetchFunctionOptions, FetchResult, EvaluatedModules } from 'vite/module-runner';
3
- import { O as OTELCarrier, S as SerializedConfig } from './traces.d.Brik_NWu.js';
1
+ import { FileSpecification, Task, CancelReason } from '@vitest/runner';
2
+ import { EvaluatedModules } from 'vite/module-runner';
3
+ import { S as SerializedConfig } from './config.d.g6OOauRt.js';
4
4
  import { E as Environment } from './environment.d.CrsxCzP1.js';
5
- import { SnapshotResult } from '@vitest/snapshot';
6
-
7
- interface AfterSuiteRunMeta {
8
- coverage?: unknown;
9
- testFiles: string[];
10
- environment: string;
11
- projectName?: string;
12
- }
13
- interface UserConsoleLog {
14
- content: string;
15
- origin?: string;
16
- browser?: boolean;
17
- type: "stdout" | "stderr";
18
- taskId?: string;
19
- time: number;
20
- size: number;
21
- }
22
- interface ModuleGraphData {
23
- graph: Record<string, string[]>;
24
- externalized: string[];
25
- inlined: string[];
26
- }
27
- interface ProvidedContext {}
28
- interface ResolveFunctionResult {
29
- id: string;
30
- file: string;
31
- url: string;
32
- }
33
- interface FetchCachedFileSystemResult {
34
- cached: true;
35
- tmp: string;
36
- id: string;
37
- file: string | null;
38
- url: string;
39
- invalidate: boolean;
40
- }
41
- type LabelColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white";
5
+ import { R as RuntimeRPC, a as RunnerRPC } from './rpc.d.RH3apGEf.js';
42
6
 
43
7
  type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
44
8
  type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
@@ -207,28 +171,6 @@ interface Request {
207
171
  }
208
172
  declare const setTimeout: typeof globalThis.setTimeout;
209
173
 
210
- interface RuntimeRPC {
211
- fetch: (id: string, importer: string | undefined, environment: string, options?: FetchFunctionOptions, otelCarrier?: OTELCarrier) => Promise<FetchResult | FetchCachedFileSystemResult>;
212
- resolve: (id: string, importer: string | undefined, environment: string) => Promise<ResolveFunctionResult | null>;
213
- transform: (id: string) => Promise<{
214
- code?: string;
215
- }>;
216
- onUserConsoleLog: (log: UserConsoleLog) => void;
217
- onUnhandledError: (err: unknown, type: string) => void;
218
- onQueued: (file: File) => void;
219
- onCollected: (files: File[]) => Promise<void>;
220
- onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
221
- onTaskArtifactRecord: <Artifact extends TestArtifact>(testId: string, artifact: Artifact) => Promise<Artifact>;
222
- onTaskUpdate: (pack: TaskResultPack[], events: TaskEventPack[]) => Promise<void>;
223
- onCancel: (reason: CancelReason) => void;
224
- getCountOfFailedTests: () => number;
225
- snapshotSaved: (snapshot: SnapshotResult) => void;
226
- resolveSnapshotPath: (testPath: string) => string;
227
- }
228
- interface RunnerRPC {
229
- onCancel: (reason: CancelReason) => void;
230
- }
231
-
232
174
  type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;
233
175
  interface ContextTestEnvironment {
234
176
  name: string;
@@ -293,4 +235,4 @@ interface WorkerGlobalState {
293
235
  onFilterStackTrace?: (trace: string) => string;
294
236
  }
295
237
 
296
- export type { AfterSuiteRunMeta as A, BirpcOptions as B, ContextRPC as C, LabelColor as L, ModuleGraphData as M, ProvidedContext as P, RuntimeRPC as R, TestExecutionMethod as T, UserConsoleLog as U, WorkerGlobalState as W, WorkerSetupContext as a, BirpcReturn as b, RunnerRPC as c, ContextTestEnvironment as d, ResolveFunctionResult as e, WorkerTestEnvironment as f, WorkerExecuteContext as g };
238
+ export type { BirpcOptions as B, ContextRPC as C, TestExecutionMethod as T, WorkerGlobalState as W, WorkerSetupContext as a, BirpcReturn as b, ContextTestEnvironment as c, WorkerTestEnvironment as d, WorkerExecuteContext as e };
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createCLI } from './chunks/cac.D9QaLeSz.js';
1
+ import { c as createCLI } from './chunks/cac.L-UbQ_Ix.js';
2
2
  import '@vitest/utils/helpers';
3
3
  import 'events';
4
4
  import 'pathe';
package/dist/config.d.ts CHANGED
@@ -1,20 +1,22 @@
1
1
  import { HookHandler, ConfigEnv, UserConfig } from 'vite';
2
2
  export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';
3
- import { I as InlineConfig, c as CoverageV8Options, R as ResolvedCoverageOptions, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport } from './chunks/reporters.d.C2PtoEFY.js';
4
- export { b as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.C2PtoEFY.js';
5
- import { V as VitestPluginContext } from './chunks/plugin.d.DGpEw-QV.js';
6
- import { F as FakeTimerInstallOpts } from './chunks/traces.d.Brik_NWu.js';
3
+ import { I as InlineConfig, c as CoverageV8Options, R as ResolvedCoverageOptions, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport } from './chunks/reporters.d.J2RlBlp9.js';
4
+ export { b as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.J2RlBlp9.js';
5
+ import { V as VitestPluginContext } from './chunks/plugin.d.B4l3vYM_.js';
6
+ import { F as FakeTimerInstallOpts } from './chunks/config.d.g6OOauRt.js';
7
7
  import '@vitest/runner';
8
8
  import '@vitest/utils';
9
- import './chunks/worker.d.Dxl5oW0C.js';
10
- import 'vite/module-runner';
11
- import './chunks/environment.d.CrsxCzP1.js';
9
+ import './chunks/rpc.d.RH3apGEf.js';
12
10
  import '@vitest/snapshot';
11
+ import 'vite/module-runner';
12
+ import './chunks/traces.d.402V_yFI.js';
13
13
  import 'node:stream';
14
14
  import '@vitest/mocker';
15
15
  import '@vitest/utils/source-map';
16
16
  import 'vitest/browser';
17
- import './chunks/browser.d.Bq3zc1l_.js';
17
+ import './chunks/browser.d.CDvMh6F9.js';
18
+ import './chunks/worker.d.DCy61tzi.js';
19
+ import './chunks/environment.d.CrsxCzP1.js';
18
20
  import '@vitest/pretty-format';
19
21
  import '@vitest/utils/diff';
20
22
  import '@vitest/expect';
@@ -1,19 +1,23 @@
1
- import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, a as ReportContext } from './chunks/reporters.d.C2PtoEFY.js';
1
+ import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, a as ReportContext } from './chunks/reporters.d.J2RlBlp9.js';
2
2
  import { TransformResult } from 'vite';
3
- import { A as AfterSuiteRunMeta } from './chunks/worker.d.Dxl5oW0C.js';
3
+ import { A as AfterSuiteRunMeta } from './chunks/rpc.d.RH3apGEf.js';
4
4
  import '@vitest/runner';
5
5
  import '@vitest/utils';
6
6
  import 'node:stream';
7
7
  import '@vitest/mocker';
8
8
  import '@vitest/utils/source-map';
9
9
  import 'vitest/browser';
10
- import './chunks/traces.d.Brik_NWu.js';
10
+ import './chunks/config.d.g6OOauRt.js';
11
11
  import '@vitest/pretty-format';
12
12
  import '@vitest/snapshot';
13
13
  import '@vitest/utils/diff';
14
- import './chunks/browser.d.Bq3zc1l_.js';
14
+ import './chunks/browser.d.CDvMh6F9.js';
15
+ import './chunks/worker.d.DCy61tzi.js';
16
+ import 'vite/module-runner';
17
+ import './chunks/environment.d.CrsxCzP1.js';
15
18
  import '@vitest/expect';
16
19
  import 'vitest/optional-types.js';
20
+ import './chunks/traces.d.402V_yFI.js';
17
21
  import './chunks/benchmark.d.DAaHLpsq.js';
18
22
  import '@vitest/runner/utils';
19
23
  import 'tinybench';
@@ -21,8 +25,6 @@ import './chunks/coverage.d.BZtK59WP.js';
21
25
  import '@vitest/snapshot/manager';
22
26
  import 'node:console';
23
27
  import 'node:fs';
24
- import 'vite/module-runner';
25
- import './chunks/environment.d.CrsxCzP1.js';
26
28
 
27
29
  type Threshold = "lines" | "functions" | "statements" | "branches";
28
30
  interface ResolvedThreshold {