vitest 4.0.14 → 4.0.16

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 (54) hide show
  1. package/dist/browser.d.ts +2 -2
  2. package/dist/browser.js +2 -2
  3. package/dist/chunks/{base.BEv8sRbK.js → base.Bin-9uYm.js} +7 -6
  4. package/dist/chunks/browser.d.Bz3lxTX-.d.ts +57 -0
  5. package/dist/chunks/{cac.DnEx6DOX.js → cac.BGonGPac.js} +10 -25
  6. package/dist/chunks/{cli-api.CbjxIXjQ.js → cli-api.BKg19Fvw.js} +469 -124
  7. package/dist/chunks/{config.d.g6OOauRt.d.ts → config.d.CzIjkicf.d.ts} +1 -0
  8. package/dist/chunks/{coverage.CtyeYmKM.js → coverage.BuJUwVtg.js} +2 -1
  9. package/dist/chunks/evaluatedModules.d.BxJ5omdx.d.ts +7 -0
  10. package/dist/chunks/{globals.C0izxiX3.js → globals.DOayXfHP.js} +3 -3
  11. package/dist/chunks/{index.D6PC4Dpu.js → index.456_DGfR.js} +128 -18
  12. package/dist/chunks/{index.CQwQ_SLL.js → index.6Qv1eEA6.js} +3 -3
  13. package/dist/chunks/index.Chj8NDwU.js +206 -0
  14. package/dist/chunks/{index.B88tjlE5.js → index.Drsj_6e7.js} +1 -1
  15. package/dist/chunks/{index.DBx1AtPJ.js → index.Z5E_ObnR.js} +1 -1
  16. package/dist/chunks/{init-forks.DmvIFK4U.js → init-forks.v9UONQS6.js} +11 -2
  17. package/dist/chunks/{init-threads.De6b3S3g.js → init-threads.DqYg3Trk.js} +1 -1
  18. package/dist/chunks/{init.a5SCIJ0x.js → init.KmQZdqFg.js} +2 -2
  19. package/dist/chunks/modules.BJuCwlRJ.js +36 -0
  20. package/dist/chunks/{plugin.d.B6hlg3fN.d.ts → plugin.d.v1sC_bv1.d.ts} +1 -1
  21. package/dist/chunks/{reporters.d.DeFcIuza.d.ts → reporters.d.Rsi0PyxX.d.ts} +27 -4
  22. package/dist/chunks/{rpc.BytlcPfC.js → rpc.BoxB0q7B.js} +1 -1
  23. package/dist/chunks/{setup-common.DGHc_BUK.js → setup-common.Cm-kSBVi.js} +1 -1
  24. package/dist/chunks/{startModuleRunner.W28wBIgJ.js → startModuleRunner.DpqpB8k3.js} +8 -9
  25. package/dist/chunks/{test.DqQZzsWf.js → test.B8ej_ZHS.js} +9 -4
  26. package/dist/chunks/{vi.BiaV1qII.js → vi.2VT5v0um.js} +40 -30
  27. package/dist/chunks/{vm.BbVD4fJ5.js → vm.qFl6P1nF.js} +2 -2
  28. package/dist/chunks/worker.d.5JNaocaN.d.ts +254 -0
  29. package/dist/cli.js +2 -2
  30. package/dist/config.d.ts +7 -7
  31. package/dist/coverage.d.ts +8 -8
  32. package/dist/coverage.js +1 -1
  33. package/dist/index.d.ts +22 -14
  34. package/dist/index.js +3 -3
  35. package/dist/module-evaluator.d.ts +5 -0
  36. package/dist/module-evaluator.js +23 -16
  37. package/dist/module-runner.js +2 -1
  38. package/dist/node.d.ts +17 -10
  39. package/dist/node.js +10 -9
  40. package/dist/reporters.d.ts +7 -7
  41. package/dist/reporters.js +2 -2
  42. package/dist/runners.d.ts +2 -1
  43. package/dist/runners.js +4 -4
  44. package/dist/worker.d.ts +5 -3
  45. package/dist/worker.js +11 -10
  46. package/dist/workers/forks.js +12 -11
  47. package/dist/workers/runVmTests.js +7 -7
  48. package/dist/workers/threads.js +12 -11
  49. package/dist/workers/vmForks.js +7 -6
  50. package/dist/workers/vmThreads.js +7 -6
  51. package/package.json +15 -15
  52. package/dist/chunks/browser.d.F6jMf15V.d.ts +0 -18
  53. package/dist/chunks/index.0kCJoeWi.js +0 -220
  54. package/dist/chunks/worker.d.DhEa3KzY.d.ts +0 -238
@@ -1,6 +1,6 @@
1
1
  import fs from 'node:fs';
