vitest 4.0.15 → 4.0.17

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 (49) hide show
  1. package/dist/browser.d.ts +3 -2
  2. package/dist/browser.js +2 -1
  3. package/dist/chunks/{base.CTp-EStD.js → base.XJJQZiKB.js} +4 -3
  4. package/dist/chunks/{browser.d.DBzUq_Na.d.ts → browser.d.ChKACdzH.d.ts} +3 -1
  5. package/dist/chunks/{cac.BNNpZQl7.js → cac.jRCLJDDc.js} +6 -6
  6. package/dist/chunks/{cli-api.C7sYjHmQ.js → cli-api.Cx2DW4Bc.js} +176 -89
  7. package/dist/chunks/{config.d.CzIjkicf.d.ts → config.d.Cy95HiCx.d.ts} +5 -0
  8. package/dist/chunks/{coverage.CtyeYmKM.js → coverage.AVPTjMgw.js} +6 -1
  9. package/dist/chunks/{index.bFLgAE-Z.js → index.6Qv1eEA6.js} +2 -2
  10. package/dist/chunks/{index.Drsj_6e7.js → index.C5r1PdPD.js} +1 -1
  11. package/dist/chunks/index.Chj8NDwU.js +206 -0
  12. package/dist/chunks/{index.BspFP3mn.js → index.CyBMJtT7.js} +1 -1
  13. package/dist/chunks/{index.456_DGfR.js → index.M8mOzt4Y.js} +26 -2
  14. package/dist/chunks/{init-forks.CKEYp90N.js → init-forks.BC6ZwHQN.js} +1 -1
  15. package/dist/chunks/{init-threads.D8Ok07M7.js → init-threads.CxSxLC0N.js} +1 -1
  16. package/dist/chunks/{init.B04saIIg.js → init.C9kljSTm.js} +5 -7
  17. package/dist/chunks/{modules.DJPjQW6m.js → modules.BJuCwlRJ.js} +4 -3
  18. package/dist/chunks/{plugin.d.CY7CUjf-.d.ts → plugin.d.CtqpEehP.d.ts} +1 -1
  19. package/dist/chunks/{reporters.d.OXEK7y4s.d.ts → reporters.d.CWXNI2jG.d.ts} +6 -5
  20. package/dist/chunks/{rpc.BytlcPfC.js → rpc.BoxB0q7B.js} +1 -1
  21. package/dist/chunks/{startModuleRunner.Iz2V0ESw.js → startModuleRunner.DEj0jb3e.js} +2 -2
  22. package/dist/chunks/{test.BT8LKgU9.js → test.B8ej_ZHS.js} +1 -1
  23. package/dist/chunks/{traces.U4xDYhzZ.js → traces.CCmnQaNT.js} +46 -1
  24. package/dist/chunks/{vm.BwmD1Rql.js → vm.CMjifoPa.js} +2 -2
  25. package/dist/chunks/worker.d.Dyxm8DEL.d.ts +255 -0
  26. package/dist/cli.js +2 -2
  27. package/dist/config.d.ts +6 -6
  28. package/dist/coverage.d.ts +5 -5
  29. package/dist/coverage.js +1 -1
  30. package/dist/environments.js +1 -1
  31. package/dist/index.d.ts +7 -7
  32. package/dist/module-evaluator.js +3 -11
  33. package/dist/module-runner.js +3 -3
  34. package/dist/node.d.ts +20 -11
  35. package/dist/node.js +11 -11
  36. package/dist/reporters.d.ts +4 -4
  37. package/dist/reporters.js +2 -2
  38. package/dist/runners.d.ts +1 -1
  39. package/dist/runners.js +3 -3
  40. package/dist/worker.d.ts +5 -3
  41. package/dist/worker.js +10 -10
  42. package/dist/workers/forks.js +11 -11
  43. package/dist/workers/runVmTests.js +4 -4
  44. package/dist/workers/threads.js +11 -11
  45. package/dist/workers/vmForks.js +9 -9
  46. package/dist/workers/vmThreads.js +9 -9
  47. package/package.json +13 -13
  48. package/dist/chunks/index.0kCJoeWi.js +0 -220
  49. package/dist/chunks/worker.d.B4A26qg6.d.ts +0 -238
