@depup/vitest 4.0.18-depup.0
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.
- package/LICENSE.md +691 -0
- package/README.md +7 -0
- package/browser/context.d.ts +7 -0
- package/browser/context.js +20 -0
- package/config.d.ts +3 -0
- package/coverage.d.ts +1 -0
- package/dist/browser.d.ts +46 -0
- package/dist/browser.js +20 -0
- package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
- package/dist/chunks/base.CJ0Y4ePK.js +165 -0
- package/dist/chunks/benchmark.B3N2zMcH.js +40 -0
- package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +24 -0
- package/dist/chunks/browser.d.ChKACdzH.d.ts +59 -0
- package/dist/chunks/cac.DVeoLl0M.js +1409 -0
- package/dist/chunks/cli-api.B7PN_QUv.js +13657 -0
- package/dist/chunks/config.d.Cy95HiCx.d.ts +210 -0
- package/dist/chunks/console.Cf-YriPC.js +146 -0
- package/dist/chunks/constants.D_Q9UYh-.js +36 -0
- package/dist/chunks/coverage.AVPTjMgw.js +3292 -0
- package/dist/chunks/coverage.D_JHT54q.js +25 -0
- package/dist/chunks/coverage.d.BZtK59WP.d.ts +37 -0
- package/dist/chunks/creator.DAmOKTvJ.js +673 -0
- package/dist/chunks/date.Bq6ZW5rf.js +73 -0
- package/dist/chunks/defaults.BOqNVLsY.js +74 -0
- package/dist/chunks/env.D4Lgay0q.js +8 -0
- package/dist/chunks/environment.d.CrsxCzP1.d.ts +29 -0
- package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
- package/dist/chunks/evaluatedModules.d.BxJ5omdx.d.ts +7 -0
- package/dist/chunks/git.Bm2pzPAa.js +71 -0
- package/dist/chunks/global.d.B15mdLcR.d.ts +99 -0
- package/dist/chunks/globals.DOayXfHP.js +30 -0
- package/dist/chunks/index.6Qv1eEA6.js +109 -0
- package/dist/chunks/index.C5r1PdPD.js +231 -0
- package/dist/chunks/index.Chj8NDwU.js +206 -0
- package/dist/chunks/index.CyBMJtT7.js +727 -0
- package/dist/chunks/index.D3XRDfWc.js +213 -0
- package/dist/chunks/index.D4KonVSU.js +6343 -0
- package/dist/chunks/index.M8mOzt4Y.js +3839 -0
- package/dist/chunks/index.Z5E_ObnR.js +37 -0
- package/dist/chunks/init-forks._y3TW739.js +41 -0
- package/dist/chunks/init-threads.DBO2kn-p.js +18 -0
- package/dist/chunks/init.B6MLFIaN.js +334 -0
- package/dist/chunks/inspector.CvyFGlXm.js +53 -0
- package/dist/chunks/modules.BJuCwlRJ.js +36 -0
- package/dist/chunks/node.Ce0vMQM7.js +14 -0
- package/dist/chunks/plugin.d.CtqpEehP.d.ts +38 -0
- package/dist/chunks/reporters.d.CWXNI2jG.d.ts +3271 -0
- package/dist/chunks/rpc.BoxB0q7B.js +76 -0
- package/dist/chunks/rpc.d.RH3apGEf.d.ts +64 -0
- package/dist/chunks/setup-common.Cm-kSBVi.js +60 -0
- package/dist/chunks/startModuleRunner.DEj0jb3e.js +861 -0
- package/dist/chunks/suite.d.BJWk38HB.d.ts +10 -0
- package/dist/chunks/test.B8ej_ZHS.js +254 -0
- package/dist/chunks/traces.CCmnQaNT.js +217 -0
- package/dist/chunks/traces.d.402V_yFI.d.ts +18 -0
- package/dist/chunks/utils.DvEY5TfP.js +52 -0
- package/dist/chunks/vi.2VT5v0um.js +3919 -0
- package/dist/chunks/vm.D3epNOPZ.js +744 -0
- package/dist/chunks/worker.d.Dyxm8DEL.d.ts +255 -0
- package/dist/cli.js +28 -0
- package/dist/config.cjs +94 -0
- package/dist/config.d.ts +104 -0
- package/dist/config.js +15 -0
- package/dist/coverage.d.ts +118 -0
- package/dist/coverage.js +23 -0
- package/dist/environments.d.ts +22 -0
- package/dist/environments.js +3 -0
- package/dist/index.d.ts +510 -0
- package/dist/index.js +20 -0
- package/dist/mocker.d.ts +1 -0
- package/dist/mocker.js +1 -0
- package/dist/module-evaluator.d.ts +124 -0
- package/dist/module-evaluator.js +343 -0
- package/dist/module-runner.js +17 -0
- package/dist/node.d.ts +251 -0
- package/dist/node.js +98 -0
- package/dist/path.js +7 -0
- package/dist/reporters.d.ts +27 -0
- package/dist/reporters.js +24 -0
- package/dist/runners.d.ts +50 -0
- package/dist/runners.js +19 -0
- package/dist/snapshot.d.ts +9 -0
- package/dist/snapshot.js +4 -0
- package/dist/spy.js +1 -0
- package/dist/suite.d.ts +5 -0
- package/dist/suite.js +6 -0
- package/dist/worker.d.ts +32 -0
- package/dist/worker.js +48 -0
- package/dist/workers/forks.js +54 -0
- package/dist/workers/runVmTests.js +95 -0
- package/dist/workers/threads.js +55 -0
- package/dist/workers/vmForks.js +36 -0
- package/dist/workers/vmThreads.js +37 -0
- package/environments.d.ts +1 -0
- package/globals.d.ts +20 -0
- package/import-meta.d.ts +5 -0
- package/importMeta.d.ts +4 -0
- package/index.cjs +5 -0
- package/index.d.cts +1 -0
- package/jsdom.d.ts +6 -0
- package/mocker.d.ts +1 -0
- package/node.d.ts +1 -0
- package/optional-types.d.ts +7 -0
- package/package.json +224 -0
- package/reporters.d.ts +1 -0
- package/runners.d.ts +1 -0
- package/snapshot.d.ts +1 -0
- package/suite.d.ts +1 -0
- package/suppress-warnings.cjs +21 -0
- package/vitest.mjs +2 -0
- package/worker.d.ts +1 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { FileSpecification, Task, CancelReason } from '@vitest/runner';
|
|
2
|
+
import { EvaluatedModules } from 'vite/module-runner';
|
|
3
|
+
import { S as SerializedConfig } from './config.d.Cy95HiCx.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
|
+
environment: ContextTestEnvironment;
|
|
205
|
+
/** Exposed to test runner as `VITEST_WORKER_ID`. Value is unique per each isolated worker. */
|
|
206
|
+
workerId: number;
|
|
207
|
+
}
|
|
208
|
+
interface ContextRPC {
|
|
209
|
+
pool: string;
|
|
210
|
+
config: SerializedConfig;
|
|
211
|
+
projectName: string;
|
|
212
|
+
environment: WorkerTestEnvironment;
|
|
213
|
+
rpc: WorkerRPC;
|
|
214
|
+
files: FileSpecification[];
|
|
215
|
+
providedContext: Record<string, any>;
|
|
216
|
+
invalidates?: string[];
|
|
217
|
+
/** Exposed to test runner as `VITEST_WORKER_ID`. Value is unique per each isolated worker. */
|
|
218
|
+
workerId: number;
|
|
219
|
+
}
|
|
220
|
+
interface WorkerSetupContext {
|
|
221
|
+
environment: WorkerTestEnvironment;
|
|
222
|
+
pool: string;
|
|
223
|
+
config: SerializedConfig;
|
|
224
|
+
projectName: string;
|
|
225
|
+
rpc: WorkerRPC;
|
|
226
|
+
}
|
|
227
|
+
interface WorkerGlobalState {
|
|
228
|
+
ctx: ContextRPC;
|
|
229
|
+
config: SerializedConfig;
|
|
230
|
+
rpc: WorkerRPC;
|
|
231
|
+
current?: Task;
|
|
232
|
+
filepath?: string;
|
|
233
|
+
metaEnv: {
|
|
234
|
+
[key: string]: any;
|
|
235
|
+
BASE_URL: string;
|
|
236
|
+
MODE: string;
|
|
237
|
+
DEV: boolean;
|
|
238
|
+
PROD: boolean;
|
|
239
|
+
SSR: boolean;
|
|
240
|
+
};
|
|
241
|
+
environment: Environment;
|
|
242
|
+
evaluatedModules: EvaluatedModules;
|
|
243
|
+
resolvingModules: Set<string>;
|
|
244
|
+
moduleExecutionInfo: Map<string, any>;
|
|
245
|
+
onCancel: (listener: (reason: CancelReason) => unknown) => void;
|
|
246
|
+
onCleanup: (listener: () => unknown) => void;
|
|
247
|
+
providedContext: Record<string, any>;
|
|
248
|
+
durations: {
|
|
249
|
+
environment: number;
|
|
250
|
+
prepare: number;
|
|
251
|
+
};
|
|
252
|
+
onFilterStackTrace?: (trace: string) => string;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
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
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { c as createCLI } from './chunks/cac.DVeoLl0M.js';
|
|
2
|
+
import '@vitest/utils/helpers';
|
|
3
|
+
import 'events';
|
|
4
|
+
import 'pathe';
|
|
5
|
+
import 'tinyrainbow';
|
|
6
|
+
import './chunks/constants.D_Q9UYh-.js';
|
|
7
|
+
import './chunks/index.M8mOzt4Y.js';
|
|
8
|
+
import 'node:fs';
|
|
9
|
+
import 'node:fs/promises';
|
|
10
|
+
import 'node:perf_hooks';
|
|
11
|
+
import '@vitest/runner/utils';
|
|
12
|
+
import '@vitest/utils/source-map';
|
|
13
|
+
import './chunks/env.D4Lgay0q.js';
|
|
14
|
+
import 'std-env';
|
|
15
|
+
import 'node:util';
|
|
16
|
+
import 'node:console';
|
|
17
|
+
import 'node:stream';
|
|
18
|
+
import '@vitest/utils/display';
|
|
19
|
+
import 'node:os';
|
|
20
|
+
import 'tinyexec';
|
|
21
|
+
import './path.js';
|
|
22
|
+
import 'node:path';
|
|
23
|
+
import 'node:url';
|
|
24
|
+
import 'vite';
|
|
25
|
+
import '@vitest/utils/offset';
|
|
26
|
+
import 'node:module';
|
|
27
|
+
|
|
28
|
+
createCLI().parse();
|
package/dist/config.cjs
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var os = require('node:os');
|
|
4
|
+
var stdEnv = require('std-env');
|
|
5
|
+
var vite = require('vite');
|
|
6
|
+
|
|
7
|
+
const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
|
|
8
|
+
const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
|
|
9
|
+
(isNode || isDeno) && process.platform === "win32";
|
|
10
|
+
(isNode || isDeno) && process.stdout?.isTTY && !stdEnv.isCI;
|
|
11
|
+
|
|
12
|
+
// if changed, update also jsdocs and docs
|
|
13
|
+
const defaultBrowserPort = 63315;
|
|
14
|
+
|
|
15
|
+
const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
|
|
16
|
+
const defaultExclude = ["**/node_modules/**", "**/.git/**"];
|
|
17
|
+
// These are the generic defaults for coverage. Providers may also set some provider specific defaults.
|
|
18
|
+
const coverageConfigDefaults = {
|
|
19
|
+
provider: "v8",
|
|
20
|
+
enabled: false,
|
|
21
|
+
clean: true,
|
|
22
|
+
cleanOnRerun: true,
|
|
23
|
+
reportsDirectory: "./coverage",
|
|
24
|
+
exclude: [],
|
|
25
|
+
reportOnFailure: false,
|
|
26
|
+
reporter: [
|
|
27
|
+
["text", {}],
|
|
28
|
+
["html", {}],
|
|
29
|
+
["clover", {}],
|
|
30
|
+
["json", {}]
|
|
31
|
+
],
|
|
32
|
+
allowExternal: false,
|
|
33
|
+
excludeAfterRemap: false,
|
|
34
|
+
processingConcurrency: Math.min(20, os.availableParallelism?.() ?? os.cpus().length)
|
|
35
|
+
};
|
|
36
|
+
const fakeTimersDefaults = {
|
|
37
|
+
loopLimit: 1e4,
|
|
38
|
+
shouldClearNativeTimers: true
|
|
39
|
+
};
|
|
40
|
+
const configDefaults = Object.freeze({
|
|
41
|
+
allowOnly: !stdEnv.isCI,
|
|
42
|
+
isolate: true,
|
|
43
|
+
watch: !stdEnv.isCI && process.stdin.isTTY,
|
|
44
|
+
globals: false,
|
|
45
|
+
environment: "node",
|
|
46
|
+
clearMocks: false,
|
|
47
|
+
restoreMocks: false,
|
|
48
|
+
mockReset: false,
|
|
49
|
+
unstubGlobals: false,
|
|
50
|
+
unstubEnvs: false,
|
|
51
|
+
include: defaultInclude,
|
|
52
|
+
exclude: defaultExclude,
|
|
53
|
+
teardownTimeout: 1e4,
|
|
54
|
+
forceRerunTriggers: ["**/package.json/**", "**/{vitest,vite}.config.*/**"],
|
|
55
|
+
update: false,
|
|
56
|
+
reporters: [],
|
|
57
|
+
silent: false,
|
|
58
|
+
hideSkippedTests: false,
|
|
59
|
+
api: false,
|
|
60
|
+
ui: false,
|
|
61
|
+
uiBase: "/__vitest__/",
|
|
62
|
+
open: !stdEnv.isCI,
|
|
63
|
+
css: { include: [] },
|
|
64
|
+
coverage: coverageConfigDefaults,
|
|
65
|
+
fakeTimers: fakeTimersDefaults,
|
|
66
|
+
maxConcurrency: 5,
|
|
67
|
+
dangerouslyIgnoreUnhandledErrors: false,
|
|
68
|
+
typecheck: {
|
|
69
|
+
checker: "tsc",
|
|
70
|
+
include: ["**/*.{test,spec}-d.?(c|m)[jt]s?(x)"],
|
|
71
|
+
exclude: defaultExclude
|
|
72
|
+
},
|
|
73
|
+
slowTestThreshold: 300,
|
|
74
|
+
disableConsoleIntercept: false
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
function defineConfig(config) {
|
|
78
|
+
return config;
|
|
79
|
+
}
|
|
80
|
+
function defineProject(config) {
|
|
81
|
+
return config;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
Object.defineProperty(exports, "mergeConfig", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () { return vite.mergeConfig; }
|
|
87
|
+
});
|
|
88
|
+
exports.configDefaults = configDefaults;
|
|
89
|
+
exports.coverageConfigDefaults = coverageConfigDefaults;
|
|
90
|
+
exports.defaultBrowserPort = defaultBrowserPort;
|
|
91
|
+
exports.defaultExclude = defaultExclude;
|
|
92
|
+
exports.defaultInclude = defaultInclude;
|
|
93
|
+
exports.defineConfig = defineConfig;
|
|
94
|
+
exports.defineProject = defineProject;
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { HookHandler, ConfigEnv, UserConfig } from 'vite';
|
|
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.CWXNI2jG.js';
|
|
4
|
+
export { b as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.CWXNI2jG.js';
|
|
5
|
+
import { V as VitestPluginContext } from './chunks/plugin.d.CtqpEehP.js';
|
|
6
|
+
import { F as FakeTimerInstallOpts } from './chunks/config.d.Cy95HiCx.js';
|
|
7
|
+
import '@vitest/runner';
|
|
8
|
+
import '@vitest/utils';
|
|
9
|
+
import './chunks/rpc.d.RH3apGEf.js';
|
|
10
|
+
import '@vitest/snapshot';
|
|
11
|
+
import 'vite/module-runner';
|
|
12
|
+
import './chunks/traces.d.402V_yFI.js';
|
|
13
|
+
import 'node:stream';
|
|
14
|
+
import './chunks/browser.d.ChKACdzH.js';
|
|
15
|
+
import './chunks/worker.d.Dyxm8DEL.js';
|
|
16
|
+
import './chunks/environment.d.CrsxCzP1.js';
|
|
17
|
+
import '@vitest/mocker';
|
|
18
|
+
import '@vitest/utils/source-map';
|
|
19
|
+
import 'vitest/browser';
|
|
20
|
+
import '@vitest/pretty-format';
|
|
21
|
+
import '@vitest/utils/diff';
|
|
22
|
+
import '@vitest/expect';
|
|
23
|
+
import 'vitest/optional-types.js';
|
|
24
|
+
import './chunks/benchmark.d.DAaHLpsq.js';
|
|
25
|
+
import '@vitest/runner/utils';
|
|
26
|
+
import 'tinybench';
|
|
27
|
+
import './chunks/coverage.d.BZtK59WP.js';
|
|
28
|
+
import '@vitest/snapshot/manager';
|
|
29
|
+
import 'node:console';
|
|
30
|
+
import 'node:fs';
|
|
31
|
+
|
|
32
|
+
type VitestInlineConfig = InlineConfig;
|
|
33
|
+
declare module "vite" {
|
|
34
|
+
interface UserConfig {
|
|
35
|
+
/**
|
|
36
|
+
* Options for Vitest
|
|
37
|
+
*/
|
|
38
|
+
test?: VitestInlineConfig;
|
|
39
|
+
}
|
|
40
|
+
interface Plugin<A = any> {
|
|
41
|
+
configureVitest?: HookHandler<(context: VitestPluginContext) => void>;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare const defaultBrowserPort = 63315;
|
|
46
|
+
|
|
47
|
+
declare const defaultInclude: string[];
|
|
48
|
+
declare const defaultExclude: string[];
|
|
49
|
+
declare const coverageConfigDefaults: ResolvedCoverageOptions;
|
|
50
|
+
declare const configDefaults: Readonly<{
|
|
51
|
+
allowOnly: boolean;
|
|
52
|
+
isolate: boolean;
|
|
53
|
+
watch: boolean;
|
|
54
|
+
globals: boolean;
|
|
55
|
+
environment: "node";
|
|
56
|
+
clearMocks: boolean;
|
|
57
|
+
restoreMocks: boolean;
|
|
58
|
+
mockReset: boolean;
|
|
59
|
+
unstubGlobals: boolean;
|
|
60
|
+
unstubEnvs: boolean;
|
|
61
|
+
include: string[];
|
|
62
|
+
exclude: string[];
|
|
63
|
+
teardownTimeout: number;
|
|
64
|
+
forceRerunTriggers: string[];
|
|
65
|
+
update: boolean;
|
|
66
|
+
reporters: never[];
|
|
67
|
+
silent: boolean;
|
|
68
|
+
hideSkippedTests: boolean;
|
|
69
|
+
api: boolean;
|
|
70
|
+
ui: boolean;
|
|
71
|
+
uiBase: string;
|
|
72
|
+
open: boolean;
|
|
73
|
+
css: {
|
|
74
|
+
include: never[];
|
|
75
|
+
};
|
|
76
|
+
coverage: CoverageV8Options;
|
|
77
|
+
fakeTimers: FakeTimerInstallOpts;
|
|
78
|
+
maxConcurrency: number;
|
|
79
|
+
dangerouslyIgnoreUnhandledErrors: boolean;
|
|
80
|
+
typecheck: {
|
|
81
|
+
checker: "tsc";
|
|
82
|
+
include: string[];
|
|
83
|
+
exclude: string[];
|
|
84
|
+
};
|
|
85
|
+
slowTestThreshold: number;
|
|
86
|
+
disableConsoleIntercept: boolean;
|
|
87
|
+
}>;
|
|
88
|
+
|
|
89
|
+
type ViteUserConfigFnObject = (env: ConfigEnv) => UserConfig;
|
|
90
|
+
type ViteUserConfigFnPromise = (env: ConfigEnv) => Promise<UserConfig>;
|
|
91
|
+
type ViteUserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
|
|
92
|
+
type ViteUserConfigExport = UserConfig | Promise<UserConfig> | ViteUserConfigFnObject | ViteUserConfigFnPromise | ViteUserConfigFn;
|
|
93
|
+
declare function defineConfig(config: UserConfig): UserConfig;
|
|
94
|
+
declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
|
95
|
+
declare function defineConfig(config: ViteUserConfigFnObject): ViteUserConfigFnObject;
|
|
96
|
+
declare function defineConfig(config: ViteUserConfigFnPromise): ViteUserConfigFnPromise;
|
|
97
|
+
declare function defineConfig(config: ViteUserConfigExport): ViteUserConfigExport;
|
|
98
|
+
declare function defineProject(config: UserWorkspaceConfig): UserWorkspaceConfig;
|
|
99
|
+
declare function defineProject(config: Promise<UserWorkspaceConfig>): Promise<UserWorkspaceConfig>;
|
|
100
|
+
declare function defineProject(config: UserProjectConfigFn): UserProjectConfigFn;
|
|
101
|
+
declare function defineProject(config: UserProjectConfigExport): UserProjectConfigExport;
|
|
102
|
+
|
|
103
|
+
export { UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude, defineConfig, defineProject };
|
|
104
|
+
export type { ViteUserConfigExport, ViteUserConfigFn, ViteUserConfigFnObject, ViteUserConfigFnPromise };
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { c as configDefaults, a as coverageConfigDefaults, d as defaultExclude, b as defaultInclude } from './chunks/defaults.BOqNVLsY.js';
|
|
2
|
+
export { mergeConfig } from 'vite';
|
|
3
|
+
export { d as defaultBrowserPort } from './chunks/constants.D_Q9UYh-.js';
|
|
4
|
+
import 'node:os';
|
|
5
|
+
import './chunks/env.D4Lgay0q.js';
|
|
6
|
+
import 'std-env';
|
|
7
|
+
|
|
8
|
+
function defineConfig(config) {
|
|
9
|
+
return config;
|
|
10
|
+
}
|
|
11
|
+
function defineProject(config) {
|
|
12
|
+
return config;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { defineConfig, defineProject };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, a as ReportContext } from './chunks/reporters.d.CWXNI2jG.js';
|
|
2
|
+
import { TransformResult } from 'vite';
|
|
3
|
+
import { A as AfterSuiteRunMeta } from './chunks/rpc.d.RH3apGEf.js';
|
|
4
|
+
import '@vitest/runner';
|
|
5
|
+
import '@vitest/utils';
|
|
6
|
+
import 'node:stream';
|
|
7
|
+
import './chunks/browser.d.ChKACdzH.js';
|
|
8
|
+
import './chunks/traces.d.402V_yFI.js';
|
|
9
|
+
import './chunks/worker.d.Dyxm8DEL.js';
|
|
10
|
+
import 'vite/module-runner';
|
|
11
|
+
import './chunks/config.d.Cy95HiCx.js';
|
|
12
|
+
import '@vitest/pretty-format';
|
|
13
|
+
import '@vitest/snapshot';
|
|
14
|
+
import '@vitest/utils/diff';
|
|
15
|
+
import './chunks/environment.d.CrsxCzP1.js';
|
|
16
|
+
import '@vitest/mocker';
|
|
17
|
+
import '@vitest/utils/source-map';
|
|
18
|
+
import 'vitest/browser';
|
|
19
|
+
import '@vitest/expect';
|
|
20
|
+
import 'vitest/optional-types.js';
|
|
21
|
+
import './chunks/benchmark.d.DAaHLpsq.js';
|
|
22
|
+
import '@vitest/runner/utils';
|
|
23
|
+
import 'tinybench';
|
|
24
|
+
import './chunks/coverage.d.BZtK59WP.js';
|
|
25
|
+
import '@vitest/snapshot/manager';
|
|
26
|
+
import 'node:console';
|
|
27
|
+
import 'node:fs';
|
|
28
|
+
|
|
29
|
+
type Threshold = "lines" | "functions" | "statements" | "branches";
|
|
30
|
+
interface ResolvedThreshold {
|
|
31
|
+
coverageMap: CoverageMap;
|
|
32
|
+
name: string;
|
|
33
|
+
thresholds: Partial<Record<Threshold, number | undefined>>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Holds info about raw coverage results that are stored on file system:
|
|
37
|
+
*
|
|
38
|
+
* ```json
|
|
39
|
+
* "project-a": {
|
|
40
|
+
* "web": {
|
|
41
|
+
* "tests/math.test.ts": "coverage-1.json",
|
|
42
|
+
* "tests/utils.test.ts": "coverage-2.json",
|
|
43
|
+
* // ^^^^^^^^^^^^^^^ Raw coverage on file system
|
|
44
|
+
* },
|
|
45
|
+
* "ssr": { ... },
|
|
46
|
+
* "browser": { ... },
|
|
47
|
+
* },
|
|
48
|
+
* "project-b": ...
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
type CoverageFiles = Map<NonNullable<AfterSuiteRunMeta["projectName"]> | symbol, Record<AfterSuiteRunMeta["environment"], {
|
|
52
|
+
[TestFilenames: string]: string;
|
|
53
|
+
}>>;
|
|
54
|
+
declare class BaseCoverageProvider<Options extends ResolvedCoverageOptions<"istanbul" | "v8">> {
|
|
55
|
+
ctx: Vitest;
|
|
56
|
+
readonly name: "v8" | "istanbul";
|
|
57
|
+
version: string;
|
|
58
|
+
options: Options;
|
|
59
|
+
globCache: Map<string, boolean>;
|
|
60
|
+
coverageFiles: CoverageFiles;
|
|
61
|
+
pendingPromises: Promise<void>[];
|
|
62
|
+
coverageFilesDirectory: string;
|
|
63
|
+
roots: string[];
|
|
64
|
+
_initialize(ctx: Vitest): void;
|
|
65
|
+
/**
|
|
66
|
+
* Check if file matches `coverage.include` but not `coverage.exclude`
|
|
67
|
+
*/
|
|
68
|
+
isIncluded(_filename: string, root?: string): boolean;
|
|
69
|
+
private getUntestedFilesByRoot;
|
|
70
|
+
getUntestedFiles(testedFiles: string[]): Promise<string[]>;
|
|
71
|
+
createCoverageMap(): CoverageMap;
|
|
72
|
+
generateReports(_: CoverageMap, __: boolean | undefined): Promise<void>;
|
|
73
|
+
parseConfigModule(_: string): Promise<{
|
|
74
|
+
generate: () => {
|
|
75
|
+
code: string;
|
|
76
|
+
};
|
|
77
|
+
}>;
|
|
78
|
+
resolveOptions(): Options;
|
|
79
|
+
clean(clean?: boolean): Promise<void>;
|
|
80
|
+
onAfterSuiteRun({ coverage, environment, projectName, testFiles }: AfterSuiteRunMeta): void;
|
|
81
|
+
readCoverageFiles<CoverageType>({ onFileRead, onFinished, onDebug }: {
|
|
82
|
+
/** Callback invoked with a single coverage result */
|
|
83
|
+
onFileRead: (data: CoverageType) => void;
|
|
84
|
+
/** Callback invoked once all results of a project for specific transform mode are read */
|
|
85
|
+
onFinished: (project: Vitest["projects"][number], environment: string) => Promise<void>;
|
|
86
|
+
onDebug: ((...logs: any[]) => void) & {
|
|
87
|
+
enabled: boolean;
|
|
88
|
+
};
|
|
89
|
+
}): Promise<void>;
|
|
90
|
+
cleanAfterRun(): Promise<void>;
|
|
91
|
+
onTestFailure(): Promise<void>;
|
|
92
|
+
reportCoverage(coverageMap: unknown, { allTestsRun }: ReportContext): Promise<void>;
|
|
93
|
+
reportThresholds(coverageMap: CoverageMap, allTestsRun: boolean | undefined): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Constructs collected coverage and users' threshold options into separate sets
|
|
96
|
+
* where each threshold set holds their own coverage maps. Threshold set is either
|
|
97
|
+
* for specific files defined by glob pattern or global for all other files.
|
|
98
|
+
*/
|
|
99
|
+
private resolveThresholds;
|
|
100
|
+
/**
|
|
101
|
+
* Check collected coverage against configured thresholds. Sets exit code to 1 when thresholds not reached.
|
|
102
|
+
*/
|
|
103
|
+
private checkThresholds;
|
|
104
|
+
/**
|
|
105
|
+
* Check if current coverage is above configured thresholds and bump the thresholds if needed
|
|
106
|
+
*/
|
|
107
|
+
updateThresholds({ thresholds: allThresholds, onUpdate, configurationFile }: {
|
|
108
|
+
thresholds: ResolvedThreshold[];
|
|
109
|
+
configurationFile: unknown;
|
|
110
|
+
onUpdate: () => void;
|
|
111
|
+
}): Promise<void>;
|
|
112
|
+
mergeReports(coverageMaps: unknown[]): Promise<void>;
|
|
113
|
+
hasTerminalReporter(reporters: ResolvedCoverageOptions["reporter"]): boolean;
|
|
114
|
+
toSlices<T>(array: T[], size: number): T[][];
|
|
115
|
+
createUncoveredFileTransformer(ctx: Vitest): (filename: string) => Promise<TransformResult | null | undefined>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { BaseCoverageProvider };
|
package/dist/coverage.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { B as BaseCoverageProvider } from './chunks/coverage.AVPTjMgw.js';
|
|
2
|
+
import 'node:fs';
|
|
3
|
+
import 'node:path';
|
|
4
|
+
import '@vitest/utils/helpers';
|
|
5
|
+
import 'pathe';
|
|
6
|
+
import 'picomatch';
|
|
7
|
+
import 'tinyglobby';
|
|
8
|
+
import 'tinyrainbow';
|
|
9
|
+
import './chunks/defaults.BOqNVLsY.js';
|
|
10
|
+
import 'node:os';
|
|
11
|
+
import './chunks/env.D4Lgay0q.js';
|
|
12
|
+
import 'std-env';
|
|
13
|
+
import 'node:crypto';
|
|
14
|
+
import 'node:url';
|
|
15
|
+
import 'node:module';
|
|
16
|
+
import 'node:process';
|
|
17
|
+
import 'node:fs/promises';
|
|
18
|
+
import 'node:assert';
|
|
19
|
+
import 'node:v8';
|
|
20
|
+
import 'node:util';
|
|
21
|
+
import 'vite';
|
|
22
|
+
import './chunks/constants.D_Q9UYh-.js';
|
|
23
|
+
import './chunks/coverage.D_JHT54q.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { E as Environment } from './chunks/environment.d.CrsxCzP1.js';
|
|
2
|
+
export { a as EnvironmentReturn, V as VmEnvironmentReturn } from './chunks/environment.d.CrsxCzP1.js';
|
|
3
|
+
import '@vitest/utils';
|
|
4
|
+
|
|
5
|
+
declare const environments: {
|
|
6
|
+
"node": Environment;
|
|
7
|
+
"jsdom": Environment;
|
|
8
|
+
"happy-dom": Environment;
|
|
9
|
+
"edge-runtime": Environment;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
interface PopulateOptions {
|
|
13
|
+
bindFunctions?: boolean;
|
|
14
|
+
additionalKeys?: string[];
|
|
15
|
+
}
|
|
16
|
+
declare function populateGlobal(global: any, win: any, options?: PopulateOptions): {
|
|
17
|
+
keys: Set<string>;
|
|
18
|
+
skipKeys: string[];
|
|
19
|
+
originals: Map<string | symbol, any>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { Environment, environments as builtinEnvironments, populateGlobal };
|