2
- import nodeModule, { isBuiltin } from 'node:module';
3
2
  import { isBareImport } from '@vitest/utils/helpers';
3
+ import { i as isBuiltin, a as isBrowserExternal, t as toBuiltin } from './modules.BJuCwlRJ.js';
4
4
  import { pathToFileURL } from 'node:url';
5
5
  import { normalize as normalize$1, join as join$1 } from 'pathe';
6
6
  import { distDir } from '../path.js';
@@ -9,6 +9,7 @@ import { VitestModuleEvaluator, unwrapId } from '../module-evaluator.js';
9
9
  import { resolve as resolve$1, isAbsolute as isAbsolute$1 } from 'node:path';
10
10
  import vm from 'node:vm';
11
11
  import { MockerRegistry, mockObject, RedirectedModule, AutomockedModule } from '@vitest/mocker';
12
+ import nodeModule from 'node:module';
12
13
  import * as viteModuleRunner from 'vite/module-runner';
13
14
  import { T as Traces } from './traces.U4xDYhzZ.js';
14
15
 
@@ -754,8 +755,6 @@ function listenForErrors(state) {
754
755
  }
755
756
 
756
757
  const { readFileSync } = fs;
757
- const browserExternalId = "__vite-browser-external";
758
- const browserExternalLength = 24;
759
758
  const VITEST_VM_CONTEXT_SYMBOL = "__vitest_vm_context__";
760
759
  const cwd = process.cwd();
761
760
  const isWindows = process.platform === "win32";
@@ -777,6 +776,7 @@ function startVitestModuleRunner(options) {
777
776
  } : void 0;