@@ -1,238 +0,0 @@
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
- type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
8
- type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
9
- type PromisifyFn<T> = ReturnType<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
10
- type Thenable<T> = T | PromiseLike<T>;
11
- type BirpcResolver = (name: string, resolved: (...args: unknown[]) => unknown) => Thenable<((...args: unknown[]) => unknown) | undefined>;
12
- interface ChannelOptions {
13
- /**
14
- * Function to post raw message
15
- */
16
- post: (data: any, ...extras: any[]) => any | Promise<any>;
17
- /**
18
- * Listener to receive raw message
19
- */
20
- on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
21
- /**
22
- * Clear the listener when `$close` is called
23
- */
24
- off?: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
25
- /**
26
- * Custom function to serialize data
27
- *
28
- * by default it passes the data as-is
29
- */
30
- serialize?: (data: any) => any;
31
- /**
32
- * Custom function to deserialize data
33
- *
34
- * by default it passes the data as-is
35
- */
36
- deserialize?: (data: any) => any;
37
- /**
38
- * Call the methods with the RPC context or the original functions object
39
- */
40
- bind?: 'rpc' | 'functions';
41
- }
42
- interface EventOptions<Remote> {
43
- /**
44
- * Names of remote functions that do not need response.
45
- */
46
- eventNames?: (keyof Remote)[];
47
- /**
48
- * Maximum timeout for waiting for response, in milliseconds.
49
- *
50
- * @default 60_000
51
- */
52
- timeout?: number;
53
- /**
54
- * Custom resolver to resolve function to be called
55
- *
56
- * For advanced use cases only
57
- */
58
- resolver?: BirpcResolver;
59
- /**
60
- * Hook triggered before an event is sent to the remote
61
- *
62
- * @param req - Request parameters
63
- * @param next - Function to continue the request
64
- * @param resolve - Function to resolve the response directly
65
- */
66
- onRequest?: (req: Request, next: (req?: Request) => Promise<any>, resolve: (res: any) => void) => void | Promise<void>;
67
- /**
68
- * Custom error handler
69
- *
70
- * @deprecated use `onFunctionError` and `onGeneralError` instead
71
- */
72
- onError?: (error: Error, functionName: string, args: any[]) => boolean | void;
73
- /**
74
- * Custom error handler for errors occurred in local functions being called
75
- *
76
- * @returns `true` to prevent the error from being thrown
77
- */
78
- onFunctionError?: (error: Error, functionName: string, args: any[]) => boolean | void;
79
- /**
80
- * Custom error handler for errors occurred during serialization or messsaging
81
- *
82
- * @returns `true` to prevent the error from being thrown
83
- */
84
- onGeneralError?: (error: Error, functionName?: string, args?: any[]) => boolean | void;
85
- /**
86
- * Custom error handler for timeouts
87
- *
88
- * @returns `true` to prevent the error from being thrown
89
- */
90
- onTimeoutError?: (functionName: string, args: any[]) => boolean | void;
91
- }
92
- type BirpcOptions<Remote> = EventOptions<Remote> & ChannelOptions;
93
- type BirpcFn<T> = PromisifyFn<T> & {
94
- /**
95
- * Send event without asking for response
96
- */
97
- asEvent: (...args: ArgumentsType<T>) => Promise<void>;
98
- };
99
- interface BirpcReturnBuiltin<RemoteFunctions, LocalFunctions = Record<string, never>> {
100
- /**
101
- * Raw functions object
102
- */
103
- $functions: LocalFunctions;
104
- /**
105
- * Whether the RPC is closed
106
- */
107
- readonly $closed: boolean;
108
- /**
109
- * Close the RPC connection
110
- */
111
- $close: (error?: Error) => void;
112
- /**
113
- * Reject pending calls
114
- */
115
- $rejectPendingCalls: (handler?: PendingCallHandler) => Promise<void>[];
116
- /**
117
- * Call the remote function and wait for the result.
118
- * An alternative to directly calling the function
119
- */
120
- $call: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<Awaited<ReturnType<RemoteFunctions[K]>>>;
121
- /**
122
- * Same as `$call`, but returns `undefined` if the function is not defined on the remote side.
123
- */
124
- $callOptional: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<Awaited<ReturnType<RemoteFunctions[K]> | undefined>>;
125
- /**
126
- * Send event without asking for response
127
- */
128
- $callEvent: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<void>;
129
- /**
130
- * Call the remote function with the raw options.
131
- */
132
- $callRaw: (options: {
133
- method: string;
134
- args: unknown[];
135
- event?: boolean;
136
- optional?: boolean;
137
- }) => Promise<Awaited<ReturnType<any>>[]>;
138
- }
139
- type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
140
- [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
141
- } & BirpcReturnBuiltin<RemoteFunctions, LocalFunctions>;
142
- type PendingCallHandler = (options: Pick<PromiseEntry, 'method' | 'reject'>) => void | Promise<void>;
143
- interface PromiseEntry {
144
- resolve: (arg: any) => void;
145
- reject: (error: any) => void;
146
- method: string;
147
- timeoutId?: ReturnType<typeof setTimeout>;
148
- }
149
- declare const TYPE_REQUEST: "q";
150
- interface Request {
151
- /**
152
- * Type
153
- */
154
- t: typeof TYPE_REQUEST;
155
- /**
156
- * ID
157
- */
158
- i?: string;
159
- /**
160
- * Method
161
- */
162
- m: string;
163
- /**
164
- * Arguments
165
- */
166
- a: any[];
167
- /**
168
- * Optional
169
- */
170
- o?: boolean;
171
- }
172
- declare const setTimeout: typeof globalThis.setTimeout;
173
-
174
- type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;
175
- interface ContextTestEnvironment {
176
- name: string;
177
- options: Record<string, any> | null;
178
- }
179
- interface WorkerTestEnvironment {
180
- name: string;
181
- options: Record<string, any> | null;
182
- }
183
- type TestExecutionMethod = "run" | "collect";
184
- interface WorkerExecuteContext {
185
- files: FileSpecification[];
186
- providedContext: Record<string, any>;
187
- invalidates?: string[];
188
- /** Exposed to test runner as `VITEST_WORKER_ID`. Value is unique per each isolated worker. */
189
- workerId: number;
190
- }
191
- interface ContextRPC {
192
- pool: string;
193
- config: SerializedConfig;
194
- projectName: string;
195
- environment: WorkerTestEnvironment;
196
- rpc: WorkerRPC;
197
- files: FileSpecification[];
198
- providedContext: Record<string, any>;
199
- invalidates?: string[];
200
- /** Exposed to test runner as `VITEST_WORKER_ID`. Value is unique per each isolated worker. */
201
- workerId: number;
202
- }
203
- interface WorkerSetupContext {
204
- environment: WorkerTestEnvironment;
205
- pool: string;
206
- config: SerializedConfig;
207
- projectName: string;
208
- rpc: WorkerRPC;
209
- }
210
- interface WorkerGlobalState {
211
- ctx: ContextRPC;
212
- config: SerializedConfig;
213
- rpc: WorkerRPC;
214
- current?: Task;
215
- filepath?: string;
216
- metaEnv: {
217
- [key: string]: any;
218
- BASE_URL: string;
219
- MODE: string;
220
- DEV: boolean;
221
- PROD: boolean;
222
- SSR: boolean;
223
- };
224
- environment: Environment;
225
- evaluatedModules: EvaluatedModules;
226
- resolvingModules: Set<string>;
227
- moduleExecutionInfo: Map<string, any>;
228
- onCancel: (listener: (reason: CancelReason) => unknown) => void;
229
- onCleanup: (listener: () => unknown) => void;
230
- providedContext: Record<string, any>;
231
- durations: {
232
- environment: number;
233
- prepare: number;
234
- };
235
- onFilterStackTrace?: (trace: string) => string;
236
- }
237
-
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 };