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
@@ -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.F6jMf15V.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 WorkerExecuteContext, e as WorkerTestEnvironment } from './worker.d.DhEa3KzY.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';
@@ -1935,6 +1937,8 @@ type WorkerRequest = {
1935
1937
  __vitest_worker_request__: true;
1936
1938
  } & ({
1937
1939
  type: "start";
1940
+ poolId: number;
1941
+ workerId: WorkerExecuteContext["workerId"];
1938
1942
  options: {
1939
1943
  reportMemory: boolean;
1940
1944
  };
@@ -1954,12 +1958,10 @@ type WorkerRequest = {
1954
1958
  } | {
1955
1959
  type: "run";
1956
1960
  context: WorkerExecuteContext;
1957
- poolId: number;
1958
1961
  otelCarrier?: OTELCarrier;
1959
1962
  } | {
1960
1963
  type: "collect";
1961
1964
  context: WorkerExecuteContext;
1962
- poolId: number;
1963
1965
  otelCarrier?: OTELCarrier;
1964
1966
  } | {
1965
1967
  type: "cancel";
@@ -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.a5SCIJ0x.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, WorkerExecuteContext as d, WorkerTestEnvironment as e };
package/dist/cli.js CHANGED
@@ -1,10 +1,10 @@
1
- import { c as createCLI } from './chunks/cac.D9QaLeSz.js';
1
+ import { c as createCLI } from './chunks/cac.DnEx6DOX.js';
2
2
  import '@vitest/utils/helpers';
3
3
  import 'events';
4
4
  import 'pathe';
5
5
  import 'tinyrainbow';
6
6
  import './chunks/constants.D_Q9UYh-.js';
7
- import './chunks/index.DWDW6mLz.js';
7
+ import './chunks/index.D6PC4Dpu.js';
8
8
  import 'node:fs';
9
9
  import 'node:fs/promises';
10
10
  import 'node:perf_hooks';
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.DeFcIuza.js';
4
+ export { b as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.DeFcIuza.js';
5
+ import { V as VitestPluginContext } from './chunks/plugin.d.B6hlg3fN.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.F6jMf15V.js';
18
+ import './chunks/worker.d.DhEa3KzY.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.DeFcIuza.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.F6jMf15V.js';
15
+ import './chunks/worker.d.DhEa3KzY.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 {
@@ -1,3 +1,3 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './chunks/index.QWbK7rHY.js';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './chunks/index.BspFP3mn.js';
2
2
  import 'node:url';
3
3
  import 'node:console';
package/dist/index.d.ts CHANGED
@@ -1,19 +1,20 @@
1
- import { S as SerializedTestSpecification } from './chunks/browser.d.Bq3zc1l_.js';
2
- export { B as BrowserTesterOptions } from './chunks/browser.d.Bq3zc1l_.js';
3
- import './chunks/global.d.Dheepru6.js';
1
+ import { S as SerializedTestSpecification } from './chunks/browser.d.F6jMf15V.js';
2
+ export { B as BrowserTesterOptions } from './chunks/browser.d.F6jMf15V.js';
3
+ import './chunks/global.d.B15mdLcR.js';
4
4
  import { File, TestAnnotation, TestArtifact, TaskResultPack, TaskEventPack, Test, TaskPopulated } from '@vitest/runner';
5
5
  export { CancelReason, ImportDuration, OnTestFailedHandler, OnTestFinishedHandler, RunMode, Task as RunnerTask, TaskBase as RunnerTaskBase, TaskEventPack as RunnerTaskEventPack, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SuiteAPI, SuiteCollector, SuiteFactory, TaskCustomOptions, TaskMeta, TaskState, TestAPI, TestAnnotation, TestAnnotationArtifact, TestArtifact, TestArtifactBase, TestArtifactLocation, TestArtifactRegistry, TestAttachment, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, recordArtifact, suite, test } from '@vitest/runner';
6
6
  import { Awaitable } from '@vitest/utils';
7
7
  export { ParsedStack, SerializedError, TestError } from '@vitest/utils';
8
- import { U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, b as BirpcReturn, P as ProvidedContext } from './chunks/worker.d.Dxl5oW0C.js';
9
- export { A as AfterSuiteRunMeta, C as ContextRPC, d as ContextTestEnvironment, c as RunnerRPC, R as RuntimeRPC, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.Dxl5oW0C.js';
10
- import { S as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/traces.d.Brik_NWu.js';
11
- export { b as RuntimeConfig, a as SerializedCoverageConfig } from './chunks/traces.d.Brik_NWu.js';
8
+ import { b as BirpcReturn } from './chunks/worker.d.DhEa3KzY.js';
9
+ export { C as ContextRPC, c as ContextTestEnvironment, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.DhEa3KzY.js';
10
+ import { S as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.g6OOauRt.js';
11
+ export { b as RuntimeConfig, a as SerializedCoverageConfig } from './chunks/config.d.g6OOauRt.js';
12
+ import { U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, P as ProvidedContext } from './chunks/rpc.d.RH3apGEf.js';
13
+ export { A as AfterSuiteRunMeta, a as RunnerRPC, R as RuntimeRPC } from './chunks/rpc.d.RH3apGEf.js';
12
14
  import { ExpectStatic } from '@vitest/expect';
13
15
  export { Assertion, AsymmetricMatchersContaining, DeeplyAllowMatchers, ExpectPollOptions, ExpectStatic, JestAssertion, Matchers, chai } from '@vitest/expect';
14
16
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
15
17
  export { Mock, MockContext, MockInstance, MockResult, MockResultIncomplete, MockResultReturn, MockResultThrow, MockSettledResult, MockSettledResultFulfilled, MockSettledResultIncomplete, MockSettledResultRejected, Mocked, MockedClass, MockedFunction, MockedObject } from '@vitest/spy';
16
- import { M as MockFactoryWithHelper, a as MockOptions } from './chunks/mocker.d.BE_2ls6u.js';
17
18
  export { b as bench } from './chunks/suite.d.BJWk38HB.js';
18
19
  import { EvaluatedModules } from 'vite/module-runner';
19
20
  export { a as BenchFunction, b as Benchmark, c as BenchmarkAPI, B as BenchmarkResult } from './chunks/benchmark.d.DAaHLpsq.js';
@@ -23,7 +24,7 @@ export { DiffOptions } from '@vitest/utils/diff';
23
24
  export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
24
25
  import '@vitest/pretty-format';
25
26
  import './chunks/environment.d.CrsxCzP1.js';
26
- import '@vitest/mocker';
27
+ import './chunks/traces.d.402V_yFI.js';
27
28
  import '@vitest/runner/utils';
28
29
 
29
30
  interface SourceMap {
@@ -89,6 +90,12 @@ declare const should: () => Chai.Should;
89
90
  */
90
91
  declare function inject<T extends keyof ProvidedContext & string>(key: T): ProvidedContext[T];
91
92
 
93
+ type Promisable<T> = T | Promise<T>;
94
+ type MockFactoryWithHelper<M = unknown> = (importOriginal: <T extends M = M>() => Promise<T>) => Promisable<Partial<M>>;
95
+ interface MockOptions {
96
+ spy?: boolean;
97
+ }
98
+
92
99
  type WaitForCallback<T> = () => T | Promise<T>;
93
100
  interface WaitForOptions {
94
101
  /**
@@ -1,14 +1,119 @@
1
- import 'vite/module-runner';
2
- export { b as VitestModuleEvaluator, a as VitestModuleEvaluatorOptions, c as createImportMetaEnvProxy, g as getDefaultRequestStubs, i as isPrimitive, u as unwrapId, w as wrapId } from './chunks/moduleRunner.d.RBEiFdiW.js';
3
- import 'node:vm';
4
- import '@vitest/spy';
5
- import './chunks/worker.d.Dxl5oW0C.js';
1
+ import { ModuleEvaluator, ModuleRunnerImportMeta, ModuleRunnerContext, EvaluatedModuleNode } from 'vite/module-runner';
2
+ import vm from 'node:vm';
3
+ import { R as RuntimeRPC } from './chunks/rpc.d.RH3apGEf.js';
6
4
  import '@vitest/runner';
7
- import './chunks/traces.d.Brik_NWu.js';
8
- import '@vitest/pretty-format';
9
5
  import '@vitest/snapshot';
10
- import '@vitest/utils/diff';
11
- import './chunks/environment.d.CrsxCzP1.js';
12
- import '@vitest/utils';
13
- import '@vitest/mocker';
14
- import './chunks/mocker.d.BE_2ls6u.js';
6
+ import './chunks/traces.d.402V_yFI.js';
7
+
8
+ type ModuleExecutionInfo = Map<string, ModuleExecutionInfoEntry>;
9
+ interface ModuleExecutionInfoEntry {
10
+ startOffset: number;
11
+ /** The duration that was spent executing the module. */
12
+ duration: number;
13
+ /** The time that was spent executing the module itself and externalized imports. */
14
+ selfTime: number;
15
+ }
16
+
17
+ declare class FileMap {
18
+ private fsCache;
19
+ private fsBufferCache;
20
+ readFileAsync(path: string): Promise<string>;
21
+ readFile(path: string): string;
22
+ readBuffer(path: string): Buffer<ArrayBuffer>;
23
+ }
24
+
25
+ interface ModuleEvaluateOptions {
26
+ timeout?: vm.RunningScriptOptions["timeout"] | undefined;
27
+ breakOnSigint?: vm.RunningScriptOptions["breakOnSigint"] | undefined;
28
+ }
29
+ type ModuleLinker = (specifier: string, referencingModule: VMModule, extra: {
30
+ assert: object;
31
+ }) => VMModule | Promise<VMModule>;
32
+ type ModuleStatus = "unlinked" | "linking" | "linked" | "evaluating" | "evaluated" | "errored";
33
+ declare class VMModule {
34
+ dependencySpecifiers: readonly string[];
35
+ error: any;
36
+ identifier: string;
37
+ context: vm.Context;
38
+ namespace: object;
39
+ status: ModuleStatus;
40
+ evaluate(options?: ModuleEvaluateOptions): Promise<void>;
41
+ link(linker: ModuleLinker): Promise<void>;
42
+ }
43
+
44
+ interface ExternalModulesExecutorOptions {
45
+ context: vm.Context;
46
+ fileMap: FileMap;
47
+ packageCache: Map<string, any>;
48
+ transform: RuntimeRPC["transform"];
49
+ interopDefault?: boolean;
50
+ viteClientModule: Record<string, unknown>;
51
+ }
52
+ declare class ExternalModulesExecutor {
53
+ #private;
54
+ private options;
55
+ private cjs;
56
+ private esm;
57
+ private vite;
58
+ private context;
59
+ private fs;
60
+ private resolvers;
61
+ constructor(options: ExternalModulesExecutorOptions);
62
+ import(identifier: string): Promise<object>;
63
+ require(identifier: string): any;
64
+ createRequire(identifier: string): NodeJS.Require;
65
+ importModuleDynamically: (specifier: string, referencer: VMModule) => Promise<VMModule>;
66
+ resolveModule: (specifier: string, referencer: string) => Promise<VMModule>;
67
+ resolve(specifier: string, parent: string): string;
68
+ private getModuleInformation;
69
+ private createModule;
70
+ private get isNetworkSupported();
71
+ }
72
+
73
+ declare module "vite/module-runner" {
74
+ interface EvaluatedModuleNode {
75
+ /**
76
+ * @internal
77
+ */
78
+ mockedExports?: Record<string, any>;
79
+ }
80
+ }
81
+
82
+ interface VitestVmOptions {
83
+ context: vm.Context;
84
+ externalModulesExecutor: ExternalModulesExecutor;
85
+ }
86
+
87
+ interface VitestModuleEvaluatorOptions {
88
+ interopDefault?: boolean | undefined;
89
+ moduleExecutionInfo?: ModuleExecutionInfo;
90
+ getCurrentTestFilepath?: () => string | undefined;
91
+ compiledFunctionArgumentsNames?: string[];
92
+ compiledFunctionArgumentsValues?: unknown[];
93
+ }
94
+ declare class VitestModuleEvaluator implements ModuleEvaluator {
95
+ private options;
96
+ stubs: Record<string, any>;
97
+ env: ModuleRunnerImportMeta["env"];
98
+ private vm;
99
+ private compiledFunctionArgumentsNames?;
100
+ private compiledFunctionArgumentsValues;
101
+ private primitives;
102
+ private debug;
103
+ private _otel;
104
+ constructor(vmOptions?: VitestVmOptions | undefined, options?: VitestModuleEvaluatorOptions);
105
+ private convertIdToImportUrl;
106
+ runExternalModule(id: string): Promise<any>;
107
+ runInlinedModule(context: ModuleRunnerContext, code: string, module: Readonly<EvaluatedModuleNode>): Promise<any>;
108
+ private _runInlinedModule;
109
+ private createRequire;
110
+ private shouldInterop;
111
+ }
112
+ declare function createImportMetaEnvProxy(): ModuleRunnerImportMeta["env"];
113
+ declare function getDefaultRequestStubs(context?: vm.Context): Record<string, any>;
114
+ declare function isPrimitive(v: any): boolean;
115
+ declare function wrapId(id: string): string;
116
+ declare function unwrapId(id: string): string;
117
+
118
+ export { VitestModuleEvaluator, createImportMetaEnvProxy, getDefaultRequestStubs, isPrimitive, unwrapId, wrapId };
119
+ export type { VitestModuleEvaluatorOptions };
@@ -67,7 +67,10 @@ class VitestModuleEvaluator {
67
67
  async runExternalModule(id) {
68
68
  if (id in this.stubs) return this.stubs[id];
69
69
  const file = this.convertIdToImportUrl(id);
70
- const namespace = await this._otel.$("vitest.module.external", { attributes: { "code.file.path": file } }, () => this.vm ? this.vm.externalModulesExecutor.import(file) : import(file));
70
+ const finishModuleExecutionInfo = this.debug.startCalculateModuleExecutionInfo(file, 0);
71
+ const namespace = await this._otel.$("vitest.module.external", { attributes: { "code.file.path": file } }, () => this.vm ? this.vm.externalModulesExecutor.import(file) : import(file)).finally(() => {
72
+ finishModuleExecutionInfo();
73
+ });
71
74
  if (!this.shouldInterop(file, namespace)) return namespace;
72
75
  const { mod, defaultExport } = interopModule(namespace);
73
76
  const { Proxy, Reflect } = this.primitives;
@@ -1,5 +1,5 @@
1
1
  export { VitestModuleEvaluator } from './module-evaluator.js';
2
- export { a as VITEST_VM_CONTEXT_SYMBOL, V as VitestModuleRunner, s as startVitestModuleRunner } from './chunks/startModuleRunner.BEYtrq5Y.js';
2
+ export { a as VITEST_VM_CONTEXT_SYMBOL, V as VitestModuleRunner, s as startVitestModuleRunner } from './chunks/startModuleRunner.W28wBIgJ.js';
3
3
  export { g as getWorkerState } from './chunks/utils.DvEY5TfP.js';
4
4
  import 'node:module';
5
5
  import 'node:url';
package/dist/node.d.ts CHANGED
@@ -3,28 +3,30 @@ import { InlineConfig, UserConfig as UserConfig$1, Plugin, ResolvedConfig as Res
3
3
  export { vite as Vite };
4
4
  export { esbuildVersion, isCSSRequest, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
5
5
  import { IncomingMessage } from 'node:http';
6
- import { h as ResolvedConfig, f as UserConfig, i as VitestRunMode, j as VitestOptions, V as Vitest, A as ApiConfig, k as TestSpecification, T as TestProject, P as PoolWorker, l as PoolOptions, m as WorkerRequest, n as TestSequencer, L as Logger } from './chunks/reporters.d.C2PtoEFY.js';
7
- export { at as BaseCoverageOptions, Y as BenchmarkUserOptions, Z as BrowserBuiltinProvider, $ as BrowserCommand, a0 as BrowserCommandContext, a1 as BrowserConfigOptions, a2 as BrowserInstanceOption, a3 as BrowserModuleMocker, a4 as BrowserOrchestrator, a5 as BrowserProvider, a6 as BrowserProviderOption, a7 as BrowserScript, a8 as BrowserServerFactory, a9 as BrowserServerOptions, aa as BrowserServerState, ab as BrowserServerStateSession, ai as BuiltinEnvironment, ac as CDPSession, aj as CSSModuleScopeStrategy, au as CoverageIstanbulOptions, av as CoverageOptions, aw as CoverageProvider, ax as CoverageProviderModule, ay as CoverageReporter, c as CoverageV8Options, az as CustomProviderOptions, ak as DepsOptimizationOptions, al as EnvironmentOptions, H as HTMLOptions, I as InlineConfig, t as JUnitOptions, J as JsonOptions, M as ModuleDiagnostic, O as OnServerRestartHandler, o as OnTestsRerunHandler, ad as ParentProjectBrowser, am as Pool, q as PoolRunnerInitializer, r as PoolTask, ae as ProjectBrowser, an as ProjectConfig, a as ReportContext, aB as ReportedHookContext, aC as Reporter, ap as ResolveSnapshotPathHandler, aq as ResolveSnapshotPathHandlerContext, af as ResolvedBrowserOptions, R as ResolvedCoverageOptions, ao as ResolvedProjectConfig, S as SerializedTestProject, u as TaskOptions, v as TestCase, w as TestCollection, x as TestDiagnostic, y as TestModule, z as TestModuleState, B as TestResult, D as TestResultFailed, E as TestResultPassed, F as TestResultSkipped, aD as TestRunEndReason, aA as TestRunResult, X as TestSequencerConstructor, G as TestState, K as TestSuite, N as TestSuiteState, ag as ToMatchScreenshotComparators, ah as ToMatchScreenshotOptions, ar as TypecheckConfig, U as UserWorkspaceConfig, as as VitestEnvironment, p as VitestPackageInstaller, W as WatcherTriggerPattern, s as WorkerResponse, _ as _BrowserNames, Q as experimental_getRunnerTask } from './chunks/reporters.d.C2PtoEFY.js';
8
- export { C as CacheKeyIdGenerator, a as CacheKeyIdGeneratorContext, V as VitestPluginContext } from './chunks/plugin.d.DGpEw-QV.js';
6
+ import { h as ResolvedConfig, f as UserConfig, i as VitestRunMode, j as VitestOptions, V as Vitest, A as ApiConfig, k as TestSpecification, T as TestProject, P as PoolWorker, l as PoolOptions, m as WorkerRequest, n as TestSequencer, L as Logger } from './chunks/reporters.d.DeFcIuza.js';
7
+ export { at as BaseCoverageOptions, Y as BenchmarkUserOptions, Z as BrowserBuiltinProvider, $ as BrowserCommand, a0 as BrowserCommandContext, a1 as BrowserConfigOptions, a2 as BrowserInstanceOption, a3 as BrowserModuleMocker, a4 as BrowserOrchestrator, a5 as BrowserProvider, a6 as BrowserProviderOption, a7 as BrowserScript, a8 as BrowserServerFactory, a9 as BrowserServerOptions, aa as BrowserServerState, ab as BrowserServerStateSession, ai as BuiltinEnvironment, ac as CDPSession, aj as CSSModuleScopeStrategy, au as CoverageIstanbulOptions, av as CoverageOptions, aw as CoverageProvider, ax as CoverageProviderModule, ay as CoverageReporter, c as CoverageV8Options, az as CustomProviderOptions, ak as DepsOptimizationOptions, al as EnvironmentOptions, H as HTMLOptions, I as InlineConfig, t as JUnitOptions, J as JsonOptions, M as ModuleDiagnostic, O as OnServerRestartHandler, o as OnTestsRerunHandler, ad as ParentProjectBrowser, am as Pool, q as PoolRunnerInitializer, r as PoolTask, ae as ProjectBrowser, an as ProjectConfig, a as ReportContext, aB as ReportedHookContext, aC as Reporter, ap as ResolveSnapshotPathHandler, aq as ResolveSnapshotPathHandlerContext, af as ResolvedBrowserOptions, R as ResolvedCoverageOptions, ao as ResolvedProjectConfig, S as SerializedTestProject, u as TaskOptions, v as TestCase, w as TestCollection, x as TestDiagnostic, y as TestModule, z as TestModuleState, B as TestResult, D as TestResultFailed, E as TestResultPassed, F as TestResultSkipped, aD as TestRunEndReason, aA as TestRunResult, X as TestSequencerConstructor, G as TestState, K as TestSuite, N as TestSuiteState, ag as ToMatchScreenshotComparators, ah as ToMatchScreenshotOptions, ar as TypecheckConfig, U as UserWorkspaceConfig, as as VitestEnvironment, p as VitestPackageInstaller, W as WatcherTriggerPattern, s as WorkerResponse, _ as _BrowserNames, Q as experimental_getRunnerTask } from './chunks/reporters.d.DeFcIuza.js';
8
+ export { C as CacheKeyIdGenerator, a as CacheKeyIdGeneratorContext, V as VitestPluginContext } from './chunks/plugin.d.B6hlg3fN.js';
9
9
  import { Awaitable } from '@vitest/utils';
10
10
  export { SerializedError } from '@vitest/utils';
11
- import { R as RuntimeRPC, C as ContextRPC } from './chunks/worker.d.Dxl5oW0C.js';
12
- export { T as TestExecutionType } from './chunks/worker.d.Dxl5oW0C.js';
11
+ import { R as RuntimeRPC } from './chunks/rpc.d.RH3apGEf.js';
13
12
  import { Writable } from 'node:stream';
14
- import { Debugger } from 'debug';
15
- import './chunks/global.d.Dheepru6.js';
13
+ import { C as ContextRPC } from './chunks/worker.d.DhEa3KzY.js';
14
+ export { T as TestExecutionType } from './chunks/worker.d.DhEa3KzY.js';
15
+ import { Debugger } from 'obug';
16
+ import './chunks/global.d.B15mdLcR.js';
16
17
  export { Task as RunnerTask, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
17
- export { b as RuntimeConfig } from './chunks/traces.d.Brik_NWu.js';
18
+ export { b as RuntimeConfig } from './chunks/config.d.g6OOauRt.js';
18
19
  export { generateFileHash } from '@vitest/runner/utils';
19
20
  import '@vitest/mocker';
20
21
  import '@vitest/utils/source-map';
21
22
  import 'vitest/browser';
22
- import './chunks/browser.d.Bq3zc1l_.js';
23
+ import './chunks/browser.d.F6jMf15V.js';
23
24
  import '@vitest/pretty-format';
24
25
  import '@vitest/snapshot';
25
26
  import '@vitest/utils/diff';
26
27
  import '@vitest/expect';
27
28
  import 'vitest/optional-types.js';
29
+ import './chunks/traces.d.402V_yFI.js';
28
30
  import './chunks/benchmark.d.DAaHLpsq.js';
29
31
  import 'tinybench';
30
32
  import './chunks/coverage.d.BZtK59WP.js';
package/dist/node.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as vite from 'vite';
2
2
  import { resolveConfig as resolveConfig$1, mergeConfig } from 'vite';
3
3
  export { esbuildVersion, isCSSRequest, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
4
- import { V as Vitest, a as VitestPlugin } from './chunks/cli-api.BJh-POxZ.js';
5
- export { f as ForksPoolWorker, G as GitNotFoundError, F as TestsNotFoundError, T as ThreadsPoolWorker, h as TypecheckPoolWorker, b as VitestPackageInstaller, j as VmForksPoolWorker, k as VmThreadsPoolWorker, o as createDebugger, d as createMethodsRPC, n as createViteLogger, c as createVitest, e as escapeTestName, l as experimental_getRunnerTask, g as getFilePoolName, i as isValidApiRequest, m as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.BJh-POxZ.js';
6
- export { p as parseCLI } from './chunks/cac.D9QaLeSz.js';
4
+ import { V as Vitest, a as VitestPlugin } from './chunks/cli-api.CbjxIXjQ.js';
5
+ export { f as ForksPoolWorker, G as GitNotFoundError, F as TestsNotFoundError, T as ThreadsPoolWorker, h as TypecheckPoolWorker, b as VitestPackageInstaller, j as VmForksPoolWorker, k as VmThreadsPoolWorker, o as createDebugger, d as createMethodsRPC, n as createViteLogger, c as createVitest, e as escapeTestName, l as experimental_getRunnerTask, g as getFilePoolName, i as isValidApiRequest, m as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.CbjxIXjQ.js';
6
+ export { p as parseCLI } from './chunks/cac.DnEx6DOX.js';
7
7
  import { r as resolveConfig$2 } from './chunks/coverage.CtyeYmKM.js';
8
8
  export { b as BaseSequencer, a as resolveApiServerConfig } from './chunks/coverage.CtyeYmKM.js';
9
9
  import { slash, deepClone } from '@vitest/utils/helpers';
@@ -19,7 +19,7 @@ import 'node:os';
19
19
  import '@vitest/snapshot/manager';
20
20
  import 'node:perf_hooks';
21
21
  import './chunks/index.0kCJoeWi.js';
22
- import './chunks/index.DWDW6mLz.js';
22
+ import './chunks/index.D6PC4Dpu.js';
23
23
  import 'node:fs/promises';
24
24
  import '@vitest/utils/source-map';
25
25
  import 'tinyrainbow';
@@ -45,7 +45,7 @@ import 'buffer';
45
45
  import './chunks/_commonjsHelpers.D26ty3Ew.js';
46
46
  import 'node:crypto';
47
47
  import './chunks/traces.U4xDYhzZ.js';
48
- import 'debug';
48
+ import 'obug';
49
49
  import '#module-evaluator';
50
50
  import 'vite/module-runner';
51
51
  import '@vitest/utils/highlight';
@@ -62,7 +62,7 @@ import './chunks/defaults.BOqNVLsY.js';
62
62
  import '@vitest/utils/constants';
63
63
  import '@vitest/utils/resolver';
64
64
  import 'es-module-lexer';
65
- import './chunks/index.CMvpbrsJ.js';
65
+ import './chunks/index.B88tjlE5.js';
66
66
  import 'node:assert';
67
67
  import '@vitest/utils/serialize';
68
68
  import 'node:readline';