778
777
  const evaluator = options.evaluator || new VitestModuleEvaluator(vm, {
779
778
  traces,
779
+ evaluatedModules: options.evaluatedModules,
780
780
  get moduleExecutionInfo() {
781
781
  return state().moduleExecutionInfo;
782
782
  },
@@ -817,7 +817,11 @@ function startVitestModuleRunner(options) {
817
817
  invalidate: false,
818
818
  mockedModule: resolvedMock
819
819
  };
820
- if (isBuiltin(rawId) || rawId.startsWith(browserExternalId)) return {
820
+ if (isBuiltin(rawId)) return {
821
+ externalize: rawId,
822
+ type: "builtin"
823
+ };
824
+ if (isBrowserExternal(rawId)) return {
821
825
  externalize: toBuiltin(rawId),
822
826
  type: "builtin"
823
827
  };
@@ -853,10 +857,5 @@ function startVitestModuleRunner(options) {
853
857
  });
854
858
  return moduleRunner;
855
859
  }
856
- function toBuiltin(id) {
857
- if (id.startsWith(browserExternalId)) id = id.slice(browserExternalLength);
858
- if (!id.startsWith("node:")) id = `node:${id}`;
859
- return id;
860
- }
861
860
 
862
861
  export { VitestModuleRunner as V, VITEST_VM_CONTEXT_SYMBOL as a, VitestTransport as b, createNodeImportMeta as c, startVitestModuleRunner as s };
@@ -7,8 +7,8 @@ import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
7
7
  import { getTests, getNames, getTestName } from '@vitest/runner/utils';
8
8
  import { processError } from '@vitest/utils/error';
9
9
  import { normalize } from 'pathe';
10
- import { a as getSnapshotClient, i as inject, c as createExpect, v as vi } from './vi.BiaV1qII.js';
11
- import { r as rpc } from './rpc.BytlcPfC.js';
10
+ import { a as getSnapshotClient, i as inject, c as createExpect, v as vi } from './vi.2VT5v0um.js';
11
+ import { r as rpc } from './rpc.BoxB0q7B.js';
12
12
 
13
13
  function createBenchmarkResult(name) {
14
14
  return {
@@ -122,8 +122,11 @@ class VitestTestRunner {
122
122
  assertionsErrors = /* @__PURE__ */ new WeakMap();
123
123
  pool = this.workerState.ctx.pool;
124
124
  _otel;
125
+ viteEnvironment;
125
126
  constructor(config) {
126
127
  this.config = config;
128
+ const environment = this.workerState.environment;
129
+ this.viteEnvironment = environment.viteEnvironment || environment.name;
127
130
  }
128
131
  importFile(filepath, source) {
129
132
  if (source === "setup") {
@@ -223,9 +226,11 @@ class VitestTestRunner {
223
226
  getImportDurations() {
224
227
  const importDurations = {};
225
228
  const entries = this.workerState.moduleExecutionInfo?.entries() || [];
226
- for (const [filepath, { duration, selfTime }] of entries) importDurations[normalize(filepath)] = {
229
+ for (const [filepath, { duration, selfTime, external, importer }] of entries) importDurations[normalize(filepath)] = {
227
230
  selfTime,
228
- totalTime: duration
231
+ totalTime: duration,
232
+ external,
233
+ importer
229
234
  };
230
235
  return importDurations;
231
236
  }
@@ -1,8 +1,8 @@
1
1
  import { chai, equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters, customMatchers } from '@vitest/expect';
2
2
  import { getCurrentTest } from '@vitest/runner';
3
- import { getNames, getTestName } from '@vitest/runner/utils';
4
3
  import { g as getWorkerState, i as isChildProcess, w as waitForImportsToResolve, r as resetModules } from './utils.DvEY5TfP.js';
5
- import { getSafeTimers } from '@vitest/utils/timers';
4
+ import { getSafeTimers, delay } from '@vitest/utils/timers';
5
+ import { getNames } from '@vitest/runner/utils';
6
6
  import { stripSnapshotIndentation, addSerializer, SnapshotClient } from '@vitest/snapshot';
7
7
  import '@vitest/utils/error';
8
8
  import { assertTypes, createSimpleStackTrace } from '@vitest/utils/helpers';
@@ -25,6 +25,18 @@ const unsupported = [
25
25
  "toThrow",
26
26
  "toThrowError"
27
27
  ];
28
+ /**
29
+ * Attaches a `cause` property to the error if missing, copies the stack trace from the source, and throws.
30
+ *
31
+ * @param error - The error to throw
32
+ * @param source - Error to copy the stack trace from
33
+ *
34
+ * @throws Always throws the provided error with an amended stack trace
35
+ */
36
+ function throwWithCause(error, source) {
37
+ if (error.cause == null) error.cause = /* @__PURE__ */ new Error("Matcher did not succeed in time.");
38
+ throw copyStackTrace$1(error, source);
39
+ }
28
40
  function createExpectPoll(expect) {
29
41
  return function poll(fn, options = {}) {
30
42
  const defaults = getWorkerState().config.expect?.poll ?? {};
@@ -41,35 +53,33 @@ function createExpectPoll(expect) {
41
53
  if (typeof key === "string" && unsupported.includes(key)) throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
42
54
  return function(...args) {
43
55
  const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
44
- const promise = () => new Promise((resolve, reject) => {
45
- let intervalId;
46
- let timeoutId;
47
- let lastError;
56
+ const promise = async () => {
48
57
  const { setTimeout, clearTimeout } = getSafeTimers();
49
- const check = async () => {
50
- try {
51
- chai.util.flag(assertion, "_name", key);
52
- const obj = await fn();
53
- chai.util.flag(assertion, "object", obj);
54
- resolve(await assertionFunction.call(assertion, ...args));
55
- clearTimeout(intervalId);
56
- clearTimeout(timeoutId);
57
- } catch (err) {
58
- lastError = err;
59
- if (!chai.util.flag(assertion, "_isLastPollAttempt")) intervalId = setTimeout(check, interval);
60
- }
61
- };
62
- timeoutId = setTimeout(() => {
63
- clearTimeout(intervalId);
64
- chai.util.flag(assertion, "_isLastPollAttempt", true);
65
- const rejectWithCause = (error) => {
66
- if (error.cause == null) error.cause = /* @__PURE__ */ new Error("Matcher did not succeed in time.");
67
- reject(copyStackTrace$1(error, STACK_TRACE_ERROR));
68
- };
69
- check().then(() => rejectWithCause(lastError)).catch((e) => rejectWithCause(e));
58
+ let executionPhase = "fn";
59
+ let hasTimedOut = false;
60
+ const timerId = setTimeout(() => {
61
+ hasTimedOut = true;
70
62
  }, timeout);
71
- check();
72
- });
63
+ chai.util.flag(assertion, "_name", key);
64
+ try {
65
+ while (true) {
66
+ const isLastAttempt = hasTimedOut;
67
+ if (isLastAttempt) chai.util.flag(assertion, "_isLastPollAttempt", true);
68
+ try {
69
+ executionPhase = "fn";
70
+ const obj = await fn();
71
+ chai.util.flag(assertion, "object", obj);
72
+ executionPhase = "assertion";
73
+ return await assertionFunction.call(assertion, ...args);
74
+ } catch (err) {
75
+ if (isLastAttempt || executionPhase === "assertion" && chai.util.flag(assertion, "_poll.assert_once")) throwWithCause(err, STACK_TRACE_ERROR);
76
+ await delay(interval, setTimeout);
77
+ }
78
+ }
79
+ } finally {
80
+ clearTimeout(timerId);
81
+ }
82
+ };
73
83
  let awaited = false;
74
84
  test.onFinished ??= [];
75
85
  test.onFinished.push(() => {
@@ -315,7 +325,7 @@ function createExpect(test) {
315
325
  get testPath() {
316
326
  return getWorkerState().filepath;
317
327
  },
318
- currentTestName: test ? getTestName(test) : globalState.currentTestName
328
+ currentTestName: test ? test.fullTestName ?? "" : globalState.currentTestName
319
329
  }, expect);
320
330
  expect.assert = chai.assert;
321
331
  // @ts-expect-error untyped
@@ -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.a5SCIJ0x.js';
4
+ import { l as loadEnvironment } from './init.KmQZdqFg.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.W28wBIgJ.js';
14
+ import { s as startVitestModuleRunner, c as createNodeImportMeta, a as VITEST_VM_CONTEXT_SYMBOL } from './startModuleRunner.DpqpB8k3.js';
15
15
  import { p as provideWorkerState } from './utils.DvEY5TfP.js';
16
16
 
17
17
  function interopCommonJsModule(interopDefault, mod) {
@@ -0,0 +1,254 @@
1
+ import { FileSpecification, Task, CancelReason } from '@vitest/runner';
2
+ import { EvaluatedModules } from 'vite/module-runner';
3
+ import { S as SerializedConfig } from './config.d.CzIjkicf.js';
4
+ import { E as Environment } from './environment.d.CrsxCzP1.js';
5
+ import { R as RuntimeRPC, a as RunnerRPC } from './rpc.d.RH3apGEf.js';
6
+
7
+ //#region src/messages.d.ts
8
+ declare const TYPE_REQUEST: "q";
9
+ interface RpcRequest {
10
+ /**
11
+ * Type
12
+ */
13
+ t: typeof TYPE_REQUEST;
14
+ /**
15
+ * ID
16
+ */
17
+ i?: string;
18
+ /**
19
+ * Method
20
+ */
21
+ m: string;
22
+ /**
23
+ * Arguments
24
+ */
25
+ a: any[];
26
+ /**
27
+ * Optional
28
+ */
29
+ o?: boolean;
30
+ }
31
+ //#endregion
32
+ //#region src/utils.d.ts
33
+ type ArgumentsType<T> = T extends ((...args: infer A) => any) ? A : never;
34
+ type ReturnType<T> = T extends ((...args: any) => infer R) ? R : never;
35
+ type Thenable<T> = T | PromiseLike<T>;
36
+ //#endregion
37
+ //#region src/main.d.ts
38
+ type PromisifyFn<T> = ReturnType<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
39
+ type BirpcResolver<This> = (this: This, name: string, resolved: (...args: unknown[]) => unknown) => Thenable<((...args: any[]) => any) | undefined>;
40
+ interface ChannelOptions {
41
+ /**
42
+ * Function to post raw message
43
+ */
44
+ post: (data: any, ...extras: any[]) => Thenable<any>;
45
+ /**
46
+ * Listener to receive raw message
47
+ */
48
+ on: (fn: (data: any, ...extras: any[]) => void) => Thenable<any>;
49
+ /**
50
+ * Clear the listener when `$close` is called
51
+ */
52
+ off?: (fn: (data: any, ...extras: any[]) => void) => Thenable<any>;
53
+ /**
54
+ * Custom function to serialize data
55
+ *
56
+ * by default it passes the data as-is
57
+ */
58
+ serialize?: (data: any) => any;
59
+ /**
60
+ * Custom function to deserialize data
61
+ *
62
+ * by default it passes the data as-is
63
+ */
64
+ deserialize?: (data: any) => any;
65
+ /**
66
+ * Call the methods with the RPC context or the original functions object
67
+ */
68
+ bind?: 'rpc' | 'functions';
69
+ /**
70
+ * Custom meta data to attached to the RPC instance's `$meta` property
71
+ */
72
+ meta?: any;
73
+ }
74
+ interface EventOptions<RemoteFunctions extends object = Record<string, unknown>, LocalFunctions extends object = Record<string, unknown>, Proxify extends boolean = true> {
75
+ /**
76
+ * Names of remote functions that do not need response.
77
+ */
78
+ eventNames?: (keyof RemoteFunctions)[];
79
+ /**
80
+ * Maximum timeout for waiting for response, in milliseconds.
81
+ *
82
+ * @default 60_000
83
+ */
84
+ timeout?: number;
85
+ /**
86
+ * Whether to proxy the remote functions.
87
+ *
88
+ * When `proxify` is false, calling the remote function
89
+ * with `rpc.$call('method', ...args)` instead of `rpc.method(...args)`
90
+ * explicitly is required.
91
+ *
92
+ * @default true
93
+ */
94
+ proxify?: Proxify;
95
+ /**
96
+ * Custom resolver to resolve function to be called
97
+ *
98
+ * For advanced use cases only
99
+ */
100
+ resolver?: BirpcResolver<BirpcReturn<RemoteFunctions, LocalFunctions, Proxify>>;
101
+ /**
102
+ * Hook triggered before an event is sent to the remote
103
+ *
104
+ * @param req - Request parameters
105
+ * @param next - Function to continue the request
106
+ * @param resolve - Function to resolve the response directly
107
+ */
108
+ onRequest?: (this: BirpcReturn<RemoteFunctions, LocalFunctions, Proxify>, req: RpcRequest, next: (req?: RpcRequest) => Promise<any>, resolve: (res: any) => void) => void | Promise<void>;
109
+ /**
110
+ * Custom error handler for errors occurred in local functions being called
111
+ *
112
+ * @returns `true` to prevent the error from being thrown
113
+ */
114
+ onFunctionError?: (this: BirpcReturn<RemoteFunctions, LocalFunctions, Proxify>, error: Error, functionName: string, args: any[]) => boolean | void;
115
+ /**
116
+ * Custom error handler for errors occurred during serialization or messsaging
117
+ *
118
+ * @returns `true` to prevent the error from being thrown
119
+ */
120
+ onGeneralError?: (this: BirpcReturn<RemoteFunctions, LocalFunctions, Proxify>, error: Error, functionName?: string, args?: any[]) => boolean | void;
121
+ /**
122
+ * Custom error handler for timeouts
123
+ *
124
+ * @returns `true` to prevent the error from being thrown
125
+ */
126
+ onTimeoutError?: (this: BirpcReturn<RemoteFunctions, LocalFunctions, Proxify>, functionName: string, args: any[]) => boolean | void;
127
+ }
128
+ type BirpcOptions<RemoteFunctions extends object = Record<string, unknown>, LocalFunctions extends object = Record<string, unknown>, Proxify extends boolean = true> = EventOptions<RemoteFunctions, LocalFunctions, Proxify> & ChannelOptions;
129
+ type BirpcFn<T> = PromisifyFn<T> & {
130
+ /**
131
+ * Send event without asking for response
132
+ */
133
+ asEvent: (...args: ArgumentsType<T>) => Promise<void>;
134
+ };
135
+ interface BirpcReturnBuiltin<RemoteFunctions, LocalFunctions = Record<string, unknown>> {
136
+ /**
137
+ * Raw functions object
138
+ */
139
+ $functions: LocalFunctions;
140
+ /**
141
+ * Whether the RPC is closed
142
+ */
143
+ readonly $closed: boolean;
144
+ /**
145
+ * Custom meta data attached to the RPC instance
146
+ */
147
+ readonly $meta: any;
148
+ /**
149
+ * Close the RPC connection
150
+ */
151
+ $close: (error?: Error) => void;
152
+ /**
153
+ * Reject pending calls
154
+ */
155
+ $rejectPendingCalls: (handler?: PendingCallHandler) => Promise<void>[];
156
+ /**
157
+ * Call the remote function and wait for the result.
158
+ * An alternative to directly calling the function
159
+ */
160
+ $call: <K$1 extends keyof RemoteFunctions>(method: K$1, ...args: ArgumentsType<RemoteFunctions[K$1]>) => Promise<Awaited<ReturnType<RemoteFunctions[K$1]>>>;
161
+ /**
162
+ * Same as `$call`, but returns `undefined` if the function is not defined on the remote side.
163
+ */
164
+ $callOptional: <K$1 extends keyof RemoteFunctions>(method: K$1, ...args: ArgumentsType<RemoteFunctions[K$1]>) => Promise<Awaited<ReturnType<RemoteFunctions[K$1]> | undefined>>;
165
+ /**
166
+ * Send event without asking for response
167
+ */
168
+ $callEvent: <K$1 extends keyof RemoteFunctions>(method: K$1, ...args: ArgumentsType<RemoteFunctions[K$1]>) => Promise<void>;
169
+ /**
170
+ * Call the remote function with the raw options.
171
+ */
172
+ $callRaw: (options: {
173
+ method: string;
174
+ args: unknown[];
175
+ event?: boolean;
176
+ optional?: boolean;
177
+ }) => Promise<Awaited<ReturnType<any>>[]>;
178
+ }
179
+ type ProxifiedRemoteFunctions<RemoteFunctions extends object = Record<string, unknown>> = { [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]> };
180
+ type BirpcReturn<RemoteFunctions extends object = Record<string, unknown>, LocalFunctions extends object = Record<string, unknown>, Proxify extends boolean = true> = Proxify extends true ? ProxifiedRemoteFunctions<RemoteFunctions> & BirpcReturnBuiltin<RemoteFunctions, LocalFunctions> : BirpcReturnBuiltin<RemoteFunctions, LocalFunctions>;
181
+ type PendingCallHandler = (options: Pick<PromiseEntry, 'method' | 'reject'>) => void | Promise<void>;
182
+ interface PromiseEntry {
183
+ resolve: (arg: any) => void;
184
+ reject: (error: any) => void;
185
+ method: string;
186
+ timeoutId?: ReturnType<typeof setTimeout>;
187
+ }
188
+ declare const setTimeout: typeof globalThis.setTimeout;
189
+
190
+ type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;
191
+ interface ContextTestEnvironment {
192
+ name: string;
193
+ options: Record<string, any> | null;
194
+ }
195
+ interface WorkerTestEnvironment {
196
+ name: string;
197
+ options: Record<string, any> | null;
198
+ }
199
+ type TestExecutionMethod = "run" | "collect";
200
+ interface WorkerExecuteContext {
201
+ files: FileSpecification[];
202
+ providedContext: Record<string, any>;
203
+ invalidates?: string[];
204
+ /** Exposed to test runner as `VITEST_WORKER_ID`. Value is unique per each isolated worker. */
205
+ workerId: number;
206
+ }
207
+ interface ContextRPC {
208
+ pool: string;
209
+ config: SerializedConfig;
210
+ projectName: string;
211
+ environment: WorkerTestEnvironment;
212
+ rpc: WorkerRPC;
213
+ files: FileSpecification[];
214
+ providedContext: Record<string, any>;
215
+ invalidates?: string[];
216
+ /** Exposed to test runner as `VITEST_WORKER_ID`. Value is unique per each isolated worker. */
217
+ workerId: number;
218
+ }
219
+ interface WorkerSetupContext {
220
+ environment: WorkerTestEnvironment;
221
+ pool: string;
222
+ config: SerializedConfig;
223
+ projectName: string;
224
+ rpc: WorkerRPC;
225
+ }
226
+ interface WorkerGlobalState {
227
+ ctx: ContextRPC;
228
+ config: SerializedConfig;
229
+ rpc: WorkerRPC;
230
+ current?: Task;
231
+ filepath?: string;
232
+ metaEnv: {
233
+ [key: string]: any;
234
+ BASE_URL: string;
235
+ MODE: string;
236
+ DEV: boolean;
237
+ PROD: boolean;
238
+ SSR: boolean;
239
+ };
240
+ environment: Environment;
241
+ evaluatedModules: EvaluatedModules;
242
+ resolvingModules: Set<string>;
243
+ moduleExecutionInfo: Map<string, any>;
244
+ onCancel: (listener: (reason: CancelReason) => unknown) => void;
245
+ onCleanup: (listener: () => unknown) => void;
246
+ providedContext: Record<string, any>;
247
+ durations: {
248
+ environment: number;
249
+ prepare: number;
250
+ };
251
+ onFilterStackTrace?: (trace: string) => string;
252
+ }
253
+
254
+ 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.DnEx6DOX.js';
1
+ import { c as createCLI } from './chunks/cac.BGonGPac.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.D6PC4Dpu.js';
7
+ import './chunks/index.456_DGfR.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,9 +1,9 @@
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.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';
3
+ import { I as InlineConfig, c as CoverageV8Options, R as ResolvedCoverageOptions, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport } from './chunks/reporters.d.Rsi0PyxX.js';
4
+ export { b as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.Rsi0PyxX.js';
5
+ import { V as VitestPluginContext } from './chunks/plugin.d.v1sC_bv1.js';
6
+ import { F as FakeTimerInstallOpts } from './chunks/config.d.CzIjkicf.js';
7
7
  import '@vitest/runner';
8
8
  import '@vitest/utils';
9
9
  import './chunks/rpc.d.RH3apGEf.js';
@@ -11,12 +11,12 @@ import '@vitest/snapshot';
11
11
  import 'vite/module-runner';
12
12
  import './chunks/traces.d.402V_yFI.js';
13
13
  import 'node:stream';
14
+ import './chunks/browser.d.Bz3lxTX-.js';
15
+ import './chunks/worker.d.5JNaocaN.js';
16
+ import './chunks/environment.d.CrsxCzP1.js';
14
17
  import '@vitest/mocker';
15
18
  import '@vitest/utils/source-map';
16
19
  import 'vitest/browser';
17
- import './chunks/browser.d.F6jMf15V.js';
18
- import './chunks/worker.d.DhEa3KzY.js';
19
- import './chunks/environment.d.CrsxCzP1.js';
20
20
  import '@vitest/pretty-format';
21
21
  import '@vitest/utils/diff';
22
22
  import '@vitest/expect';
@@ -1,20 +1,20 @@
1
- import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, a as ReportContext } from './chunks/reporters.d.DeFcIuza.js';
1
+ import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, a as ReportContext } from './chunks/reporters.d.Rsi0PyxX.js';
2
2
  import { TransformResult } from 'vite';
3
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
- import '@vitest/mocker';
8
- import '@vitest/utils/source-map';
9
- import 'vitest/browser';
10
- import './chunks/config.d.g6OOauRt.js';
7
+ import './chunks/browser.d.Bz3lxTX-.js';
8
+ import './chunks/worker.d.5JNaocaN.js';
9
+ import 'vite/module-runner';
10
+ import './chunks/config.d.CzIjkicf.js';
11
11
  import '@vitest/pretty-format';
12
12
  import '@vitest/snapshot';
13
13
  import '@vitest/utils/diff';
14
- import './chunks/browser.d.F6jMf15V.js';
15
- import './chunks/worker.d.DhEa3KzY.js';
16
- import 'vite/module-runner';
17
14
  import './chunks/environment.d.CrsxCzP1.js';
15
+ import '@vitest/mocker';
16
+ import '@vitest/utils/source-map';
17
+ import 'vitest/browser';
18
18
  import '@vitest/expect';
19
19
  import 'vitest/optional-types.js';
20
20
  import './chunks/traces.d.402V_yFI.js';
package/dist/coverage.js CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BaseCoverageProvider } from './chunks/coverage.CtyeYmKM.js';
1
+ export { B as BaseCoverageProvider } from './chunks/coverage.BuJUwVtg.js';
2
2
  import 'node:fs';
3
3
  import 'node:path';
4
4
  import '@vitest/utils/helpers';
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { S as SerializedTestSpecification } from './chunks/browser.d.F6jMf15V.js';
2
- export { B as BrowserTesterOptions } from './chunks/browser.d.F6jMf15V.js';
1
+ import { M as ModuleDefinitionDurationsDiagnostic, U as UntrackedModuleDefinitionDiagnostic, S as SerializedTestSpecification, a as ModuleDefinitionDiagnostic, b as ModuleDefinitionLocation, c as SourceModuleDiagnostic, d as SourceModuleLocations } from './chunks/browser.d.Bz3lxTX-.js';
2
+ export { B as BrowserTesterOptions } from './chunks/browser.d.Bz3lxTX-.js';
3
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 { 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';
8
+ import { b as BirpcReturn } from './chunks/worker.d.5JNaocaN.js';
9
+ export { C as ContextRPC, c as ContextTestEnvironment, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.5JNaocaN.js';
10
+ import { S as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.CzIjkicf.js';
11
+ export { b as RuntimeConfig, a as SerializedCoverageConfig } from './chunks/config.d.CzIjkicf.js';
12
12
  import { U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, P as ProvidedContext } from './chunks/rpc.d.RH3apGEf.js';
13
13
  export { A as AfterSuiteRunMeta, a as RunnerRPC, R as RuntimeRPC } from './chunks/rpc.d.RH3apGEf.js';
14
14
  import { ExpectStatic } from '@vitest/expect';
@@ -16,13 +16,14 @@ export { Assertion, AsymmetricMatchersContaining, DeeplyAllowMatchers, ExpectPol
16
16
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
17
17
  export { Mock, MockContext, MockInstance, MockResult, MockResultIncomplete, MockResultReturn, MockResultThrow, MockSettledResult, MockSettledResultFulfilled, MockSettledResultIncomplete, MockSettledResultRejected, Mocked, MockedClass, MockedFunction, MockedObject } from '@vitest/spy';
18
18
  export { b as bench } from './chunks/suite.d.BJWk38HB.js';
19
- import { EvaluatedModules } from 'vite/module-runner';
19
+ export { V as EvaluatedModules } from './chunks/evaluatedModules.d.BxJ5omdx.js';
20
20
  export { a as BenchFunction, b as Benchmark, c as BenchmarkAPI, B as BenchmarkResult } from './chunks/benchmark.d.DAaHLpsq.js';
21
21
  export { ExpectTypeOf, expectTypeOf } from 'expect-type';
22
22
  export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotSerializer, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
23
23
  export { DiffOptions } from '@vitest/utils/diff';
24
24
  export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
25
25
  import '@vitest/pretty-format';
26
+ import 'vite/module-runner';
26
27
  import './chunks/environment.d.CrsxCzP1.js';
27
28
  import './chunks/traces.d.402V_yFI.js';
28
29
  import '@vitest/runner/utils';
@@ -37,6 +38,9 @@ interface SourceMap {
37
38
  toString: () => string;
38
39
  toUrl: () => string;
39
40
  }
41
+ interface ExternalResult {
42
+ source?: string;
43
+ }
40
44
  interface TransformResultWithSource {
41
45
  code: string;
42
46
  map: SourceMap | {
@@ -46,6 +50,9 @@ interface TransformResultWithSource {
46
50
  deps?: string[];
47
51
  dynamicDeps?: string[];
48
52
  source?: string;
53
+ transformTime?: number;
54
+ modules?: ModuleDefinitionDurationsDiagnostic[];
55
+ untrackedModules?: UntrackedModuleDefinitionDiagnostic[];
49
56
  }
50
57
  interface WebSocketHandlers {
51
58
  onTaskUpdate: (packs: TaskResultPack[], events: TaskEventPack[]) => void;
@@ -58,7 +65,8 @@ interface WebSocketHandlers {
58
65
  color?: LabelColor;
59
66
  }[];
60
67
  getModuleGraph: (projectName: string, id: string, browser?: boolean) => Promise<ModuleGraphData>;
61
- getTransformResult: (projectName: string, id: string, browser?: boolean) => Promise<TransformResultWithSource | undefined>;
68
+ getTransformResult: (projectName: string, id: string, testFileId: string, browser?: boolean) => Promise<TransformResultWithSource | undefined>;
69
+ getExternalResult: (id: string, testFileId: string) => Promise<ExternalResult | undefined>;
62
70
  readTestFile: (id: string) => Promise<string | null>;
63
71
  saveTestFile: (id: string, content: string) => Promise<void>;
64
72
  rerun: (files: string[], resetTestNamePattern?: boolean) => Promise<void>;
@@ -484,10 +492,6 @@ interface VitestUtils {
484
492
  declare const vitest: VitestUtils;
485
493
  declare const vi: VitestUtils;
486
494
 
487
- declare class VitestEvaluatedModules extends EvaluatedModules {
488
- getModuleSourceMapById(id: string): any;
489
- }
490
-
491
495
  interface AssertType {
492
496
  <T>(value: T): void;
493
497
  }
@@ -498,5 +502,9 @@ interface BrowserUI {
498
502
  setIframeViewport: (width: number, height: number) => Promise<void>;
499
503
  }
500
504
 
501
- export { VitestEvaluatedModules as EvaluatedModules, LabelColor, ModuleGraphData, ProvidedContext, SerializedConfig, SerializedTestSpecification, UserConsoleLog, assert, assertType, createExpect, globalExpect as expect, inject, should, vi, vitest };
502
- export type { AssertType, BrowserUI, TransformResultWithSource, VitestUtils, WebSocketEvents, WebSocketHandlers, WebSocketRPC };
505
+ declare namespace Experimental {
506
+ export { ModuleDefinitionDiagnostic, ModuleDefinitionDurationsDiagnostic, ModuleDefinitionLocation, SourceModuleDiagnostic, SourceModuleLocations, UntrackedModuleDefinitionDiagnostic };
507
+ }
508
+
509
+ export { Experimental, LabelColor, ModuleGraphData, ProvidedContext, SerializedConfig, SerializedTestSpecification, UserConsoleLog, assert, assertType, createExpect, globalExpect as expect, inject, should, vi, vitest };
510
+ export type { AssertType, BrowserUI, ExternalResult, TransformResultWithSource, VitestUtils, WebSocketEvents, WebSocketHandlers, WebSocketRPC };
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- export { b as assert, c as createExpect, g as expect, i as inject, s as should, v as vi, d as vitest } from './chunks/vi.BiaV1qII.js';
1
+ export { b as assert, c as createExpect, g as expect, i as inject, s as should, v as vi, d as vitest } from './chunks/vi.2VT5v0um.js';
2
2
  export { b as bench } from './chunks/benchmark.B3N2zMcH.js';
3
3
  export { V as EvaluatedModules } from './chunks/evaluatedModules.Dg1zASAC.js';
4
- export { a as assertType } from './chunks/index.DBx1AtPJ.js';
4
+ export { a as assertType } from './chunks/index.Z5E_ObnR.js';
5
5
  export { expectTypeOf } from 'expect-type';
6
6
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, recordArtifact, suite, test } from '@vitest/runner';
7
7
  export { chai } from '@vitest/expect';
8
- import '@vitest/runner/utils';
9
8
  import './chunks/utils.DvEY5TfP.js';
10
9
  import '@vitest/utils/timers';
10
+ import '@vitest/runner/utils';
11
11
  import '@vitest/snapshot';
12
12
  import '@vitest/utils/error';
13
13
  import '@vitest/utils/helpers';