vitest 2.1.3 → 2.1.4
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 +1 -209
- package/dist/browser.d.ts +21 -21
- package/dist/browser.js +7 -7
- package/dist/chunks/{RandomSequencer.Bh5-tlNJ.js → RandomSequencer.CMRlh2v4.js} +143 -142
- package/dist/chunks/{base.BO5Jx7vw.js → base.C3xNdjV6.js} +3 -3
- package/dist/chunks/{benchmark.C8CRJYG4.js → benchmark.Cdu9hjj4.js} +2 -2
- package/dist/chunks/{benchmark.JVlTzojj.d.ts → benchmark.geERunq4.d.ts} +1 -1
- package/dist/chunks/{cac.BSMVokHR.js → cac.DrfPaMvZ.js} +11 -10
- package/dist/chunks/{cli-api.btGgw3PC.js → cli-api.CKrRYkw8.js} +732 -577
- package/dist/chunks/{console.CfT1Wjed.js → console.BYGVloWk.js} +2 -6
- package/dist/chunks/{coverage.zlNdAMHK.js → coverage.BoMDb1ip.js} +1 -1
- package/dist/chunks/{creator.CBPphXqR.js → creator.IIqd8RWT.js} +8 -8
- package/dist/chunks/{execute._eQQfgI8.js → execute.2pr0rHgK.js} +8 -6
- package/dist/chunks/{globals.Bdzt04Qm.js → globals.Bp645TTJ.js} +8 -13
- package/dist/chunks/{index.BpSiYbpB.js → index.68735LiX.js} +28 -5
- package/dist/chunks/{index.X0nbfr6-.js → index.BJDntFik.js} +7 -7
- package/dist/chunks/{index.Dz2opmmU.js → index.Bn81VaWg.js} +3808 -3787
- package/dist/chunks/{index.CPD77dLA.js → index.CqYx2Nsr.js} +7 -7
- package/dist/chunks/{index.4GFF2h22.js → index.D3d79vc8.js} +6 -6
- package/dist/chunks/index.Dqe5k2Rk.js +54 -0
- package/dist/chunks/{node.Bx4JZjMG.js → node.AKq966Jp.js} +1 -5
- package/dist/chunks/{reporters.C4ZHgdxQ.d.ts → reporters.anwo7Y6a.d.ts} +1328 -1313
- package/dist/chunks/{resolveConfig.Dha6ilPI.js → resolveConfig.DPmbhVlP.js} +3193 -3175
- package/dist/chunks/{rpc.B7Mfb-Yf.js → rpc.C3q9uwRX.js} +2 -2
- package/dist/chunks/{run-once.Sxe67Wng.js → run-once.2ogXb3JV.js} +1 -1
- package/dist/chunks/{runBaseTests.Cx4wXyTR.js → runBaseTests.Dm-659zB.js} +21 -25
- package/dist/chunks/{setup-common.BKyF15v_.js → setup-common.DDmVKp6O.js} +3 -3
- package/dist/chunks/{suite.BMWOKiTe.d.ts → suite.B2jumIFP.d.ts} +2 -2
- package/dist/chunks/{utils.CY6Spixo.js → utils.BB4zjzR8.js} +2 -2
- package/dist/chunks/utils.C8RiOc4B.js +77 -0
- package/dist/chunks/{vi.BskyZC5g.js → vi.JMQoNY_Z.js} +94 -141
- package/dist/chunks/{vite.YH7MrecS.d.ts → vite.BdBj-UWY.d.ts} +1 -1
- package/dist/chunks/{vm.DB_hLchi.js → vm.jpyrB0xy.js} +5 -8
- package/dist/chunks/{worker.B6RjTtbk.d.ts → worker.BAlI9hII.d.ts} +12 -3
- package/dist/chunks/{worker.CcJLfX8w.d.ts → worker.DHnGaO2M.d.ts} +1 -1
- package/dist/cli.js +3 -4
- package/dist/config.cjs +4 -4
- package/dist/config.d.ts +10 -10
- package/dist/config.js +4 -4
- package/dist/coverage.d.ts +9 -9
- package/dist/coverage.js +8 -11
- package/dist/environments.d.ts +2 -2
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +53 -53
- package/dist/execute.js +7 -6
- package/dist/index.d.ts +75 -1099
- package/dist/index.js +7 -18
- package/dist/node.d.ts +43 -41
- package/dist/node.js +22 -28
- package/dist/path.js +1 -1
- package/dist/reporters.d.ts +10 -10
- package/dist/reporters.js +12 -18
- package/dist/runners.d.ts +12 -19
- package/dist/runners.js +142 -148
- package/dist/snapshot.js +2 -6
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +2 -6
- package/dist/worker.js +5 -6
- package/dist/workers/forks.js +9 -8
- package/dist/workers/runVmTests.js +16 -20
- package/dist/workers/threads.js +9 -8
- package/dist/workers/vmForks.js +9 -12
- package/dist/workers/vmThreads.js +9 -12
- package/dist/workers.d.ts +13 -13
- package/dist/workers.js +14 -18
- package/package.json +26 -26
- package/dist/chunks/base.DwXGwWst.js +0 -89
- package/dist/chunks/env.CmHVDJnw.js +0 -7
- package/dist/chunks/index.-d_XpZEA.js +0 -140
- package/dist/chunks/index.CxRxs566.js +0 -23
- package/dist/chunks/tasks.BZnCS9aT.js +0 -18
- package/dist/chunks/utils.Ck2hJTRs.js +0 -23
- package/dist/chunks/{environment.CzISCQ7o.d.ts → environment.LoooBwUu.d.ts} +24 -24
- package/dist/chunks/{index.lVXYBqEP.js → index.BMoXz_-n.js} +186 -186
|
@@ -1,261 +1,132 @@
|
|
|
1
|
+
import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.Crbj2GAb.js';
|
|
2
|
+
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
|
1
3
|
import * as _vitest_runner from '@vitest/runner';
|
|
2
|
-
import { File,
|
|
4
|
+
import { File, TaskResultPack, Task, Test, Suite, CancelReason, Custom, TaskMeta, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
|
|
5
|
+
import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
|
|
3
6
|
import * as vite from 'vite';
|
|
4
7
|
import { ViteDevServer, TransformResult as TransformResult$1, ServerOptions, DepOptimizationConfig, AliasOptions, UserConfig as UserConfig$1, ConfigEnv } from 'vite';
|
|
5
|
-
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
|
6
|
-
import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.Crbj2GAb.js';
|
|
7
8
|
import { RawSourceMap, ViteNodeServerOptions } from 'vite-node';
|
|
8
|
-
import
|
|
9
|
-
import { b as Awaitable,
|
|
9
|
+
import * as chai from 'chai';
|
|
10
|
+
import { b as Awaitable, U as UserConsoleLog, P as ProvidedContext, A as AfterSuiteRunMeta, c as Arrayable$1, f as EnvironmentOptions, d as ArgumentsType, O as OnServerRestartHandler } from './environment.LoooBwUu.js';
|
|
10
11
|
import { Writable } from 'node:stream';
|
|
12
|
+
import { ParsedStack, Awaitable as Awaitable$1, ErrorWithDiff, TestError, Arrayable } from '@vitest/utils';
|
|
13
|
+
import { StackTraceParserOptions } from '@vitest/utils/source-map';
|
|
11
14
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
12
|
-
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
13
15
|
import { ViteNodeServer } from 'vite-node/server';
|
|
14
|
-
import {
|
|
15
|
-
import { StackTraceParserOptions } from '@vitest/utils/source-map';
|
|
16
|
+
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
16
17
|
import { Stats } from 'node:fs';
|
|
17
|
-
import
|
|
18
|
-
import { B as BenchmarkResult } from './benchmark.JVlTzojj.js';
|
|
18
|
+
import { B as BenchmarkResult } from './benchmark.geERunq4.js';
|
|
19
19
|
|
|
20
|
-
type
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
* Test files are run parallel using `node:child_process` [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
48
|
-
*
|
|
49
|
-
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
50
|
-
*/
|
|
51
|
-
vmForks?: ForksOptions & VmOptions;
|
|
20
|
+
type SerializedTestSpecification = [
|
|
21
|
+
project: {
|
|
22
|
+
name: string | undefined;
|
|
23
|
+
root: string;
|
|
24
|
+
},
|
|
25
|
+
file: string,
|
|
26
|
+
options: {
|
|
27
|
+
pool: string;
|
|
28
|
+
}
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
|
|
32
|
+
|
|
33
|
+
interface Reporter {
|
|
34
|
+
onInit?: (ctx: Vitest) => void;
|
|
35
|
+
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
36
|
+
onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable<void>;
|
|
37
|
+
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
38
|
+
onFinished?: (files: File[], errors: unknown[], coverage?: unknown) => Awaitable<void>;
|
|
39
|
+
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
40
|
+
onTestRemoved?: (trigger?: string) => Awaitable<void>;
|
|
41
|
+
onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
42
|
+
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
43
|
+
onServerRestart?: (reason?: string) => Awaitable<void>;
|
|
44
|
+
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
45
|
+
onProcessTimeout?: () => Awaitable<void>;
|
|
52
46
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
vmThreads?: ResolvedThreadsOptions & VmOptions;
|
|
57
|
-
vmForks?: ResolvedForksOptions & VmOptions;
|
|
47
|
+
|
|
48
|
+
interface BaseOptions {
|
|
49
|
+
isTTY?: boolean;
|
|
58
50
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
51
|
+
declare abstract class BaseReporter implements Reporter {
|
|
52
|
+
start: number;
|
|
53
|
+
end: number;
|
|
54
|
+
watchFilters?: string[];
|
|
55
|
+
failedUnwatchedFiles: Task[];
|
|
56
|
+
isTTY: boolean;
|
|
57
|
+
ctx: Vitest;
|
|
58
|
+
protected verbose: boolean;
|
|
59
|
+
private _filesInWatchMode;
|
|
60
|
+
private _lastRunTimeout;
|
|
61
|
+
private _lastRunTimer;
|
|
62
|
+
private _lastRunCount;
|
|
63
|
+
private _timeStart;
|
|
64
|
+
private _offUnhandledRejection?;
|
|
65
|
+
constructor(options?: BaseOptions);
|
|
66
|
+
get mode(): VitestRunMode;
|
|
67
|
+
onInit(ctx: Vitest): void;
|
|
68
|
+
relative(path: string): string;
|
|
69
|
+
onFinished(files?: File[], errors?: unknown[]): void;
|
|
70
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
71
|
+
protected printTask(task: Task): void;
|
|
72
|
+
private getDurationPrefix;
|
|
73
|
+
onWatcherStart(files?: File[], errors?: unknown[]): void;
|
|
74
|
+
private resetLastRunLog;
|
|
75
|
+
onWatcherRerun(files: string[], trigger?: string): void;
|
|
76
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
77
|
+
shouldLog(log: UserConsoleLog): boolean;
|
|
78
|
+
onServerRestart(reason?: string): void;
|
|
79
|
+
reportSummary(files: File[], errors: unknown[]): void;
|
|
80
|
+
reportTestSummary(files: File[], errors: unknown[]): void;
|
|
81
|
+
private printErrorsSummary;
|
|
82
|
+
reportBenchmarkSummary(files: File[]): void;
|
|
83
|
+
private printTaskErrors;
|
|
84
|
+
registerUnhandledRejection(): void;
|
|
78
85
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
|
|
87
|
+
interface ParsedFile extends File {
|
|
88
|
+
start: number;
|
|
89
|
+
end: number;
|
|
82
90
|
}
|
|
83
|
-
interface
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
/** Maximum amount of child processes to use */
|
|
87
|
-
maxForks?: number | string;
|
|
88
|
-
/**
|
|
89
|
-
* Run tests inside a single fork.
|
|
90
|
-
*
|
|
91
|
-
* @default false
|
|
92
|
-
*/
|
|
93
|
-
singleFork?: boolean;
|
|
91
|
+
interface ParsedTest extends Test {
|
|
92
|
+
start: number;
|
|
93
|
+
end: number;
|
|
94
94
|
}
|
|
95
|
-
interface
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
interface ParsedSuite extends Suite {
|
|
96
|
+
start: number;
|
|
97
|
+
end: number;
|
|
98
98
|
}
|
|
99
|
-
interface
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
108
|
-
*
|
|
109
|
-
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
110
|
-
*
|
|
111
|
-
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
112
|
-
*
|
|
113
|
-
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
114
|
-
*
|
|
115
|
-
* @default [] // no execution arguments are passed
|
|
116
|
-
*/
|
|
117
|
-
execArgv?: string[];
|
|
99
|
+
interface LocalCallDefinition {
|
|
100
|
+
start: number;
|
|
101
|
+
end: number;
|
|
102
|
+
name: string;
|
|
103
|
+
type: 'suite' | 'test';
|
|
104
|
+
mode: 'run' | 'skip' | 'only' | 'todo';
|
|
105
|
+
task: ParsedSuite | ParsedFile | ParsedTest;
|
|
118
106
|
}
|
|
119
|
-
interface
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
/** Isolation is always enabled */
|
|
126
|
-
isolate?: true;
|
|
127
|
-
/**
|
|
128
|
-
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
129
|
-
*
|
|
130
|
-
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
131
|
-
*
|
|
132
|
-
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
133
|
-
*
|
|
134
|
-
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
135
|
-
*
|
|
136
|
-
* @default [] // no execution arguments are passed
|
|
137
|
-
*/
|
|
138
|
-
execArgv?: string[];
|
|
107
|
+
interface FileInformation {
|
|
108
|
+
file: File;
|
|
109
|
+
filepath: string;
|
|
110
|
+
parsed: string;
|
|
111
|
+
map: RawSourceMap | null;
|
|
112
|
+
definitions: LocalCallDefinition[];
|
|
139
113
|
}
|
|
140
114
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
// Write output but don't hide the cursor
|
|
150
|
-
const log = createLogUpdate(process.stdout, {
|
|
151
|
-
showCursor: true
|
|
152
|
-
});
|
|
153
|
-
```
|
|
154
|
-
*/
|
|
155
|
-
readonly showCursor?: boolean;
|
|
115
|
+
type RawErrsMap = Map<string, TscErrorInfo[]>;
|
|
116
|
+
interface TscErrorInfo {
|
|
117
|
+
filePath: string;
|
|
118
|
+
errCode: number;
|
|
119
|
+
errMsg: string;
|
|
120
|
+
line: number;
|
|
121
|
+
column: number;
|
|
156
122
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
Persist the logged output. Useful if you want to start a new log session below the current one.
|
|
166
|
-
*/
|
|
167
|
-
done(): void;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
Log to `stdout` by overwriting the previous output in the terminal.
|
|
172
|
-
|
|
173
|
-
@param text - The text to log to `stdout`.
|
|
174
|
-
|
|
175
|
-
@example
|
|
176
|
-
```
|
|
177
|
-
import logUpdate from 'log-update';
|
|
178
|
-
|
|
179
|
-
const frames = ['-', '\\', '|', '/'];
|
|
180
|
-
let index = 0;
|
|
181
|
-
|
|
182
|
-
setInterval(() => {
|
|
183
|
-
const frame = frames[index = ++index % frames.length];
|
|
184
|
-
|
|
185
|
-
logUpdate(
|
|
186
|
-
`
|
|
187
|
-
♥♥
|
|
188
|
-
${frame} unicorns ${frame}
|
|
189
|
-
♥♥
|
|
190
|
-
`
|
|
191
|
-
);
|
|
192
|
-
}, 80);
|
|
193
|
-
```
|
|
194
|
-
*/
|
|
195
|
-
declare const logUpdate: ((...text: string[]) => void) & LogUpdateMethods;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
Get a `logUpdate` method that logs to the specified stream.
|
|
200
|
-
|
|
201
|
-
@param stream - The stream to log to.
|
|
202
|
-
|
|
203
|
-
@example
|
|
204
|
-
```
|
|
205
|
-
import {createLogUpdate} from 'log-update';
|
|
206
|
-
|
|
207
|
-
// Write output but don't hide the cursor
|
|
208
|
-
const log = createLogUpdate(process.stdout);
|
|
209
|
-
```
|
|
210
|
-
*/
|
|
211
|
-
declare function createLogUpdate(
|
|
212
|
-
stream: NodeJS.WritableStream,
|
|
213
|
-
options?: Options
|
|
214
|
-
): typeof logUpdate;
|
|
215
|
-
|
|
216
|
-
interface ParsedFile extends File {
|
|
217
|
-
start: number;
|
|
218
|
-
end: number;
|
|
219
|
-
}
|
|
220
|
-
interface ParsedTest extends Test {
|
|
221
|
-
start: number;
|
|
222
|
-
end: number;
|
|
223
|
-
}
|
|
224
|
-
interface ParsedSuite extends Suite {
|
|
225
|
-
start: number;
|
|
226
|
-
end: number;
|
|
227
|
-
}
|
|
228
|
-
interface LocalCallDefinition {
|
|
229
|
-
start: number;
|
|
230
|
-
end: number;
|
|
231
|
-
name: string;
|
|
232
|
-
type: 'suite' | 'test';
|
|
233
|
-
mode: 'run' | 'skip' | 'only' | 'todo';
|
|
234
|
-
task: ParsedSuite | ParsedFile | ParsedTest;
|
|
235
|
-
}
|
|
236
|
-
interface FileInformation {
|
|
237
|
-
file: File;
|
|
238
|
-
filepath: string;
|
|
239
|
-
parsed: string;
|
|
240
|
-
map: RawSourceMap | null;
|
|
241
|
-
definitions: LocalCallDefinition[];
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
type RawErrsMap = Map<string, TscErrorInfo[]>;
|
|
245
|
-
interface TscErrorInfo {
|
|
246
|
-
filePath: string;
|
|
247
|
-
errCode: number;
|
|
248
|
-
errMsg: string;
|
|
249
|
-
line: number;
|
|
250
|
-
column: number;
|
|
251
|
-
}
|
|
252
|
-
interface CollectLineNumbers {
|
|
253
|
-
target: number;
|
|
254
|
-
next: number;
|
|
255
|
-
prev?: number;
|
|
256
|
-
}
|
|
257
|
-
type CollectLines = {
|
|
258
|
-
[key in keyof CollectLineNumbers]: string;
|
|
123
|
+
interface CollectLineNumbers {
|
|
124
|
+
target: number;
|
|
125
|
+
next: number;
|
|
126
|
+
prev?: number;
|
|
127
|
+
}
|
|
128
|
+
type CollectLines = {
|
|
129
|
+
[key in keyof CollectLineNumbers]: string;
|
|
259
130
|
};
|
|
260
131
|
interface RootAndTarget {
|
|
261
132
|
root: string;
|
|
@@ -326,6 +197,81 @@ interface PrintErrorResult {
|
|
|
326
197
|
nearest?: ParsedStack;
|
|
327
198
|
}
|
|
328
199
|
|
|
200
|
+
interface Options {
|
|
201
|
+
/**
|
|
202
|
+
Show the cursor. This can be useful when a CLI accepts input from a user.
|
|
203
|
+
|
|
204
|
+
@example
|
|
205
|
+
```
|
|
206
|
+
import {createLogUpdate} from 'log-update';
|
|
207
|
+
|
|
208
|
+
// Write output but don't hide the cursor
|
|
209
|
+
const log = createLogUpdate(process.stdout, {
|
|
210
|
+
showCursor: true
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
*/
|
|
214
|
+
readonly showCursor?: boolean;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
type LogUpdateMethods = {
|
|
218
|
+
/**
|
|
219
|
+
Clear the logged output.
|
|
220
|
+
*/
|
|
221
|
+
clear(): void;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
Persist the logged output. Useful if you want to start a new log session below the current one.
|
|
225
|
+
*/
|
|
226
|
+
done(): void;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
Log to `stdout` by overwriting the previous output in the terminal.
|
|
231
|
+
|
|
232
|
+
@param text - The text to log to `stdout`.
|
|
233
|
+
|
|
234
|
+
@example
|
|
235
|
+
```
|
|
236
|
+
import logUpdate from 'log-update';
|
|
237
|
+
|
|
238
|
+
const frames = ['-', '\\', '|', '/'];
|
|
239
|
+
let index = 0;
|
|
240
|
+
|
|
241
|
+
setInterval(() => {
|
|
242
|
+
const frame = frames[index = ++index % frames.length];
|
|
243
|
+
|
|
244
|
+
logUpdate(
|
|
245
|
+
`
|
|
246
|
+
♥♥
|
|
247
|
+
${frame} unicorns ${frame}
|
|
248
|
+
♥♥
|
|
249
|
+
`
|
|
250
|
+
);
|
|
251
|
+
}, 80);
|
|
252
|
+
```
|
|
253
|
+
*/
|
|
254
|
+
declare const logUpdate: ((...text: string[]) => void) & LogUpdateMethods;
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
Get a `logUpdate` method that logs to the specified stream.
|
|
259
|
+
|
|
260
|
+
@param stream - The stream to log to.
|
|
261
|
+
|
|
262
|
+
@example
|
|
263
|
+
```
|
|
264
|
+
import {createLogUpdate} from 'log-update';
|
|
265
|
+
|
|
266
|
+
// Write output but don't hide the cursor
|
|
267
|
+
const log = createLogUpdate(process.stdout);
|
|
268
|
+
```
|
|
269
|
+
*/
|
|
270
|
+
declare function createLogUpdate(
|
|
271
|
+
stream: NodeJS.WritableStream,
|
|
272
|
+
options?: Options
|
|
273
|
+
): typeof logUpdate;
|
|
274
|
+
|
|
329
275
|
interface ErrorOptions {
|
|
330
276
|
type?: string;
|
|
331
277
|
fullStack?: boolean;
|
|
@@ -488,8 +434,13 @@ interface BrowserConfigOptions {
|
|
|
488
434
|
screenshotFailures?: boolean;
|
|
489
435
|
/**
|
|
490
436
|
* Scripts injected into the tester iframe.
|
|
437
|
+
* @deprecated Will be removed in the future, use `testerHtmlPath` instead.
|
|
491
438
|
*/
|
|
492
439
|
testerScripts?: BrowserScript[];
|
|
440
|
+
/**
|
|
441
|
+
* Path to the index.html file that will be used to run tests.
|
|
442
|
+
*/
|
|
443
|
+
testerHtmlPath?: string;
|
|
493
444
|
/**
|
|
494
445
|
* Scripts injected into the main window.
|
|
495
446
|
*/
|
|
@@ -579,50 +530,6 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
|
579
530
|
};
|
|
580
531
|
}
|
|
581
532
|
|
|
582
|
-
declare class TestProject {
|
|
583
|
-
/**
|
|
584
|
-
* The global vitest instance.
|
|
585
|
-
* @experimental The public Vitest API is experimental and does not follow semver.
|
|
586
|
-
*/
|
|
587
|
-
readonly vitest: Vitest;
|
|
588
|
-
/**
|
|
589
|
-
* The workspace project this test project is associated with.
|
|
590
|
-
* @experimental The public Vitest API is experimental and does not follow semver.
|
|
591
|
-
*/
|
|
592
|
-
readonly workspaceProject: WorkspaceProject;
|
|
593
|
-
/**
|
|
594
|
-
* Resolved project configuration.
|
|
595
|
-
*/
|
|
596
|
-
readonly config: ResolvedProjectConfig;
|
|
597
|
-
/**
|
|
598
|
-
* Resolved global configuration. If there are no workspace projects, this will be the same as `config`.
|
|
599
|
-
*/
|
|
600
|
-
readonly globalConfig: ResolvedConfig;
|
|
601
|
-
/**
|
|
602
|
-
* The name of the project or an empty string if not set.
|
|
603
|
-
*/
|
|
604
|
-
readonly name: string;
|
|
605
|
-
constructor(workspaceProject: WorkspaceProject);
|
|
606
|
-
/**
|
|
607
|
-
* Serialized project configuration. This is the config that tests receive.
|
|
608
|
-
*/
|
|
609
|
-
get serializedConfig(): SerializedConfig;
|
|
610
|
-
/**
|
|
611
|
-
* Custom context provided to the project.
|
|
612
|
-
*/
|
|
613
|
-
context(): ProvidedContext;
|
|
614
|
-
/**
|
|
615
|
-
* Provide a custom serializable context to the project. This context will be available for tests once they run.
|
|
616
|
-
*/
|
|
617
|
-
provide<T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]): void;
|
|
618
|
-
toJSON(): SerializedTestProject;
|
|
619
|
-
}
|
|
620
|
-
interface SerializedTestProject {
|
|
621
|
-
name: string;
|
|
622
|
-
serializedConfig: SerializedConfig;
|
|
623
|
-
context: ProvidedContext;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
533
|
interface InitializeProjectOptions extends UserWorkspaceConfig {
|
|
627
534
|
workspaceConfigPath: string;
|
|
628
535
|
extends?: string;
|
|
@@ -681,90 +588,39 @@ declare class WorkspaceProject {
|
|
|
681
588
|
initBrowserProvider(): Promise<void>;
|
|
682
589
|
}
|
|
683
590
|
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
options:
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
591
|
+
interface BlobOptions {
|
|
592
|
+
outputFile?: string;
|
|
593
|
+
}
|
|
594
|
+
declare class BlobReporter implements Reporter {
|
|
595
|
+
ctx: Vitest;
|
|
596
|
+
options: BlobOptions;
|
|
597
|
+
constructor(options: BlobOptions);
|
|
598
|
+
onInit(ctx: Vitest): void;
|
|
599
|
+
onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
|
|
600
|
+
}
|
|
694
601
|
|
|
695
|
-
|
|
602
|
+
interface HTMLOptions {
|
|
603
|
+
outputFile?: string;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
declare class ReportedTaskImplementation {
|
|
696
607
|
/**
|
|
697
|
-
*
|
|
608
|
+
* Task instance.
|
|
609
|
+
* @experimental Public runner task API is experimental and does not follow semver.
|
|
698
610
|
*/
|
|
699
|
-
readonly
|
|
611
|
+
readonly task: Task;
|
|
700
612
|
/**
|
|
701
|
-
*
|
|
613
|
+
* The project assosiacted with the test or suite.
|
|
702
614
|
*/
|
|
703
|
-
readonly
|
|
615
|
+
readonly project: TestProject;
|
|
704
616
|
/**
|
|
705
|
-
*
|
|
617
|
+
* Unique identifier.
|
|
618
|
+
* This ID is deterministic and will be the same for the same test across multiple runs.
|
|
619
|
+
* The ID is based on the project name, module url and test position.
|
|
706
620
|
*/
|
|
707
|
-
readonly
|
|
708
|
-
pool: Pool;
|
|
709
|
-
};
|
|
710
|
-
readonly project: TestProject;
|
|
711
|
-
readonly moduleId: string;
|
|
712
|
-
readonly pool: Pool;
|
|
713
|
-
constructor(workspaceProject: WorkspaceProject, moduleId: string, pool: Pool);
|
|
714
|
-
toJSON(): SerializedTestSpecification;
|
|
621
|
+
readonly id: string;
|
|
715
622
|
/**
|
|
716
|
-
*
|
|
717
|
-
* @deprecated
|
|
718
|
-
*/
|
|
719
|
-
[Symbol.iterator](): Generator<string | WorkspaceProject, void, unknown>;
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
/**
|
|
723
|
-
* @deprecated use TestSpecification instead
|
|
724
|
-
*/
|
|
725
|
-
type WorkspaceSpec = TestSpecification & [
|
|
726
|
-
/**
|
|
727
|
-
* @deprecated use spec.project instead
|
|
728
|
-
*/
|
|
729
|
-
project: WorkspaceProject,
|
|
730
|
-
/**
|
|
731
|
-
* @deprecated use spec.moduleId instead
|
|
732
|
-
*/
|
|
733
|
-
file: string,
|
|
734
|
-
/**
|
|
735
|
-
* @deprecated use spec.pool instead
|
|
736
|
-
*/
|
|
737
|
-
options: {
|
|
738
|
-
pool: Pool;
|
|
739
|
-
}
|
|
740
|
-
];
|
|
741
|
-
type RunWithFiles = (files: WorkspaceSpec[], invalidates?: string[]) => Awaitable$1<void>;
|
|
742
|
-
interface ProcessPool {
|
|
743
|
-
name: string;
|
|
744
|
-
runTests: RunWithFiles;
|
|
745
|
-
collectTests: RunWithFiles;
|
|
746
|
-
close?: () => Awaitable$1<void>;
|
|
747
|
-
}
|
|
748
|
-
declare function getFilePoolName(project: WorkspaceProject, file: string): Pool;
|
|
749
|
-
|
|
750
|
-
declare class ReportedTaskImplementation {
|
|
751
|
-
/**
|
|
752
|
-
* Task instance.
|
|
753
|
-
* @experimental Public runner task API is experimental and does not follow semver.
|
|
754
|
-
*/
|
|
755
|
-
readonly task: Task;
|
|
756
|
-
/**
|
|
757
|
-
* The project assosiacted with the test or suite.
|
|
758
|
-
*/
|
|
759
|
-
readonly project: TestProject;
|
|
760
|
-
/**
|
|
761
|
-
* Unique identifier.
|
|
762
|
-
* This ID is deterministic and will be the same for the same test across multiple runs.
|
|
763
|
-
* The ID is based on the project name, module url and test position.
|
|
764
|
-
*/
|
|
765
|
-
readonly id: string;
|
|
766
|
-
/**
|
|
767
|
-
* Location in the module where the test or suite is defined.
|
|
623
|
+
* Location in the module where the test or suite is defined.
|
|
768
624
|
*/
|
|
769
625
|
readonly location: {
|
|
770
626
|
line: number;
|
|
@@ -948,6 +804,10 @@ interface TestResultSkipped {
|
|
|
948
804
|
errors: undefined;
|
|
949
805
|
}
|
|
950
806
|
interface TestDiagnostic {
|
|
807
|
+
/**
|
|
808
|
+
* If the duration of the test is above `slowTestThreshold`.
|
|
809
|
+
*/
|
|
810
|
+
slow: boolean;
|
|
951
811
|
/**
|
|
952
812
|
* The amount of memory used by the test in bytes.
|
|
953
813
|
* This value is only available if the test was executed with `logHeapUsage` flag.
|
|
@@ -999,266 +859,500 @@ interface ModuleDiagnostic {
|
|
|
999
859
|
duration: number;
|
|
1000
860
|
}
|
|
1001
861
|
|
|
1002
|
-
declare class
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
idMap: Map<string, Task>;
|
|
1006
|
-
taskFileMap: WeakMap<Task, File>;
|
|
1007
|
-
errorsSet: Set<unknown>;
|
|
1008
|
-
processTimeoutCauses: Set<string>;
|
|
1009
|
-
reportedTasksMap: WeakMap<Task, TestCase | TestSuite | TestModule>;
|
|
1010
|
-
catchError(err: unknown, type: string): void;
|
|
1011
|
-
clearErrors(): void;
|
|
1012
|
-
getUnhandledErrors(): unknown[];
|
|
1013
|
-
addProcessTimeoutCause(cause: string): void;
|
|
1014
|
-
getProcessTimeoutCauses(): string[];
|
|
1015
|
-
getPaths(): string[];
|
|
1016
|
-
/**
|
|
1017
|
-
* Return files that were running or collected.
|
|
1018
|
-
*/
|
|
1019
|
-
getFiles(keys?: string[]): File[];
|
|
1020
|
-
getFilepaths(): string[];
|
|
1021
|
-
getFailedFilepaths(): string[];
|
|
1022
|
-
collectPaths(paths?: string[]): void;
|
|
1023
|
-
collectFiles(project: WorkspaceProject, files?: File[]): void;
|
|
1024
|
-
clearFiles(project: WorkspaceProject, paths?: string[]): void;
|
|
1025
|
-
updateId(task: Task, project: WorkspaceProject): void;
|
|
1026
|
-
getReportedEntity(task: Task): TestCase | TestSuite | TestModule | undefined;
|
|
1027
|
-
updateTasks(packs: TaskResultPack[]): void;
|
|
1028
|
-
updateUserLog(log: UserConsoleLog): void;
|
|
1029
|
-
getCountOfFailedTests(): number;
|
|
1030
|
-
cancelFiles(files: string[], project: WorkspaceProject): void;
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
interface SuiteResultCache {
|
|
1034
|
-
failed: boolean;
|
|
1035
|
-
duration: number;
|
|
1036
|
-
}
|
|
1037
|
-
declare class ResultsCache {
|
|
1038
|
-
private cache;
|
|
1039
|
-
private workspacesKeyMap;
|
|
1040
|
-
private cachePath;
|
|
1041
|
-
private version;
|
|
1042
|
-
private root;
|
|
1043
|
-
constructor(version: string);
|
|
1044
|
-
getCachePath(): string | null;
|
|
1045
|
-
setConfig(root: string, config: ResolvedConfig['cache']): void;
|
|
1046
|
-
getResults(key: string): SuiteResultCache | undefined;
|
|
1047
|
-
readFromCache(): Promise<void>;
|
|
1048
|
-
updateResults(files: File[]): void;
|
|
1049
|
-
removeFromCache(filepath: string): void;
|
|
1050
|
-
writeToCache(): Promise<void>;
|
|
862
|
+
declare class BasicReporter extends BaseReporter {
|
|
863
|
+
constructor();
|
|
864
|
+
reportSummary(files: File[], errors: unknown[]): void;
|
|
1051
865
|
}
|
|
1052
866
|
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
removeStats(fsPath: string): void;
|
|
867
|
+
interface ListRendererOptions {
|
|
868
|
+
renderSucceed?: boolean;
|
|
869
|
+
logger: Logger;
|
|
870
|
+
showHeap: boolean;
|
|
871
|
+
slowTestThreshold: number;
|
|
872
|
+
mode: VitestRunMode;
|
|
1060
873
|
}
|
|
874
|
+
declare function createListRenderer(_tasks: Task[], options: ListRendererOptions): {
|
|
875
|
+
start(): any;
|
|
876
|
+
update(_tasks: Task[]): any;
|
|
877
|
+
stop(): any;
|
|
878
|
+
clear(): void;
|
|
879
|
+
};
|
|
1061
880
|
|
|
1062
|
-
declare class
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
881
|
+
declare class DefaultReporter extends BaseReporter {
|
|
882
|
+
renderer?: ReturnType<typeof createListRenderer>;
|
|
883
|
+
rendererOptions: ListRendererOptions;
|
|
884
|
+
private renderSucceedDefault?;
|
|
885
|
+
onPathsCollected(paths?: string[]): void;
|
|
886
|
+
onTestRemoved(trigger?: string): Promise<void>;
|
|
887
|
+
onCollected(): void;
|
|
888
|
+
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): void;
|
|
889
|
+
onWatcherStart(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
890
|
+
stopListRender(): void;
|
|
891
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
892
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1071
893
|
}
|
|
1072
894
|
|
|
1073
|
-
|
|
1074
|
-
|
|
895
|
+
interface DotRendererOptions {
|
|
896
|
+
logger: Logger;
|
|
1075
897
|
}
|
|
898
|
+
declare function createDotRenderer(_tasks: Task[], options: DotRendererOptions): {
|
|
899
|
+
start(): any;
|
|
900
|
+
update(_tasks: Task[]): any;
|
|
901
|
+
stop(): Promise<any>;
|
|
902
|
+
clear(): void;
|
|
903
|
+
};
|
|
1076
904
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
905
|
+
declare class DotReporter extends BaseReporter {
|
|
906
|
+
renderer?: ReturnType<typeof createDotRenderer>;
|
|
907
|
+
onCollected(): void;
|
|
908
|
+
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
909
|
+
onWatcherStart(): Promise<void>;
|
|
910
|
+
stopListRender(): Promise<void>;
|
|
911
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
912
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1080
913
|
}
|
|
1081
914
|
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
onSummaryEnd(root: N, state: any): void;
|
|
1087
|
-
onEnd(root: N, state: any): void;
|
|
915
|
+
declare class GithubActionsReporter implements Reporter {
|
|
916
|
+
ctx: Vitest;
|
|
917
|
+
onInit(ctx: Vitest): void;
|
|
918
|
+
onFinished(files?: File[], errors?: unknown[]): void;
|
|
1088
919
|
}
|
|
1089
920
|
|
|
1090
|
-
|
|
1091
|
-
|
|
921
|
+
declare class HangingProcessReporter implements Reporter {
|
|
922
|
+
whyRunning: (() => void) | undefined;
|
|
923
|
+
onInit(): void;
|
|
924
|
+
onProcessTimeout(): void;
|
|
1092
925
|
}
|
|
1093
926
|
|
|
1094
|
-
|
|
1095
|
-
|
|
927
|
+
type Status = 'passed' | 'failed' | 'skipped' | 'pending' | 'todo' | 'disabled';
|
|
928
|
+
type Milliseconds = number;
|
|
929
|
+
interface Callsite {
|
|
930
|
+
line: number;
|
|
931
|
+
column: number;
|
|
1096
932
|
}
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
lcovonly: LcovOnlyOptions;
|
|
1107
|
-
none: never;
|
|
1108
|
-
teamcity: TeamcityOptions;
|
|
1109
|
-
text: TextOptions;
|
|
1110
|
-
"text-lcov": TextLcovOptions;
|
|
1111
|
-
"text-summary": TextSummaryOptions;
|
|
933
|
+
interface JsonAssertionResult {
|
|
934
|
+
ancestorTitles: Array<string>;
|
|
935
|
+
fullName: string;
|
|
936
|
+
status: Status;
|
|
937
|
+
title: string;
|
|
938
|
+
meta: TaskMeta;
|
|
939
|
+
duration?: Milliseconds | null;
|
|
940
|
+
failureMessages: Array<string> | null;
|
|
941
|
+
location?: Callsite | null;
|
|
1112
942
|
}
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
943
|
+
interface JsonTestResult {
|
|
944
|
+
message: string;
|
|
945
|
+
name: string;
|
|
946
|
+
status: 'failed' | 'passed';
|
|
947
|
+
startTime: number;
|
|
948
|
+
endTime: number;
|
|
949
|
+
assertionResults: Array<JsonAssertionResult>;
|
|
1120
950
|
}
|
|
1121
|
-
interface
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
951
|
+
interface JsonTestResults {
|
|
952
|
+
numFailedTests: number;
|
|
953
|
+
numFailedTestSuites: number;
|
|
954
|
+
numPassedTests: number;
|
|
955
|
+
numPassedTestSuites: number;
|
|
956
|
+
numPendingTests: number;
|
|
957
|
+
numPendingTestSuites: number;
|
|
958
|
+
numTodoTests: number;
|
|
959
|
+
numTotalTests: number;
|
|
960
|
+
numTotalTestSuites: number;
|
|
961
|
+
startTime: number;
|
|
962
|
+
success: boolean;
|
|
963
|
+
testResults: Array<JsonTestResult>;
|
|
964
|
+
snapshot: SnapshotSummary;
|
|
1126
965
|
}
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
type JsonSummaryOptions = FileOptions;
|
|
1130
|
-
|
|
1131
|
-
interface LcovOptions extends FileOptions, ProjectOptions {}
|
|
1132
|
-
interface LcovOnlyOptions extends FileOptions, ProjectOptions {}
|
|
1133
|
-
|
|
1134
|
-
interface TeamcityOptions extends FileOptions {
|
|
1135
|
-
blockName: string;
|
|
966
|
+
interface JsonOptions$1 {
|
|
967
|
+
outputFile?: string;
|
|
1136
968
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
interface LinkMapper {
|
|
1147
|
-
getPath(node: string | Node): string;
|
|
1148
|
-
relativePath(source: string | Node, target: string | Node): string;
|
|
1149
|
-
assetPath(node: Node, name: string): string;
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
type TransformResult = string | Partial<TransformResult$1> | undefined | null | void;
|
|
1153
|
-
type CoverageResults = unknown;
|
|
1154
|
-
interface CoverageProvider {
|
|
1155
|
-
name: string;
|
|
1156
|
-
/** Called when provider is being initialized before tests run */
|
|
1157
|
-
initialize: (ctx: Vitest) => Promise<void> | void;
|
|
1158
|
-
/** Called when setting coverage options for Vitest context (`ctx.config.coverage`) */
|
|
1159
|
-
resolveOptions: () => ResolvedCoverageOptions;
|
|
1160
|
-
/** Callback to clean previous reports */
|
|
1161
|
-
clean: (clean?: boolean) => void | Promise<void>;
|
|
1162
|
-
/** Called with coverage results after a single test file has been run */
|
|
1163
|
-
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void | Promise<void>;
|
|
1164
|
-
/** Callback called when test run fails */
|
|
1165
|
-
onTestFailure?: () => void | Promise<void>;
|
|
1166
|
-
/** Callback to generate final coverage results */
|
|
1167
|
-
generateCoverage: (reportContext: ReportContext) => CoverageResults | Promise<CoverageResults>;
|
|
1168
|
-
/** Callback to convert coverage results to coverage reports. Called with results returned from `generateCoverage` */
|
|
1169
|
-
reportCoverage: (coverage: CoverageResults, reportContext: ReportContext) => void | Promise<void>;
|
|
1170
|
-
/** Callback for `--merge-reports` options. Called with multiple coverage results generated by `generateCoverage`. */
|
|
1171
|
-
mergeReports?: (coverages: CoverageResults[]) => void | Promise<void>;
|
|
1172
|
-
/** Callback called for instrumenting files with coverage counters. */
|
|
1173
|
-
onFileTransform?: (sourceCode: string, id: string, pluginCtx: any) => TransformResult | Promise<TransformResult>;
|
|
1174
|
-
}
|
|
1175
|
-
interface ReportContext {
|
|
1176
|
-
/** Indicates whether all tests were run. False when only specific tests were run. */
|
|
1177
|
-
allTestsRun?: boolean;
|
|
1178
|
-
}
|
|
1179
|
-
interface CoverageProviderModule {
|
|
1180
|
-
/**
|
|
1181
|
-
* Factory for creating a new coverage provider
|
|
1182
|
-
*/
|
|
1183
|
-
getProvider: () => CoverageProvider | Promise<CoverageProvider>;
|
|
969
|
+
declare class JsonReporter implements Reporter {
|
|
970
|
+
start: number;
|
|
971
|
+
ctx: Vitest;
|
|
972
|
+
options: JsonOptions$1;
|
|
973
|
+
constructor(options: JsonOptions$1);
|
|
974
|
+
onInit(ctx: Vitest): void;
|
|
975
|
+
protected logTasks(files: File[]): Promise<void>;
|
|
976
|
+
onFinished(files?: File[]): Promise<void>;
|
|
1184
977
|
/**
|
|
1185
|
-
*
|
|
978
|
+
* Writes the report to an output file if specified in the config,
|
|
979
|
+
* or logs it to the console otherwise.
|
|
980
|
+
* @param report
|
|
1186
981
|
*/
|
|
1187
|
-
|
|
982
|
+
writeReport(report: string): Promise<void>;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
interface JUnitOptions {
|
|
986
|
+
outputFile?: string;
|
|
987
|
+
classname?: string;
|
|
988
|
+
suiteName?: string;
|
|
1188
989
|
/**
|
|
1189
|
-
*
|
|
990
|
+
* Write <system-out> and <system-err> for console output
|
|
991
|
+
* @default true
|
|
1190
992
|
*/
|
|
1191
|
-
|
|
993
|
+
includeConsoleOutput?: boolean;
|
|
1192
994
|
/**
|
|
1193
|
-
*
|
|
995
|
+
* Add <testcase file="..."> attribute (validated on CIRCLE CI and GitLab CI)
|
|
996
|
+
* @default false
|
|
1194
997
|
*/
|
|
1195
|
-
|
|
998
|
+
addFileAttribute?: boolean;
|
|
1196
999
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1000
|
+
declare class JUnitReporter implements Reporter {
|
|
1001
|
+
private ctx;
|
|
1002
|
+
private reportFile?;
|
|
1003
|
+
private baseLog;
|
|
1004
|
+
private logger;
|
|
1005
|
+
private _timeStart;
|
|
1006
|
+
private fileFd?;
|
|
1007
|
+
private options;
|
|
1008
|
+
constructor(options: JUnitOptions);
|
|
1009
|
+
onInit(ctx: Vitest): Promise<void>;
|
|
1010
|
+
writeElement(name: string, attrs: Record<string, any>, children: () => Promise<void>): Promise<void>;
|
|
1011
|
+
writeLogs(task: Task, type: 'err' | 'out'): Promise<void>;
|
|
1012
|
+
writeTasks(tasks: Task[], filename: string): Promise<void>;
|
|
1013
|
+
onFinished(files?: _vitest_runner.File[]): Promise<void>;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
declare class TapReporter implements Reporter {
|
|
1017
|
+
protected ctx: Vitest;
|
|
1018
|
+
private logger;
|
|
1019
|
+
onInit(ctx: Vitest): void;
|
|
1020
|
+
static getComment(task: Task): string;
|
|
1021
|
+
private logErrorDetails;
|
|
1022
|
+
protected logTasks(tasks: Task[]): void;
|
|
1023
|
+
onFinished(files?: _vitest_runner.File[]): void;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
declare class TapFlatReporter extends TapReporter {
|
|
1027
|
+
onInit(ctx: Vitest): void;
|
|
1028
|
+
onFinished(files?: _vitest_runner.File[]): void;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
declare class VerboseReporter extends DefaultReporter {
|
|
1032
|
+
protected verbose: boolean;
|
|
1033
|
+
constructor();
|
|
1034
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
interface TableRendererOptions {
|
|
1038
|
+
renderSucceed?: boolean;
|
|
1039
|
+
logger: Logger;
|
|
1040
|
+
showHeap: boolean;
|
|
1041
|
+
slowTestThreshold: number;
|
|
1042
|
+
compare?: FlatBenchmarkReport;
|
|
1043
|
+
}
|
|
1044
|
+
declare function createTableRenderer(_tasks: Task[], options: TableRendererOptions): {
|
|
1045
|
+
start(): any;
|
|
1046
|
+
update(_tasks: Task[]): any;
|
|
1047
|
+
stop(): any;
|
|
1048
|
+
clear(): void;
|
|
1218
1049
|
};
|
|
1219
|
-
|
|
1050
|
+
|
|
1051
|
+
declare class TableReporter extends BaseReporter {
|
|
1052
|
+
renderer?: ReturnType<typeof createTableRenderer>;
|
|
1053
|
+
rendererOptions: TableRendererOptions;
|
|
1054
|
+
onTestRemoved(trigger?: string): void;
|
|
1055
|
+
onCollected(): Promise<void>;
|
|
1056
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1057
|
+
onFinished(files?: File[], errors?: unknown[]): Promise<void>;
|
|
1058
|
+
onWatcherStart(): Promise<void>;
|
|
1059
|
+
stopListRender(): void;
|
|
1060
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
1061
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1062
|
+
}
|
|
1063
|
+
interface FlatBenchmarkReport {
|
|
1064
|
+
[id: string]: FormattedBenchmarkResult;
|
|
1065
|
+
}
|
|
1066
|
+
type FormattedBenchmarkResult = BenchmarkResult & {
|
|
1067
|
+
id: string;
|
|
1068
|
+
};
|
|
1069
|
+
|
|
1070
|
+
declare const BenchmarkReportsMap: {
|
|
1071
|
+
default: typeof TableReporter;
|
|
1072
|
+
verbose: typeof VerboseReporter;
|
|
1073
|
+
};
|
|
1074
|
+
type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* @deprecated Use `TestModule` instead
|
|
1078
|
+
*/
|
|
1079
|
+
declare const TestFile: typeof TestModule;
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* @deprecated Use `ModuleDiagnostic` instead
|
|
1083
|
+
*/
|
|
1084
|
+
type FileDiagnostic = ModuleDiagnostic;
|
|
1085
|
+
|
|
1086
|
+
declare const ReportersMap: {
|
|
1087
|
+
default: typeof DefaultReporter;
|
|
1088
|
+
basic: typeof BasicReporter;
|
|
1089
|
+
blob: typeof BlobReporter;
|
|
1090
|
+
verbose: typeof VerboseReporter;
|
|
1091
|
+
dot: typeof DotReporter;
|
|
1092
|
+
json: typeof JsonReporter;
|
|
1093
|
+
tap: typeof TapReporter;
|
|
1094
|
+
'tap-flat': typeof TapFlatReporter;
|
|
1095
|
+
junit: typeof JUnitReporter;
|
|
1096
|
+
'hanging-process': typeof HangingProcessReporter;
|
|
1097
|
+
'github-actions': typeof GithubActionsReporter;
|
|
1098
|
+
};
|
|
1099
|
+
type BuiltinReporters = keyof typeof ReportersMap;
|
|
1100
|
+
interface BuiltinReporterOptions {
|
|
1101
|
+
'default': BaseOptions;
|
|
1102
|
+
'basic': BaseOptions;
|
|
1103
|
+
'verbose': never;
|
|
1104
|
+
'dot': BaseOptions;
|
|
1105
|
+
'json': JsonOptions$1;
|
|
1106
|
+
'blob': BlobOptions;
|
|
1107
|
+
'tap': never;
|
|
1108
|
+
'tap-flat': never;
|
|
1109
|
+
'junit': JUnitOptions;
|
|
1110
|
+
'hanging-process': never;
|
|
1111
|
+
'html': HTMLOptions;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
interface TestSequencer {
|
|
1220
1115
|
/**
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
* @default false
|
|
1116
|
+
* Slicing tests into shards. Will be run before `sort`.
|
|
1117
|
+
* Only run, if `shard` is defined.
|
|
1224
1118
|
*/
|
|
1225
|
-
|
|
1119
|
+
shard: (files: WorkspaceSpec[]) => Awaitable<WorkspaceSpec[]>;
|
|
1120
|
+
sort: (files: WorkspaceSpec[]) => Awaitable<WorkspaceSpec[]>;
|
|
1121
|
+
}
|
|
1122
|
+
interface TestSequencerConstructor {
|
|
1123
|
+
new (ctx: Vitest): TestSequencer;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
interface BenchmarkUserOptions {
|
|
1226
1127
|
/**
|
|
1227
|
-
*
|
|
1128
|
+
* Include globs for benchmark test files
|
|
1228
1129
|
*
|
|
1229
|
-
* @default ['
|
|
1130
|
+
* @default ['**\/*.{bench,benchmark}.?(c|m)[jt]s?(x)']
|
|
1230
1131
|
*/
|
|
1231
1132
|
include?: string[];
|
|
1232
1133
|
/**
|
|
1233
|
-
*
|
|
1234
|
-
*
|
|
1235
|
-
* @default ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx', '.vue', '.svelte', '.marko']
|
|
1134
|
+
* Exclude globs for benchmark test files
|
|
1135
|
+
* @default ['**\/node_modules/**', '**\/dist/**', '**\/cypress/**', '**\/.{idea,git,cache,output,temp}/**', '**\/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*']
|
|
1236
1136
|
*/
|
|
1237
|
-
|
|
1137
|
+
exclude?: string[];
|
|
1238
1138
|
/**
|
|
1239
|
-
*
|
|
1139
|
+
* Include globs for in-source benchmark test files
|
|
1240
1140
|
*
|
|
1241
|
-
* @default [
|
|
1141
|
+
* @default []
|
|
1242
1142
|
*/
|
|
1243
|
-
|
|
1143
|
+
includeSource?: string[];
|
|
1244
1144
|
/**
|
|
1245
|
-
*
|
|
1145
|
+
* Custom reporter for output. Can contain one or more built-in report names, reporter instances,
|
|
1146
|
+
* and/or paths to custom reporters
|
|
1246
1147
|
*
|
|
1247
|
-
* @default
|
|
1148
|
+
* @default ['default']
|
|
1248
1149
|
*/
|
|
1249
|
-
|
|
1150
|
+
reporters?: Arrayable<BenchmarkBuiltinReporters | Reporter>;
|
|
1250
1151
|
/**
|
|
1251
|
-
*
|
|
1252
|
-
*
|
|
1253
|
-
* @default true
|
|
1152
|
+
* @deprecated Use `benchmark.outputJson` instead
|
|
1254
1153
|
*/
|
|
1255
|
-
|
|
1154
|
+
outputFile?: string | (Partial<Record<BenchmarkBuiltinReporters, string>> & Record<string, string>);
|
|
1256
1155
|
/**
|
|
1257
|
-
*
|
|
1258
|
-
*
|
|
1259
|
-
* @default true
|
|
1156
|
+
* benchmark output file to compare against
|
|
1260
1157
|
*/
|
|
1261
|
-
|
|
1158
|
+
compare?: string;
|
|
1159
|
+
/**
|
|
1160
|
+
* benchmark output file
|
|
1161
|
+
*/
|
|
1162
|
+
outputJson?: string;
|
|
1163
|
+
/**
|
|
1164
|
+
* Include `samples` array of benchmark results for API or custom reporter usages.
|
|
1165
|
+
* This is disabled by default to reduce memory usage.
|
|
1166
|
+
* @default false
|
|
1167
|
+
*/
|
|
1168
|
+
includeSamples?: boolean;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
interface Node {
|
|
1172
|
+
isRoot(): boolean;
|
|
1173
|
+
visit(visitor: Visitor, state: any): void;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
interface Visitor<N extends Node = Node> {
|
|
1177
|
+
onStart(root: N, state: any): void;
|
|
1178
|
+
onSummary(root: N, state: any): void;
|
|
1179
|
+
onDetail(root: N, state: any): void;
|
|
1180
|
+
onSummaryEnd(root: N, state: any): void;
|
|
1181
|
+
onEnd(root: N, state: any): void;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
interface FileOptions {
|
|
1185
|
+
file: string;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
interface ProjectOptions {
|
|
1189
|
+
projectRoot: string;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
interface ReportOptions {
|
|
1193
|
+
clover: CloverOptions;
|
|
1194
|
+
cobertura: CoberturaOptions;
|
|
1195
|
+
"html-spa": HtmlSpaOptions;
|
|
1196
|
+
html: HtmlOptions;
|
|
1197
|
+
json: JsonOptions;
|
|
1198
|
+
"json-summary": JsonSummaryOptions;
|
|
1199
|
+
lcov: LcovOptions;
|
|
1200
|
+
lcovonly: LcovOnlyOptions;
|
|
1201
|
+
none: never;
|
|
1202
|
+
teamcity: TeamcityOptions;
|
|
1203
|
+
text: TextOptions;
|
|
1204
|
+
"text-lcov": TextLcovOptions;
|
|
1205
|
+
"text-summary": TextSummaryOptions;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
interface CloverOptions extends FileOptions, ProjectOptions {}
|
|
1209
|
+
|
|
1210
|
+
interface CoberturaOptions extends FileOptions, ProjectOptions {}
|
|
1211
|
+
|
|
1212
|
+
interface HtmlSpaOptions extends HtmlOptions {
|
|
1213
|
+
metricsToShow: Array<"lines" | "branches" | "functions" | "statements">;
|
|
1214
|
+
}
|
|
1215
|
+
interface HtmlOptions {
|
|
1216
|
+
verbose: boolean;
|
|
1217
|
+
skipEmpty: boolean;
|
|
1218
|
+
subdir: string;
|
|
1219
|
+
linkMapper: LinkMapper;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
type JsonOptions = FileOptions;
|
|
1223
|
+
type JsonSummaryOptions = FileOptions;
|
|
1224
|
+
|
|
1225
|
+
interface LcovOptions extends FileOptions, ProjectOptions {}
|
|
1226
|
+
interface LcovOnlyOptions extends FileOptions, ProjectOptions {}
|
|
1227
|
+
|
|
1228
|
+
interface TeamcityOptions extends FileOptions {
|
|
1229
|
+
blockName: string;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
interface TextOptions extends FileOptions {
|
|
1233
|
+
maxCols: number;
|
|
1234
|
+
skipEmpty: boolean;
|
|
1235
|
+
skipFull: boolean;
|
|
1236
|
+
}
|
|
1237
|
+
type TextLcovOptions = ProjectOptions;
|
|
1238
|
+
type TextSummaryOptions = FileOptions;
|
|
1239
|
+
|
|
1240
|
+
interface LinkMapper {
|
|
1241
|
+
getPath(node: string | Node): string;
|
|
1242
|
+
relativePath(source: string | Node, target: string | Node): string;
|
|
1243
|
+
assetPath(node: Node, name: string): string;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
type TransformResult = string | Partial<TransformResult$1> | undefined | null | void;
|
|
1247
|
+
type CoverageResults = unknown;
|
|
1248
|
+
interface CoverageProvider {
|
|
1249
|
+
name: string;
|
|
1250
|
+
/** Called when provider is being initialized before tests run */
|
|
1251
|
+
initialize: (ctx: Vitest) => Promise<void> | void;
|
|
1252
|
+
/** Called when setting coverage options for Vitest context (`ctx.config.coverage`) */
|
|
1253
|
+
resolveOptions: () => ResolvedCoverageOptions;
|
|
1254
|
+
/** Callback to clean previous reports */
|
|
1255
|
+
clean: (clean?: boolean) => void | Promise<void>;
|
|
1256
|
+
/** Called with coverage results after a single test file has been run */
|
|
1257
|
+
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void | Promise<void>;
|
|
1258
|
+
/** Callback called when test run fails */
|
|
1259
|
+
onTestFailure?: () => void | Promise<void>;
|
|
1260
|
+
/** Callback to generate final coverage results */
|
|
1261
|
+
generateCoverage: (reportContext: ReportContext) => CoverageResults | Promise<CoverageResults>;
|
|
1262
|
+
/** Callback to convert coverage results to coverage reports. Called with results returned from `generateCoverage` */
|
|
1263
|
+
reportCoverage: (coverage: CoverageResults, reportContext: ReportContext) => void | Promise<void>;
|
|
1264
|
+
/** Callback for `--merge-reports` options. Called with multiple coverage results generated by `generateCoverage`. */
|
|
1265
|
+
mergeReports?: (coverages: CoverageResults[]) => void | Promise<void>;
|
|
1266
|
+
/** Callback called for instrumenting files with coverage counters. */
|
|
1267
|
+
onFileTransform?: (sourceCode: string, id: string, pluginCtx: any) => TransformResult | Promise<TransformResult>;
|
|
1268
|
+
}
|
|
1269
|
+
interface ReportContext {
|
|
1270
|
+
/** Indicates whether all tests were run. False when only specific tests were run. */
|
|
1271
|
+
allTestsRun?: boolean;
|
|
1272
|
+
}
|
|
1273
|
+
interface CoverageProviderModule {
|
|
1274
|
+
/**
|
|
1275
|
+
* Factory for creating a new coverage provider
|
|
1276
|
+
*/
|
|
1277
|
+
getProvider: () => CoverageProvider | Promise<CoverageProvider>;
|
|
1278
|
+
/**
|
|
1279
|
+
* Executed before tests are run in the worker thread.
|
|
1280
|
+
*/
|
|
1281
|
+
startCoverage?: () => unknown | Promise<unknown>;
|
|
1282
|
+
/**
|
|
1283
|
+
* Executed on after each run in the worker thread. Possible to return a payload passed to the provider
|
|
1284
|
+
*/
|
|
1285
|
+
takeCoverage?: () => unknown | Promise<unknown>;
|
|
1286
|
+
/**
|
|
1287
|
+
* Executed after all tests have been run in the worker thread.
|
|
1288
|
+
*/
|
|
1289
|
+
stopCoverage?: () => unknown | Promise<unknown>;
|
|
1290
|
+
}
|
|
1291
|
+
type CoverageReporter = keyof ReportOptions | (string & {});
|
|
1292
|
+
type CoverageReporterWithOptions<ReporterName extends CoverageReporter = CoverageReporter> = ReporterName extends keyof ReportOptions ? ReportOptions[ReporterName] extends never ? [ReporterName, object] : [ReporterName, Partial<ReportOptions[ReporterName]>] : [ReporterName, Record<string, unknown>];
|
|
1293
|
+
type CoverageProviderName = 'v8' | 'istanbul' | 'custom' | undefined;
|
|
1294
|
+
type CoverageOptions<T extends CoverageProviderName = CoverageProviderName> = T extends 'istanbul' ? {
|
|
1295
|
+
provider: T;
|
|
1296
|
+
} & CoverageIstanbulOptions : T extends 'v8' ? {
|
|
1297
|
+
/**
|
|
1298
|
+
* Provider to use for coverage collection.
|
|
1299
|
+
*
|
|
1300
|
+
* @default 'v8'
|
|
1301
|
+
*/
|
|
1302
|
+
provider: T;
|
|
1303
|
+
} & CoverageV8Options : T extends 'custom' ? {
|
|
1304
|
+
provider: T;
|
|
1305
|
+
} & CustomProviderOptions : {
|
|
1306
|
+
provider?: T;
|
|
1307
|
+
} & CoverageV8Options;
|
|
1308
|
+
/** Fields that have default values. Internally these will always be defined. */
|
|
1309
|
+
type FieldsWithDefaultValues = 'enabled' | 'clean' | 'cleanOnRerun' | 'reportsDirectory' | 'exclude' | 'extension' | 'reportOnFailure' | 'allowExternal' | 'processingConcurrency';
|
|
1310
|
+
type ResolvedCoverageOptions<T extends CoverageProviderName = CoverageProviderName> = CoverageOptions<T> & Required<Pick<CoverageOptions<T>, FieldsWithDefaultValues>> & {
|
|
1311
|
+
reporter: CoverageReporterWithOptions[];
|
|
1312
|
+
};
|
|
1313
|
+
interface BaseCoverageOptions {
|
|
1314
|
+
/**
|
|
1315
|
+
* Enables coverage collection. Can be overridden using `--coverage` CLI option.
|
|
1316
|
+
*
|
|
1317
|
+
* @default false
|
|
1318
|
+
*/
|
|
1319
|
+
enabled?: boolean;
|
|
1320
|
+
/**
|
|
1321
|
+
* List of files included in coverage as glob patterns
|
|
1322
|
+
*
|
|
1323
|
+
* @default ['**']
|
|
1324
|
+
*/
|
|
1325
|
+
include?: string[];
|
|
1326
|
+
/**
|
|
1327
|
+
* Extensions for files to be included in coverage
|
|
1328
|
+
*
|
|
1329
|
+
* @default ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx', '.vue', '.svelte', '.marko']
|
|
1330
|
+
*/
|
|
1331
|
+
extension?: string | string[];
|
|
1332
|
+
/**
|
|
1333
|
+
* List of files excluded from coverage as glob patterns
|
|
1334
|
+
*
|
|
1335
|
+
* @default ['coverage/**', 'dist/**', '**\/[.]**', 'packages/*\/test?(s)/**', '**\/*.d.ts', '**\/virtual:*', '**\/__x00__*', '**\/\x00*', 'cypress/**', 'test?(s)/**', 'test?(-*).?(c|m)[jt]s?(x)', '**\/*{.,-}{test,spec}?(-d).?(c|m)[jt]s?(x)', '**\/__tests__/**', '**\/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*', '**\/vitest.{workspace,projects}.[jt]s?(on)', '**\/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}']
|
|
1336
|
+
*/
|
|
1337
|
+
exclude?: string[];
|
|
1338
|
+
/**
|
|
1339
|
+
* Whether to include all files, including the untested ones into report
|
|
1340
|
+
*
|
|
1341
|
+
* @default true
|
|
1342
|
+
*/
|
|
1343
|
+
all?: boolean;
|
|
1344
|
+
/**
|
|
1345
|
+
* Clean coverage results before running tests
|
|
1346
|
+
*
|
|
1347
|
+
* @default true
|
|
1348
|
+
*/
|
|
1349
|
+
clean?: boolean;
|
|
1350
|
+
/**
|
|
1351
|
+
* Clean coverage report on watch rerun
|
|
1352
|
+
*
|
|
1353
|
+
* @default true
|
|
1354
|
+
*/
|
|
1355
|
+
cleanOnRerun?: boolean;
|
|
1262
1356
|
/**
|
|
1263
1357
|
* Directory to write coverage report to
|
|
1264
1358
|
*
|
|
@@ -1271,7 +1365,7 @@ interface BaseCoverageOptions {
|
|
|
1271
1365
|
*
|
|
1272
1366
|
* @default ['text', 'html', 'clover', 'json']
|
|
1273
1367
|
*/
|
|
1274
|
-
reporter?: Arrayable<CoverageReporter> | (CoverageReporter | [CoverageReporter] | CoverageReporterWithOptions)[];
|
|
1368
|
+
reporter?: Arrayable$1<CoverageReporter> | (CoverageReporter | [CoverageReporter] | CoverageReporterWithOptions)[];
|
|
1275
1369
|
/**
|
|
1276
1370
|
* Do not show files with 100% statement, branch, and function coverage
|
|
1277
1371
|
*
|
|
@@ -1332,558 +1426,174 @@ interface BaseCoverageOptions {
|
|
|
1332
1426
|
*
|
|
1333
1427
|
* Use this option when you are seeing files that show up in report even if they
|
|
1334
1428
|
* match your `coverage.exclude` patterns.
|
|
1335
|
-
*
|
|
1336
|
-
* @default false
|
|
1337
|
-
*/
|
|
1338
|
-
excludeAfterRemap?: boolean;
|
|
1339
|
-
/**
|
|
1340
|
-
* Concurrency limit used when processing the coverage results.
|
|
1341
|
-
* Defaults to `Math.min(20, os.availableParallelism?.() ?? os.cpus().length)`
|
|
1342
|
-
*/
|
|
1343
|
-
processingConcurrency?: number;
|
|
1344
|
-
}
|
|
1345
|
-
interface CoverageIstanbulOptions extends BaseCoverageOptions {
|
|
1346
|
-
/**
|
|
1347
|
-
* Set to array of class method names to ignore for coverage
|
|
1348
|
-
*
|
|
1349
|
-
* @default []
|
|
1350
|
-
*/
|
|
1351
|
-
ignoreClassMethods?: string[];
|
|
1352
|
-
}
|
|
1353
|
-
interface CoverageV8Options extends BaseCoverageOptions {
|
|
1354
|
-
/**
|
|
1355
|
-
* Ignore empty lines, comments and other non-runtime code, e.g. Typescript types
|
|
1356
|
-
*/
|
|
1357
|
-
ignoreEmptyLines?: boolean;
|
|
1358
|
-
}
|
|
1359
|
-
interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues> {
|
|
1360
|
-
/** Name of the module or path to a file to load the custom provider from */
|
|
1361
|
-
customProviderModule: string;
|
|
1362
|
-
}
|
|
1363
|
-
interface Thresholds {
|
|
1364
|
-
/** Set global thresholds to `100` */
|
|
1365
|
-
100?: boolean;
|
|
1366
|
-
/** Check thresholds per file. */
|
|
1367
|
-
perFile?: boolean;
|
|
1368
|
-
/**
|
|
1369
|
-
* Update threshold values automatically when current coverage is higher than earlier thresholds
|
|
1370
|
-
*
|
|
1371
|
-
* @default false
|
|
1372
|
-
*/
|
|
1373
|
-
autoUpdate?: boolean;
|
|
1374
|
-
/** Thresholds for statements */
|
|
1375
|
-
statements?: number;
|
|
1376
|
-
/** Thresholds for functions */
|
|
1377
|
-
functions?: number;
|
|
1378
|
-
/** Thresholds for branches */
|
|
1379
|
-
branches?: number;
|
|
1380
|
-
/** Thresholds for lines */
|
|
1381
|
-
lines?: number;
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
interface VitestOptions {
|
|
1385
|
-
packageInstaller?: VitestPackageInstaller;
|
|
1386
|
-
stdin?: NodeJS.ReadStream;
|
|
1387
|
-
stdout?: NodeJS.WriteStream | Writable;
|
|
1388
|
-
stderr?: NodeJS.WriteStream | Writable;
|
|
1389
|
-
}
|
|
1390
|
-
declare class Vitest {
|
|
1391
|
-
readonly mode: VitestRunMode;
|
|
1392
|
-
version: string;
|
|
1393
|
-
config: ResolvedConfig;
|
|
1394
|
-
configOverride: Partial<ResolvedConfig>;
|
|
1395
|
-
server: ViteDevServer;
|
|
1396
|
-
state: StateManager;
|
|
1397
|
-
snapshot: SnapshotManager;
|
|
1398
|
-
cache: VitestCache;
|
|
1399
|
-
reporters: Reporter[];
|
|
1400
|
-
coverageProvider: CoverageProvider | null | undefined;
|
|
1401
|
-
logger: Logger;
|
|
1402
|
-
pool: ProcessPool | undefined;
|
|
1403
|
-
vitenode: ViteNodeServer;
|
|
1404
|
-
invalidates: Set<string>;
|
|
1405
|
-
changedTests: Set<string>;
|
|
1406
|
-
watchedTests: Set<string>;
|
|
1407
|
-
filenamePattern?: string;
|
|
1408
|
-
runningPromise?: Promise<void>;
|
|
1409
|
-
closingPromise?: Promise<void>;
|
|
1410
|
-
isCancelling: boolean;
|
|
1411
|
-
isFirstRun: boolean;
|
|
1412
|
-
restartsCount: number;
|
|
1413
|
-
runner: ViteNodeRunner;
|
|
1414
|
-
packageInstaller: VitestPackageInstaller;
|
|
1415
|
-
private coreWorkspaceProject;
|
|
1416
|
-
private resolvedProjects;
|
|
1417
|
-
projects: WorkspaceProject[];
|
|
1418
|
-
distPath: string;
|
|
1419
|
-
private _cachedSpecs;
|
|
1420
|
-
/** @deprecated use `_cachedSpecs` */
|
|
1421
|
-
projectTestFiles: Map<string, WorkspaceSpec[]>;
|
|
1422
|
-
constructor(mode: VitestRunMode, options?: VitestOptions);
|
|
1423
|
-
private _onRestartListeners;
|
|
1424
|
-
private _onClose;
|
|
1425
|
-
private _onSetServer;
|
|
1426
|
-
private _onCancelListeners;
|
|
1427
|
-
setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
|
|
1428
|
-
provide<T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]): void;
|
|
1429
|
-
/**
|
|
1430
|
-
* @deprecated internal, use `_createCoreProject` instead
|
|
1431
|
-
*/
|
|
1432
|
-
createCoreProject(): Promise<WorkspaceProject>;
|
|
1433
|
-
/**
|
|
1434
|
-
* @internal
|
|
1435
|
-
*/
|
|
1436
|
-
_createCoreProject(): Promise<WorkspaceProject>;
|
|
1437
|
-
getCoreWorkspaceProject(): WorkspaceProject;
|
|
1438
|
-
/**
|
|
1439
|
-
* @deprecated use Reported Task API instead
|
|
1440
|
-
*/
|
|
1441
|
-
getProjectByTaskId(taskId: string): WorkspaceProject;
|
|
1442
|
-
getProjectByName(name?: string): WorkspaceProject;
|
|
1443
|
-
private getWorkspaceConfigPath;
|
|
1444
|
-
private resolveWorkspace;
|
|
1445
|
-
private initCoverageProvider;
|
|
1446
|
-
private initBrowserProviders;
|
|
1447
|
-
mergeReports(): Promise<void>;
|
|
1448
|
-
collect(filters?: string[]): Promise<{
|
|
1449
|
-
tests: File[];
|
|
1450
|
-
errors: unknown[];
|
|
1451
|
-
}>;
|
|
1452
|
-
listFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
1453
|
-
start(filters?: string[]): Promise<void>;
|
|
1454
|
-
init(): Promise<void>;
|
|
1455
|
-
private getTestDependencies;
|
|
1456
|
-
filterTestsBySource(specs: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
|
|
1457
|
-
/**
|
|
1458
|
-
* @deprecated remove when vscode extension supports "getFileWorkspaceSpecs"
|
|
1459
|
-
*/
|
|
1460
|
-
getProjectsByTestFile(file: string): WorkspaceSpec[];
|
|
1461
|
-
getFileWorkspaceSpecs(file: string): WorkspaceSpec[];
|
|
1462
|
-
initializeGlobalSetup(paths: TestSpecification[]): Promise<void>;
|
|
1463
|
-
runFiles(specs: TestSpecification[], allTestsRun: boolean): Promise<void>;
|
|
1464
|
-
collectFiles(specs: WorkspaceSpec[]): Promise<void>;
|
|
1465
|
-
cancelCurrentRun(reason: CancelReason): Promise<void>;
|
|
1466
|
-
rerunFiles(files?: string[], trigger?: string): Promise<void>;
|
|
1467
|
-
changeProjectName(pattern: string): Promise<void>;
|
|
1468
|
-
changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
|
|
1469
|
-
changeFilenamePattern(pattern: string, files?: string[]): Promise<void>;
|
|
1470
|
-
rerunFailed(): Promise<void>;
|
|
1471
|
-
updateSnapshot(files?: string[]): Promise<void>;
|
|
1472
|
-
private _rerunTimer;
|
|
1473
|
-
private scheduleRerun;
|
|
1474
|
-
getModuleProjects(filepath: string): WorkspaceProject[];
|
|
1475
|
-
/**
|
|
1476
|
-
* Watch only the specified tests. If no tests are provided, all tests will be watched.
|
|
1477
|
-
*/
|
|
1478
|
-
watchTests(tests: string[]): void;
|
|
1479
|
-
private updateLastChanged;
|
|
1480
|
-
onChange: (id: string) => void;
|
|
1481
|
-
onUnlink: (id: string) => void;
|
|
1482
|
-
onAdd: (id: string) => Promise<void>;
|
|
1483
|
-
private unregisterWatcher;
|
|
1484
|
-
private registerWatcher;
|
|
1485
|
-
/**
|
|
1486
|
-
* @returns A value indicating whether rerun is needed (changedTests was mutated)
|
|
1487
|
-
*/
|
|
1488
|
-
private handleFileChanged;
|
|
1489
|
-
private reportCoverage;
|
|
1490
|
-
close(): Promise<void>;
|
|
1491
|
-
/**
|
|
1492
|
-
* Close the thread pool and exit the process
|
|
1493
|
-
*/
|
|
1494
|
-
exit(force?: boolean): Promise<void>;
|
|
1495
|
-
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
|
|
1496
|
-
getTestFilepaths(): Promise<string[]>;
|
|
1497
|
-
globTestSpecs(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
1498
|
-
/**
|
|
1499
|
-
* @deprecated use globTestSpecs instead
|
|
1500
|
-
*/
|
|
1501
|
-
globTestFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
1502
|
-
private ensureSpecCached;
|
|
1503
|
-
shouldKeepServer(): boolean;
|
|
1504
|
-
onServerRestart(fn: OnServerRestartHandler): void;
|
|
1505
|
-
onAfterSetServer(fn: OnServerRestartHandler): void;
|
|
1506
|
-
onCancel(fn: (reason: CancelReason) => void): void;
|
|
1507
|
-
onClose(fn: () => void): void;
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
interface Reporter {
|
|
1511
|
-
onInit?: (ctx: Vitest) => void;
|
|
1512
|
-
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
1513
|
-
onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable<void>;
|
|
1514
|
-
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
1515
|
-
onFinished?: (files: File[], errors: unknown[], coverage?: unknown) => Awaitable<void>;
|
|
1516
|
-
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
1517
|
-
onTestRemoved?: (trigger?: string) => Awaitable<void>;
|
|
1518
|
-
onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
1519
|
-
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
1520
|
-
onServerRestart?: (reason?: string) => Awaitable<void>;
|
|
1521
|
-
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
1522
|
-
onProcessTimeout?: () => Awaitable<void>;
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
interface BaseOptions {
|
|
1526
|
-
isTTY?: boolean;
|
|
1527
|
-
}
|
|
1528
|
-
declare abstract class BaseReporter implements Reporter {
|
|
1529
|
-
start: number;
|
|
1530
|
-
end: number;
|
|
1531
|
-
watchFilters?: string[];
|
|
1532
|
-
failedUnwatchedFiles: Task[];
|
|
1533
|
-
isTTY: boolean;
|
|
1534
|
-
ctx: Vitest;
|
|
1535
|
-
protected verbose: boolean;
|
|
1536
|
-
private _filesInWatchMode;
|
|
1537
|
-
private _lastRunTimeout;
|
|
1538
|
-
private _lastRunTimer;
|
|
1539
|
-
private _lastRunCount;
|
|
1540
|
-
private _timeStart;
|
|
1541
|
-
private _offUnhandledRejection?;
|
|
1542
|
-
constructor(options?: BaseOptions);
|
|
1543
|
-
get mode(): VitestRunMode;
|
|
1544
|
-
onInit(ctx: Vitest): void;
|
|
1545
|
-
relative(path: string): string;
|
|
1546
|
-
onFinished(files?: File[], errors?: unknown[]): void;
|
|
1547
|
-
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1548
|
-
protected printTask(task: Task): void;
|
|
1549
|
-
onWatcherStart(files?: File[], errors?: unknown[]): void;
|
|
1550
|
-
private resetLastRunLog;
|
|
1551
|
-
onWatcherRerun(files: string[], trigger?: string): void;
|
|
1552
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1553
|
-
shouldLog(log: UserConsoleLog): boolean;
|
|
1554
|
-
onServerRestart(reason?: string): void;
|
|
1555
|
-
reportSummary(files: File[], errors: unknown[]): void;
|
|
1556
|
-
reportTestSummary(files: File[], errors: unknown[]): void;
|
|
1557
|
-
private printErrorsSummary;
|
|
1558
|
-
reportBenchmarkSummary(files: File[]): void;
|
|
1559
|
-
private printTaskErrors;
|
|
1560
|
-
registerUnhandledRejection(): void;
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
|
-
declare class BasicReporter extends BaseReporter {
|
|
1564
|
-
constructor();
|
|
1565
|
-
reportSummary(files: File[], errors: unknown[]): void;
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
interface ListRendererOptions {
|
|
1569
|
-
renderSucceed?: boolean;
|
|
1570
|
-
logger: Logger;
|
|
1571
|
-
showHeap: boolean;
|
|
1572
|
-
slowTestThreshold: number;
|
|
1573
|
-
mode: VitestRunMode;
|
|
1574
|
-
}
|
|
1575
|
-
declare function createListRenderer(_tasks: Task[], options: ListRendererOptions): {
|
|
1576
|
-
start(): any;
|
|
1577
|
-
update(_tasks: Task[]): any;
|
|
1578
|
-
stop(): any;
|
|
1579
|
-
clear(): void;
|
|
1580
|
-
};
|
|
1581
|
-
|
|
1582
|
-
declare class DefaultReporter extends BaseReporter {
|
|
1583
|
-
renderer?: ReturnType<typeof createListRenderer>;
|
|
1584
|
-
rendererOptions: ListRendererOptions;
|
|
1585
|
-
private renderSucceedDefault?;
|
|
1586
|
-
onPathsCollected(paths?: string[]): void;
|
|
1587
|
-
onTestRemoved(trigger?: string): Promise<void>;
|
|
1588
|
-
onCollected(): void;
|
|
1589
|
-
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): void;
|
|
1590
|
-
onWatcherStart(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
1591
|
-
stopListRender(): void;
|
|
1592
|
-
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
1593
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
interface DotRendererOptions {
|
|
1597
|
-
logger: Logger;
|
|
1598
|
-
}
|
|
1599
|
-
declare function createDotRenderer(_tasks: Task[], options: DotRendererOptions): {
|
|
1600
|
-
start(): any;
|
|
1601
|
-
update(_tasks: Task[]): any;
|
|
1602
|
-
stop(): Promise<any>;
|
|
1603
|
-
clear(): void;
|
|
1604
|
-
};
|
|
1605
|
-
|
|
1606
|
-
declare class DotReporter extends BaseReporter {
|
|
1607
|
-
renderer?: ReturnType<typeof createDotRenderer>;
|
|
1608
|
-
onCollected(): void;
|
|
1609
|
-
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
1610
|
-
onWatcherStart(): Promise<void>;
|
|
1611
|
-
stopListRender(): Promise<void>;
|
|
1612
|
-
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
1613
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1614
|
-
}
|
|
1615
|
-
|
|
1616
|
-
type Status = 'passed' | 'failed' | 'skipped' | 'pending' | 'todo' | 'disabled';
|
|
1617
|
-
type Milliseconds = number;
|
|
1618
|
-
interface Callsite {
|
|
1619
|
-
line: number;
|
|
1620
|
-
column: number;
|
|
1621
|
-
}
|
|
1622
|
-
interface JsonAssertionResult {
|
|
1623
|
-
ancestorTitles: Array<string>;
|
|
1624
|
-
fullName: string;
|
|
1625
|
-
status: Status;
|
|
1626
|
-
title: string;
|
|
1627
|
-
meta: TaskMeta;
|
|
1628
|
-
duration?: Milliseconds | null;
|
|
1629
|
-
failureMessages: Array<string> | null;
|
|
1630
|
-
location?: Callsite | null;
|
|
1631
|
-
}
|
|
1632
|
-
interface JsonTestResult {
|
|
1633
|
-
message: string;
|
|
1634
|
-
name: string;
|
|
1635
|
-
status: 'failed' | 'passed';
|
|
1636
|
-
startTime: number;
|
|
1637
|
-
endTime: number;
|
|
1638
|
-
assertionResults: Array<JsonAssertionResult>;
|
|
1639
|
-
}
|
|
1640
|
-
interface JsonTestResults {
|
|
1641
|
-
numFailedTests: number;
|
|
1642
|
-
numFailedTestSuites: number;
|
|
1643
|
-
numPassedTests: number;
|
|
1644
|
-
numPassedTestSuites: number;
|
|
1645
|
-
numPendingTests: number;
|
|
1646
|
-
numPendingTestSuites: number;
|
|
1647
|
-
numTodoTests: number;
|
|
1648
|
-
numTotalTests: number;
|
|
1649
|
-
numTotalTestSuites: number;
|
|
1650
|
-
startTime: number;
|
|
1651
|
-
success: boolean;
|
|
1652
|
-
testResults: Array<JsonTestResult>;
|
|
1653
|
-
snapshot: SnapshotSummary;
|
|
1654
|
-
}
|
|
1655
|
-
interface JsonOptions {
|
|
1656
|
-
outputFile?: string;
|
|
1657
|
-
}
|
|
1658
|
-
declare class JsonReporter implements Reporter {
|
|
1659
|
-
start: number;
|
|
1660
|
-
ctx: Vitest;
|
|
1661
|
-
options: JsonOptions;
|
|
1662
|
-
constructor(options: JsonOptions);
|
|
1663
|
-
onInit(ctx: Vitest): void;
|
|
1664
|
-
protected logTasks(files: File[]): Promise<void>;
|
|
1665
|
-
onFinished(files?: File[]): Promise<void>;
|
|
1666
|
-
/**
|
|
1667
|
-
* Writes the report to an output file if specified in the config,
|
|
1668
|
-
* or logs it to the console otherwise.
|
|
1669
|
-
* @param report
|
|
1670
|
-
*/
|
|
1671
|
-
writeReport(report: string): Promise<void>;
|
|
1672
|
-
}
|
|
1673
|
-
|
|
1674
|
-
declare class VerboseReporter extends DefaultReporter {
|
|
1675
|
-
protected verbose: boolean;
|
|
1676
|
-
constructor();
|
|
1677
|
-
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1678
|
-
}
|
|
1679
|
-
|
|
1680
|
-
declare class TapReporter implements Reporter {
|
|
1681
|
-
protected ctx: Vitest;
|
|
1682
|
-
private logger;
|
|
1683
|
-
onInit(ctx: Vitest): void;
|
|
1684
|
-
static getComment(task: Task): string;
|
|
1685
|
-
private logErrorDetails;
|
|
1686
|
-
protected logTasks(tasks: Task[]): void;
|
|
1687
|
-
onFinished(files?: _vitest_runner.File[]): void;
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
|
-
interface JUnitOptions {
|
|
1691
|
-
outputFile?: string;
|
|
1692
|
-
classname?: string;
|
|
1693
|
-
suiteName?: string;
|
|
1694
|
-
/**
|
|
1695
|
-
* Write <system-out> and <system-err> for console output
|
|
1696
|
-
* @default true
|
|
1429
|
+
*
|
|
1430
|
+
* @default false
|
|
1697
1431
|
*/
|
|
1698
|
-
|
|
1432
|
+
excludeAfterRemap?: boolean;
|
|
1699
1433
|
/**
|
|
1700
|
-
*
|
|
1701
|
-
*
|
|
1434
|
+
* Concurrency limit used when processing the coverage results.
|
|
1435
|
+
* Defaults to `Math.min(20, os.availableParallelism?.() ?? os.cpus().length)`
|
|
1702
1436
|
*/
|
|
1703
|
-
|
|
1704
|
-
}
|
|
1705
|
-
declare class JUnitReporter implements Reporter {
|
|
1706
|
-
private ctx;
|
|
1707
|
-
private reportFile?;
|
|
1708
|
-
private baseLog;
|
|
1709
|
-
private logger;
|
|
1710
|
-
private _timeStart;
|
|
1711
|
-
private fileFd?;
|
|
1712
|
-
private options;
|
|
1713
|
-
constructor(options: JUnitOptions);
|
|
1714
|
-
onInit(ctx: Vitest): Promise<void>;
|
|
1715
|
-
writeElement(name: string, attrs: Record<string, any>, children: () => Promise<void>): Promise<void>;
|
|
1716
|
-
writeLogs(task: Task, type: 'err' | 'out'): Promise<void>;
|
|
1717
|
-
writeTasks(tasks: Task[], filename: string): Promise<void>;
|
|
1718
|
-
onFinished(files?: _vitest_runner.File[]): Promise<void>;
|
|
1719
|
-
}
|
|
1720
|
-
|
|
1721
|
-
declare class TapFlatReporter extends TapReporter {
|
|
1722
|
-
onInit(ctx: Vitest): void;
|
|
1723
|
-
onFinished(files?: _vitest_runner.File[]): void;
|
|
1724
|
-
}
|
|
1725
|
-
|
|
1726
|
-
declare class HangingProcessReporter implements Reporter {
|
|
1727
|
-
whyRunning: (() => void) | undefined;
|
|
1728
|
-
onInit(): void;
|
|
1729
|
-
onProcessTimeout(): void;
|
|
1730
|
-
}
|
|
1731
|
-
|
|
1732
|
-
declare class GithubActionsReporter implements Reporter {
|
|
1733
|
-
ctx: Vitest;
|
|
1734
|
-
onInit(ctx: Vitest): void;
|
|
1735
|
-
onFinished(files?: File[], errors?: unknown[]): void;
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
interface HTMLOptions {
|
|
1739
|
-
outputFile?: string;
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
interface BlobOptions {
|
|
1743
|
-
outputFile?: string;
|
|
1744
|
-
}
|
|
1745
|
-
declare class BlobReporter implements Reporter {
|
|
1746
|
-
ctx: Vitest;
|
|
1747
|
-
options: BlobOptions;
|
|
1748
|
-
constructor(options: BlobOptions);
|
|
1749
|
-
onInit(ctx: Vitest): void;
|
|
1750
|
-
onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
|
|
1751
|
-
}
|
|
1752
|
-
|
|
1753
|
-
interface TableRendererOptions {
|
|
1754
|
-
renderSucceed?: boolean;
|
|
1755
|
-
logger: Logger;
|
|
1756
|
-
showHeap: boolean;
|
|
1757
|
-
slowTestThreshold: number;
|
|
1758
|
-
compare?: FlatBenchmarkReport;
|
|
1437
|
+
processingConcurrency?: number;
|
|
1759
1438
|
}
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
declare class TableReporter extends BaseReporter {
|
|
1768
|
-
renderer?: ReturnType<typeof createTableRenderer>;
|
|
1769
|
-
rendererOptions: TableRendererOptions;
|
|
1770
|
-
onTestRemoved(trigger?: string): void;
|
|
1771
|
-
onCollected(): Promise<void>;
|
|
1772
|
-
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1773
|
-
onFinished(files?: File[], errors?: unknown[]): Promise<void>;
|
|
1774
|
-
onWatcherStart(): Promise<void>;
|
|
1775
|
-
stopListRender(): void;
|
|
1776
|
-
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
1777
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1439
|
+
interface CoverageIstanbulOptions extends BaseCoverageOptions {
|
|
1440
|
+
/**
|
|
1441
|
+
* Set to array of class method names to ignore for coverage
|
|
1442
|
+
*
|
|
1443
|
+
* @default []
|
|
1444
|
+
*/
|
|
1445
|
+
ignoreClassMethods?: string[];
|
|
1778
1446
|
}
|
|
1779
|
-
interface
|
|
1780
|
-
|
|
1447
|
+
interface CoverageV8Options extends BaseCoverageOptions {
|
|
1448
|
+
/**
|
|
1449
|
+
* Ignore empty lines, comments and other non-runtime code, e.g. Typescript types
|
|
1450
|
+
*/
|
|
1451
|
+
ignoreEmptyLines?: boolean;
|
|
1781
1452
|
}
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
declare const BenchmarkReportsMap: {
|
|
1787
|
-
default: typeof TableReporter;
|
|
1788
|
-
verbose: typeof VerboseReporter;
|
|
1789
|
-
};
|
|
1790
|
-
type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
|
|
1791
|
-
|
|
1792
|
-
/**
|
|
1793
|
-
* @deprecated Use `TestModule` instead
|
|
1794
|
-
*/
|
|
1795
|
-
declare const TestFile: typeof TestModule;
|
|
1796
|
-
|
|
1797
|
-
/**
|
|
1798
|
-
* @deprecated Use `ModuleDiagnostic` instead
|
|
1799
|
-
*/
|
|
1800
|
-
type FileDiagnostic = ModuleDiagnostic;
|
|
1801
|
-
|
|
1802
|
-
declare const ReportersMap: {
|
|
1803
|
-
default: typeof DefaultReporter;
|
|
1804
|
-
basic: typeof BasicReporter;
|
|
1805
|
-
blob: typeof BlobReporter;
|
|
1806
|
-
verbose: typeof VerboseReporter;
|
|
1807
|
-
dot: typeof DotReporter;
|
|
1808
|
-
json: typeof JsonReporter;
|
|
1809
|
-
tap: typeof TapReporter;
|
|
1810
|
-
'tap-flat': typeof TapFlatReporter;
|
|
1811
|
-
junit: typeof JUnitReporter;
|
|
1812
|
-
'hanging-process': typeof HangingProcessReporter;
|
|
1813
|
-
'github-actions': typeof GithubActionsReporter;
|
|
1814
|
-
};
|
|
1815
|
-
type BuiltinReporters = keyof typeof ReportersMap;
|
|
1816
|
-
interface BuiltinReporterOptions {
|
|
1817
|
-
'default': BaseOptions;
|
|
1818
|
-
'basic': BaseOptions;
|
|
1819
|
-
'verbose': never;
|
|
1820
|
-
'dot': BaseOptions;
|
|
1821
|
-
'json': JsonOptions;
|
|
1822
|
-
'blob': BlobOptions;
|
|
1823
|
-
'tap': never;
|
|
1824
|
-
'tap-flat': never;
|
|
1825
|
-
'junit': JUnitOptions;
|
|
1826
|
-
'hanging-process': never;
|
|
1827
|
-
'html': HTMLOptions;
|
|
1453
|
+
interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues> {
|
|
1454
|
+
/** Name of the module or path to a file to load the custom provider from */
|
|
1455
|
+
customProviderModule: string;
|
|
1828
1456
|
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1457
|
+
interface Thresholds {
|
|
1458
|
+
/** Set global thresholds to `100` */
|
|
1459
|
+
100?: boolean;
|
|
1460
|
+
/** Check thresholds per file. */
|
|
1461
|
+
perFile?: boolean;
|
|
1831
1462
|
/**
|
|
1832
|
-
*
|
|
1833
|
-
*
|
|
1463
|
+
* Update threshold values automatically when current coverage is higher than earlier thresholds
|
|
1464
|
+
*
|
|
1465
|
+
* @default false
|
|
1834
1466
|
*/
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1467
|
+
autoUpdate?: boolean;
|
|
1468
|
+
/** Thresholds for statements */
|
|
1469
|
+
statements?: number;
|
|
1470
|
+
/** Thresholds for functions */
|
|
1471
|
+
functions?: number;
|
|
1472
|
+
/** Thresholds for branches */
|
|
1473
|
+
branches?: number;
|
|
1474
|
+
/** Thresholds for lines */
|
|
1475
|
+
lines?: number;
|
|
1840
1476
|
}
|
|
1841
1477
|
|
|
1842
|
-
type
|
|
1843
|
-
|
|
1844
|
-
interface
|
|
1478
|
+
type BuiltinPool = 'browser' | 'threads' | 'forks' | 'vmThreads' | 'vmForks' | 'typescript';
|
|
1479
|
+
type Pool = BuiltinPool | (string & {});
|
|
1480
|
+
interface PoolOptions extends Record<string, unknown> {
|
|
1845
1481
|
/**
|
|
1846
|
-
*
|
|
1482
|
+
* Run tests in `node:worker_threads`.
|
|
1847
1483
|
*
|
|
1848
|
-
*
|
|
1484
|
+
* Test isolation (when enabled) is done by spawning a new thread for each test file.
|
|
1485
|
+
*
|
|
1486
|
+
* This pool is used by default.
|
|
1849
1487
|
*/
|
|
1850
|
-
|
|
1488
|
+
threads?: ThreadsOptions & WorkerContextOptions;
|
|
1851
1489
|
/**
|
|
1852
|
-
*
|
|
1853
|
-
*
|
|
1490
|
+
* Run tests in `node:child_process` using [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
1491
|
+
*
|
|
1492
|
+
* Test isolation (when enabled) is done by spawning a new child process for each test file.
|
|
1854
1493
|
*/
|
|
1855
|
-
|
|
1494
|
+
forks?: ForksOptions & WorkerContextOptions;
|
|
1856
1495
|
/**
|
|
1857
|
-
*
|
|
1496
|
+
* Run tests in isolated `node:vm`.
|
|
1497
|
+
* Test files are run parallel using `node:worker_threads`.
|
|
1858
1498
|
*
|
|
1859
|
-
*
|
|
1499
|
+
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
1860
1500
|
*/
|
|
1861
|
-
|
|
1501
|
+
vmThreads?: ThreadsOptions & VmOptions;
|
|
1862
1502
|
/**
|
|
1863
|
-
*
|
|
1864
|
-
* and/or paths to custom reporters
|
|
1503
|
+
* Run tests in isolated `node:vm`.
|
|
1865
1504
|
*
|
|
1866
|
-
*
|
|
1505
|
+
* Test files are run parallel using `node:child_process` [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
1506
|
+
*
|
|
1507
|
+
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
1867
1508
|
*/
|
|
1868
|
-
|
|
1509
|
+
vmForks?: ForksOptions & VmOptions;
|
|
1510
|
+
}
|
|
1511
|
+
interface ResolvedPoolOptions extends PoolOptions {
|
|
1512
|
+
threads?: ResolvedThreadsOptions & WorkerContextOptions;
|
|
1513
|
+
forks?: ResolvedForksOptions & WorkerContextOptions;
|
|
1514
|
+
vmThreads?: ResolvedThreadsOptions & VmOptions;
|
|
1515
|
+
vmForks?: ResolvedForksOptions & VmOptions;
|
|
1516
|
+
}
|
|
1517
|
+
interface ThreadsOptions {
|
|
1518
|
+
/** Minimum amount of threads to use */
|
|
1519
|
+
minThreads?: number | string;
|
|
1520
|
+
/** Maximum amount of threads to use */
|
|
1521
|
+
maxThreads?: number | string;
|
|
1869
1522
|
/**
|
|
1870
|
-
*
|
|
1523
|
+
* Run tests inside a single thread.
|
|
1524
|
+
*
|
|
1525
|
+
* @default false
|
|
1526
|
+
*/
|
|
1527
|
+
singleThread?: boolean;
|
|
1528
|
+
/**
|
|
1529
|
+
* Use Atomics to synchronize threads
|
|
1530
|
+
*
|
|
1531
|
+
* This can improve performance in some cases, but might cause segfault in older Node versions.
|
|
1532
|
+
*
|
|
1533
|
+
* @default false
|
|
1534
|
+
*/
|
|
1535
|
+
useAtomics?: boolean;
|
|
1536
|
+
}
|
|
1537
|
+
interface ResolvedThreadsOptions extends ThreadsOptions {
|
|
1538
|
+
minThreads?: number;
|
|
1539
|
+
maxThreads?: number;
|
|
1540
|
+
}
|
|
1541
|
+
interface ForksOptions {
|
|
1542
|
+
/** Minimum amount of child processes to use */
|
|
1543
|
+
minForks?: number | string;
|
|
1544
|
+
/** Maximum amount of child processes to use */
|
|
1545
|
+
maxForks?: number | string;
|
|
1546
|
+
/**
|
|
1547
|
+
* Run tests inside a single fork.
|
|
1548
|
+
*
|
|
1549
|
+
* @default false
|
|
1550
|
+
*/
|
|
1551
|
+
singleFork?: boolean;
|
|
1552
|
+
}
|
|
1553
|
+
interface ResolvedForksOptions extends ForksOptions {
|
|
1554
|
+
minForks?: number;
|
|
1555
|
+
maxForks?: number;
|
|
1556
|
+
}
|
|
1557
|
+
interface WorkerContextOptions {
|
|
1558
|
+
/**
|
|
1559
|
+
* Isolate test environment by recycling `worker_threads` or `child_process` after each test
|
|
1560
|
+
*
|
|
1561
|
+
* @default true
|
|
1871
1562
|
*/
|
|
1872
|
-
|
|
1563
|
+
isolate?: boolean;
|
|
1873
1564
|
/**
|
|
1874
|
-
*
|
|
1565
|
+
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
1566
|
+
*
|
|
1567
|
+
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
1568
|
+
*
|
|
1569
|
+
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
1570
|
+
*
|
|
1571
|
+
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
1572
|
+
*
|
|
1573
|
+
* @default [] // no execution arguments are passed
|
|
1875
1574
|
*/
|
|
1876
|
-
|
|
1575
|
+
execArgv?: string[];
|
|
1576
|
+
}
|
|
1577
|
+
interface VmOptions {
|
|
1877
1578
|
/**
|
|
1878
|
-
*
|
|
1579
|
+
* Specifies the memory limit for `worker_thread` or `child_process` before they are recycled.
|
|
1580
|
+
* If you see memory leaks, try to tinker this value.
|
|
1879
1581
|
*/
|
|
1880
|
-
|
|
1582
|
+
memoryLimit?: string | number;
|
|
1583
|
+
/** Isolation is always enabled */
|
|
1584
|
+
isolate?: true;
|
|
1881
1585
|
/**
|
|
1882
|
-
*
|
|
1883
|
-
*
|
|
1884
|
-
*
|
|
1586
|
+
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
1587
|
+
*
|
|
1588
|
+
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
1589
|
+
*
|
|
1590
|
+
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
1591
|
+
*
|
|
1592
|
+
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
1593
|
+
*
|
|
1594
|
+
* @default [] // no execution arguments are passed
|
|
1885
1595
|
*/
|
|
1886
|
-
|
|
1596
|
+
execArgv?: string[];
|
|
1887
1597
|
}
|
|
1888
1598
|
|
|
1889
1599
|
type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
|
|
@@ -2207,7 +1917,7 @@ interface InlineConfig {
|
|
|
2207
1917
|
*
|
|
2208
1918
|
* @default []
|
|
2209
1919
|
*/
|
|
2210
|
-
reporters?: Arrayable<ReporterName | InlineReporter> | ((ReporterName | InlineReporter) | [ReporterName] | ReporterWithOptions)[];
|
|
1920
|
+
reporters?: Arrayable$1<ReporterName | InlineReporter> | ((ReporterName | InlineReporter) | [ReporterName] | ReporterWithOptions)[];
|
|
2211
1921
|
/**
|
|
2212
1922
|
* Write test results to a file when the --reporter=json` or `--reporter=junit` option is also specified.
|
|
2213
1923
|
* Also definable individually per reporter by using an object instead.
|
|
@@ -2474,274 +2184,579 @@ interface InlineConfig {
|
|
|
2474
2184
|
*/
|
|
2475
2185
|
host?: string;
|
|
2476
2186
|
/**
|
|
2477
|
-
* Wait for debugger to connect before running tests
|
|
2187
|
+
* Wait for debugger to connect before running tests
|
|
2188
|
+
*/
|
|
2189
|
+
waitForDebugger?: boolean;
|
|
2190
|
+
};
|
|
2191
|
+
/**
|
|
2192
|
+
* Define variables that will be returned from `inject` in the test environment.
|
|
2193
|
+
* @example
|
|
2194
|
+
* ```ts
|
|
2195
|
+
* // vitest.config.ts
|
|
2196
|
+
* export default defineConfig({
|
|
2197
|
+
* test: {
|
|
2198
|
+
* provide: {
|
|
2199
|
+
* someKey: 'someValue'
|
|
2200
|
+
* }
|
|
2201
|
+
* }
|
|
2202
|
+
* })
|
|
2203
|
+
* ```
|
|
2204
|
+
* ```ts
|
|
2205
|
+
* // test file
|
|
2206
|
+
* import { inject } from 'vitest'
|
|
2207
|
+
* const value = inject('someKey') // 'someValue'
|
|
2208
|
+
* ```
|
|
2209
|
+
*/
|
|
2210
|
+
provide?: Partial<ProvidedContext>;
|
|
2211
|
+
/**
|
|
2212
|
+
* Configuration options for expect() matches.
|
|
2213
|
+
*/
|
|
2214
|
+
expect?: {
|
|
2215
|
+
/**
|
|
2216
|
+
* Throw an error if tests don't have any expect() assertions.
|
|
2217
|
+
*/
|
|
2218
|
+
requireAssertions?: boolean;
|
|
2219
|
+
/**
|
|
2220
|
+
* Default options for expect.poll()
|
|
2221
|
+
*/
|
|
2222
|
+
poll?: {
|
|
2223
|
+
/**
|
|
2224
|
+
* Timeout in milliseconds
|
|
2225
|
+
* @default 1000
|
|
2226
|
+
*/
|
|
2227
|
+
timeout?: number;
|
|
2228
|
+
/**
|
|
2229
|
+
* Polling interval in milliseconds
|
|
2230
|
+
* @default 50
|
|
2231
|
+
*/
|
|
2232
|
+
interval?: number;
|
|
2233
|
+
};
|
|
2234
|
+
};
|
|
2235
|
+
/**
|
|
2236
|
+
* Modify default Chai config. Vitest uses Chai for `expect` and `assert` matches.
|
|
2237
|
+
* https://github.com/chaijs/chai/blob/4.x.x/lib/chai/config.js
|
|
2238
|
+
*/
|
|
2239
|
+
chaiConfig?: ChaiConfig;
|
|
2240
|
+
/**
|
|
2241
|
+
* Stop test execution when given number of tests have failed.
|
|
2242
|
+
*/
|
|
2243
|
+
bail?: number;
|
|
2244
|
+
/**
|
|
2245
|
+
* Retry the test specific number of times if it fails.
|
|
2246
|
+
*
|
|
2247
|
+
* @default 0
|
|
2248
|
+
*/
|
|
2249
|
+
retry?: number;
|
|
2250
|
+
/**
|
|
2251
|
+
* Show full diff when snapshot fails instead of a patch.
|
|
2252
|
+
*/
|
|
2253
|
+
expandSnapshotDiff?: boolean;
|
|
2254
|
+
/**
|
|
2255
|
+
* By default, Vitest automatically intercepts console logging during tests for extra formatting of test file, test title, etc...
|
|
2256
|
+
* This is also required for console log preview on Vitest UI.
|
|
2257
|
+
* However, disabling such interception might help when you want to debug a code with normal synchronus terminal console logging.
|
|
2258
|
+
*
|
|
2259
|
+
* This option has no effect on browser pool since Vitest preserves original logging on browser devtools.
|
|
2260
|
+
*
|
|
2261
|
+
* @default false
|
|
2262
|
+
*/
|
|
2263
|
+
disableConsoleIntercept?: boolean;
|
|
2264
|
+
/**
|
|
2265
|
+
* Always print console stack traces.
|
|
2266
|
+
*
|
|
2267
|
+
* @default false
|
|
2268
|
+
*/
|
|
2269
|
+
printConsoleTrace?: boolean;
|
|
2270
|
+
/**
|
|
2271
|
+
* Include "location" property inside the test definition
|
|
2272
|
+
*
|
|
2273
|
+
* @default false
|
|
2274
|
+
*/
|
|
2275
|
+
includeTaskLocation?: boolean;
|
|
2276
|
+
}
|
|
2277
|
+
interface TypecheckConfig {
|
|
2278
|
+
/**
|
|
2279
|
+
* Run typechecking tests alongisde regular tests.
|
|
2280
|
+
*/
|
|
2281
|
+
enabled?: boolean;
|
|
2282
|
+
/**
|
|
2283
|
+
* When typechecking is enabled, only run typechecking tests.
|
|
2284
|
+
*/
|
|
2285
|
+
only?: boolean;
|
|
2286
|
+
/**
|
|
2287
|
+
* What tools to use for type checking.
|
|
2288
|
+
*
|
|
2289
|
+
* @default 'tsc'
|
|
2290
|
+
*/
|
|
2291
|
+
checker: 'tsc' | 'vue-tsc' | (string & Record<never, never>);
|
|
2292
|
+
/**
|
|
2293
|
+
* Pattern for files that should be treated as test files
|
|
2294
|
+
*
|
|
2295
|
+
* @default ['**\/*.{test,spec}-d.?(c|m)[jt]s?(x)']
|
|
2296
|
+
*/
|
|
2297
|
+
include: string[];
|
|
2298
|
+
/**
|
|
2299
|
+
* Pattern for files that should not be treated as test files
|
|
2300
|
+
*
|
|
2301
|
+
* @default ['**\/node_modules/**', '**\/dist/**', '**\/cypress/**', '**\/.{idea,git,cache,output,temp}/**', '**\/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*']
|
|
2302
|
+
*/
|
|
2303
|
+
exclude: string[];
|
|
2304
|
+
/**
|
|
2305
|
+
* Check JS files that have `@ts-check` comment.
|
|
2306
|
+
* If you have it enabled in tsconfig, this will not overwrite it.
|
|
2307
|
+
*/
|
|
2308
|
+
allowJs?: boolean;
|
|
2309
|
+
/**
|
|
2310
|
+
* Do not fail, if Vitest found errors outside the test files.
|
|
2311
|
+
*/
|
|
2312
|
+
ignoreSourceErrors?: boolean;
|
|
2313
|
+
/**
|
|
2314
|
+
* Path to tsconfig, relative to the project root.
|
|
2315
|
+
*/
|
|
2316
|
+
tsconfig?: string;
|
|
2317
|
+
}
|
|
2318
|
+
interface UserConfig extends InlineConfig {
|
|
2319
|
+
/**
|
|
2320
|
+
* Path to the config file.
|
|
2321
|
+
*
|
|
2322
|
+
* Default resolving to `vitest.config.*`, `vite.config.*`
|
|
2323
|
+
*
|
|
2324
|
+
* Setting to `false` will disable config resolving.
|
|
2325
|
+
*/
|
|
2326
|
+
config?: string | false | undefined;
|
|
2327
|
+
/**
|
|
2328
|
+
* Do not run tests when Vitest starts.
|
|
2329
|
+
*
|
|
2330
|
+
* Vitest will only run tests if it's called programmatically or the test file changes.
|
|
2331
|
+
*
|
|
2332
|
+
* CLI file filters will be ignored.
|
|
2333
|
+
*/
|
|
2334
|
+
standalone?: boolean;
|
|
2335
|
+
/**
|
|
2336
|
+
* Use happy-dom
|
|
2337
|
+
*/
|
|
2338
|
+
dom?: boolean;
|
|
2339
|
+
/**
|
|
2340
|
+
* Run tests that cover a list of source files
|
|
2341
|
+
*/
|
|
2342
|
+
related?: string[] | string;
|
|
2343
|
+
/**
|
|
2344
|
+
* Overrides Vite mode
|
|
2345
|
+
* @default 'test'
|
|
2346
|
+
*/
|
|
2347
|
+
mode?: string;
|
|
2348
|
+
/**
|
|
2349
|
+
* Runs tests that are affected by the changes in the repository, or between specified branch or commit hash
|
|
2350
|
+
* Requires initialized git repository
|
|
2351
|
+
* @default false
|
|
2352
|
+
*/
|
|
2353
|
+
changed?: boolean | string;
|
|
2354
|
+
/**
|
|
2355
|
+
* Test suite shard to execute in a format of <index>/<count>.
|
|
2356
|
+
* Will divide tests into a `count` numbers, and run only the `indexed` part.
|
|
2357
|
+
* Cannot be used with enabled watch.
|
|
2358
|
+
* @example --shard=2/3
|
|
2359
|
+
*/
|
|
2360
|
+
shard?: string;
|
|
2361
|
+
/**
|
|
2362
|
+
* Name of the project or projects to run.
|
|
2363
|
+
*/
|
|
2364
|
+
project?: string | string[];
|
|
2365
|
+
/**
|
|
2366
|
+
* Additional exclude patterns
|
|
2367
|
+
*/
|
|
2368
|
+
cliExclude?: string[];
|
|
2369
|
+
/**
|
|
2370
|
+
* Override vite config's clearScreen from cli
|
|
2371
|
+
*/
|
|
2372
|
+
clearScreen?: boolean;
|
|
2373
|
+
/**
|
|
2374
|
+
* benchmark.compare option exposed at the top level for cli
|
|
2375
|
+
*/
|
|
2376
|
+
compare?: string;
|
|
2377
|
+
/**
|
|
2378
|
+
* benchmark.outputJson option exposed at the top level for cli
|
|
2379
|
+
*/
|
|
2380
|
+
outputJson?: string;
|
|
2381
|
+
/**
|
|
2382
|
+
* Directory of blob reports to merge
|
|
2383
|
+
* @default '.vitest-reports'
|
|
2384
|
+
*/
|
|
2385
|
+
mergeReports?: string;
|
|
2386
|
+
}
|
|
2387
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions' | 'pool' | 'cliExclude' | 'diff' | 'setupFiles' | 'snapshotEnvironment' | 'bail'> {
|
|
2388
|
+
mode: VitestRunMode;
|
|
2389
|
+
base?: string;
|
|
2390
|
+
diff?: string;
|
|
2391
|
+
bail?: number;
|
|
2392
|
+
setupFiles: string[];
|
|
2393
|
+
snapshotEnvironment?: string;
|
|
2394
|
+
config?: string;
|
|
2395
|
+
filters?: string[];
|
|
2396
|
+
testNamePattern?: RegExp;
|
|
2397
|
+
related?: string[];
|
|
2398
|
+
coverage: ResolvedCoverageOptions;
|
|
2399
|
+
snapshotOptions: SnapshotStateOptions;
|
|
2400
|
+
browser: ResolvedBrowserOptions;
|
|
2401
|
+
pool: Pool;
|
|
2402
|
+
poolOptions?: ResolvedPoolOptions;
|
|
2403
|
+
reporters: (InlineReporter | ReporterWithOptions)[];
|
|
2404
|
+
defines: Record<string, any>;
|
|
2405
|
+
api?: ApiConfig;
|
|
2406
|
+
cliExclude?: string[];
|
|
2407
|
+
benchmark?: Required<Omit<BenchmarkUserOptions, 'outputFile' | 'compare' | 'outputJson'>> & Pick<BenchmarkUserOptions, 'outputFile' | 'compare' | 'outputJson'>;
|
|
2408
|
+
shard?: {
|
|
2409
|
+
index: number;
|
|
2410
|
+
count: number;
|
|
2411
|
+
};
|
|
2412
|
+
cache: {
|
|
2413
|
+
/**
|
|
2414
|
+
* @deprecated
|
|
2478
2415
|
*/
|
|
2479
|
-
|
|
2416
|
+
dir: string;
|
|
2417
|
+
} | false;
|
|
2418
|
+
sequence: {
|
|
2419
|
+
sequencer: TestSequencerConstructor;
|
|
2420
|
+
hooks: SequenceHooks;
|
|
2421
|
+
setupFiles: SequenceSetupFiles;
|
|
2422
|
+
shuffle?: boolean;
|
|
2423
|
+
concurrent?: boolean;
|
|
2424
|
+
seed: number;
|
|
2425
|
+
};
|
|
2426
|
+
typecheck: Omit<TypecheckConfig, 'enabled'> & {
|
|
2427
|
+
enabled: boolean;
|
|
2428
|
+
};
|
|
2429
|
+
runner?: string;
|
|
2430
|
+
maxWorkers: number;
|
|
2431
|
+
minWorkers: number;
|
|
2432
|
+
}
|
|
2433
|
+
type NonProjectOptions = 'shard' | 'watch' | 'run' | 'cache' | 'update' | 'reporters' | 'outputFile' | 'teardownTimeout' | 'silent' | 'forceRerunTriggers' | 'testNamePattern' | 'ui' | 'open' | 'uiBase' | 'snapshotFormat' | 'resolveSnapshotPath' | 'passWithNoTests' | 'onConsoleLog' | 'onStackTrace' | 'dangerouslyIgnoreUnhandledErrors' | 'slowTestThreshold' | 'inspect' | 'inspectBrk' | 'coverage' | 'maxWorkers' | 'minWorkers' | 'fileParallelism';
|
|
2434
|
+
type ProjectConfig = Omit<UserConfig, NonProjectOptions | 'sequencer' | 'deps' | 'poolOptions'> & {
|
|
2435
|
+
sequencer?: Omit<SequenceOptions, 'sequencer' | 'seed'>;
|
|
2436
|
+
deps?: Omit<DepsOptions, 'moduleDirectories'>;
|
|
2437
|
+
poolOptions?: {
|
|
2438
|
+
threads?: Pick<NonNullable<PoolOptions['threads']>, 'singleThread' | 'isolate'>;
|
|
2439
|
+
vmThreads?: Pick<NonNullable<PoolOptions['vmThreads']>, 'singleThread'>;
|
|
2440
|
+
forks?: Pick<NonNullable<PoolOptions['forks']>, 'singleFork' | 'isolate'>;
|
|
2480
2441
|
};
|
|
2442
|
+
};
|
|
2443
|
+
type ResolvedProjectConfig = Omit<ResolvedConfig, NonProjectOptions>;
|
|
2444
|
+
interface UserWorkspaceConfig extends UserConfig$1 {
|
|
2445
|
+
test?: ProjectConfig;
|
|
2446
|
+
}
|
|
2447
|
+
type UserProjectConfigFn = (env: ConfigEnv) => UserWorkspaceConfig | Promise<UserWorkspaceConfig>;
|
|
2448
|
+
type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
|
|
2449
|
+
type WorkspaceProjectConfiguration = string | (UserProjectConfigExport & {
|
|
2481
2450
|
/**
|
|
2482
|
-
*
|
|
2483
|
-
* @example
|
|
2484
|
-
* ```ts
|
|
2485
|
-
* // vitest.config.ts
|
|
2486
|
-
* export default defineConfig({
|
|
2487
|
-
* test: {
|
|
2488
|
-
* provide: {
|
|
2489
|
-
* someKey: 'someValue'
|
|
2490
|
-
* }
|
|
2491
|
-
* }
|
|
2492
|
-
* })
|
|
2493
|
-
* ```
|
|
2494
|
-
* ```ts
|
|
2495
|
-
* // test file
|
|
2496
|
-
* import { inject } from 'vitest'
|
|
2497
|
-
* const value = inject('someKey') // 'someValue'
|
|
2498
|
-
* ```
|
|
2451
|
+
* Relative path to the extendable config. All other options will be merged with this config.
|
|
2452
|
+
* @example '../vite.config.ts'
|
|
2499
2453
|
*/
|
|
2500
|
-
|
|
2454
|
+
extends?: string;
|
|
2455
|
+
});
|
|
2456
|
+
|
|
2457
|
+
declare class TestProject {
|
|
2501
2458
|
/**
|
|
2502
|
-
*
|
|
2459
|
+
* The global vitest instance.
|
|
2460
|
+
* @experimental The public Vitest API is experimental and does not follow semver.
|
|
2503
2461
|
*/
|
|
2504
|
-
|
|
2505
|
-
/**
|
|
2506
|
-
* Throw an error if tests don't have any expect() assertions.
|
|
2507
|
-
*/
|
|
2508
|
-
requireAssertions?: boolean;
|
|
2509
|
-
/**
|
|
2510
|
-
* Default options for expect.poll()
|
|
2511
|
-
*/
|
|
2512
|
-
poll?: {
|
|
2513
|
-
/**
|
|
2514
|
-
* Timeout in milliseconds
|
|
2515
|
-
* @default 1000
|
|
2516
|
-
*/
|
|
2517
|
-
timeout?: number;
|
|
2518
|
-
/**
|
|
2519
|
-
* Polling interval in milliseconds
|
|
2520
|
-
* @default 50
|
|
2521
|
-
*/
|
|
2522
|
-
interval?: number;
|
|
2523
|
-
};
|
|
2524
|
-
};
|
|
2462
|
+
readonly vitest: Vitest;
|
|
2525
2463
|
/**
|
|
2526
|
-
*
|
|
2527
|
-
*
|
|
2464
|
+
* The workspace project this test project is associated with.
|
|
2465
|
+
* @experimental The public Vitest API is experimental and does not follow semver.
|
|
2528
2466
|
*/
|
|
2529
|
-
|
|
2467
|
+
readonly workspaceProject: WorkspaceProject;
|
|
2530
2468
|
/**
|
|
2531
|
-
*
|
|
2469
|
+
* Resolved project configuration.
|
|
2532
2470
|
*/
|
|
2533
|
-
|
|
2471
|
+
readonly config: ResolvedProjectConfig;
|
|
2534
2472
|
/**
|
|
2535
|
-
*
|
|
2536
|
-
*
|
|
2537
|
-
* @default 0
|
|
2473
|
+
* Resolved global configuration. If there are no workspace projects, this will be the same as `config`.
|
|
2538
2474
|
*/
|
|
2539
|
-
|
|
2475
|
+
readonly globalConfig: ResolvedConfig;
|
|
2540
2476
|
/**
|
|
2541
|
-
*
|
|
2477
|
+
* The name of the project or an empty string if not set.
|
|
2542
2478
|
*/
|
|
2543
|
-
|
|
2479
|
+
readonly name: string;
|
|
2480
|
+
constructor(workspaceProject: WorkspaceProject);
|
|
2544
2481
|
/**
|
|
2545
|
-
*
|
|
2546
|
-
* This is also required for console log preview on Vitest UI.
|
|
2547
|
-
* However, disabling such interception might help when you want to debug a code with normal synchronus terminal console logging.
|
|
2548
|
-
*
|
|
2549
|
-
* This option has no effect on browser pool since Vitest preserves original logging on browser devtools.
|
|
2550
|
-
*
|
|
2551
|
-
* @default false
|
|
2482
|
+
* Serialized project configuration. This is the config that tests receive.
|
|
2552
2483
|
*/
|
|
2553
|
-
|
|
2484
|
+
get serializedConfig(): SerializedConfig;
|
|
2554
2485
|
/**
|
|
2555
|
-
*
|
|
2556
|
-
*
|
|
2557
|
-
* @default false
|
|
2486
|
+
* Custom context provided to the project.
|
|
2558
2487
|
*/
|
|
2559
|
-
|
|
2488
|
+
context(): ProvidedContext;
|
|
2560
2489
|
/**
|
|
2561
|
-
*
|
|
2562
|
-
*
|
|
2563
|
-
* @default false
|
|
2490
|
+
* Provide a custom serializable context to the project. This context will be available for tests once they run.
|
|
2564
2491
|
*/
|
|
2565
|
-
|
|
2492
|
+
provide<T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]): void;
|
|
2493
|
+
toJSON(): SerializedTestProject;
|
|
2566
2494
|
}
|
|
2567
|
-
interface
|
|
2495
|
+
interface SerializedTestProject {
|
|
2496
|
+
name: string;
|
|
2497
|
+
serializedConfig: SerializedConfig;
|
|
2498
|
+
context: ProvidedContext;
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
declare class TestSpecification {
|
|
2568
2502
|
/**
|
|
2569
|
-
*
|
|
2503
|
+
* @deprecated use `project` instead
|
|
2570
2504
|
*/
|
|
2571
|
-
|
|
2505
|
+
readonly 0: WorkspaceProject;
|
|
2572
2506
|
/**
|
|
2573
|
-
*
|
|
2507
|
+
* @deprecated use `moduleId` instead
|
|
2574
2508
|
*/
|
|
2575
|
-
|
|
2509
|
+
readonly 1: string;
|
|
2576
2510
|
/**
|
|
2577
|
-
*
|
|
2578
|
-
*
|
|
2579
|
-
* @default 'tsc'
|
|
2511
|
+
* @deprecated use `pool` instead
|
|
2580
2512
|
*/
|
|
2581
|
-
|
|
2513
|
+
readonly 2: {
|
|
2514
|
+
pool: Pool;
|
|
2515
|
+
};
|
|
2516
|
+
readonly project: TestProject;
|
|
2517
|
+
readonly moduleId: string;
|
|
2518
|
+
readonly pool: Pool;
|
|
2519
|
+
constructor(workspaceProject: WorkspaceProject, moduleId: string, pool: Pool);
|
|
2520
|
+
toJSON(): SerializedTestSpecification;
|
|
2582
2521
|
/**
|
|
2583
|
-
*
|
|
2584
|
-
*
|
|
2585
|
-
* @default ['**\/*.{test,spec}-d.?(c|m)[jt]s?(x)']
|
|
2522
|
+
* for backwards compatibility
|
|
2523
|
+
* @deprecated
|
|
2586
2524
|
*/
|
|
2587
|
-
|
|
2525
|
+
[Symbol.iterator](): Generator<string | WorkspaceProject, void, unknown>;
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
/**
|
|
2529
|
+
* @deprecated use TestSpecification instead
|
|
2530
|
+
*/
|
|
2531
|
+
type WorkspaceSpec = TestSpecification & [
|
|
2588
2532
|
/**
|
|
2589
|
-
*
|
|
2590
|
-
*
|
|
2591
|
-
* @default ['**\/node_modules/**', '**\/dist/**', '**\/cypress/**', '**\/.{idea,git,cache,output,temp}/**', '**\/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*']
|
|
2533
|
+
* @deprecated use spec.project instead
|
|
2592
2534
|
*/
|
|
2593
|
-
|
|
2535
|
+
project: WorkspaceProject,
|
|
2594
2536
|
/**
|
|
2595
|
-
*
|
|
2596
|
-
* If you have it enabled in tsconfig, this will not overwrite it.
|
|
2537
|
+
* @deprecated use spec.moduleId instead
|
|
2597
2538
|
*/
|
|
2598
|
-
|
|
2539
|
+
file: string,
|
|
2599
2540
|
/**
|
|
2600
|
-
*
|
|
2541
|
+
* @deprecated use spec.pool instead
|
|
2601
2542
|
*/
|
|
2602
|
-
|
|
2543
|
+
options: {
|
|
2544
|
+
pool: Pool;
|
|
2545
|
+
}
|
|
2546
|
+
];
|
|
2547
|
+
type RunWithFiles = (files: WorkspaceSpec[], invalidates?: string[]) => Awaitable$1<void>;
|
|
2548
|
+
interface ProcessPool {
|
|
2549
|
+
name: string;
|
|
2550
|
+
runTests: RunWithFiles;
|
|
2551
|
+
collectTests: RunWithFiles;
|
|
2552
|
+
close?: () => Awaitable$1<void>;
|
|
2553
|
+
}
|
|
2554
|
+
declare function getFilePoolName(project: WorkspaceProject, file: string): Pool;
|
|
2555
|
+
|
|
2556
|
+
interface SuiteResultCache {
|
|
2557
|
+
failed: boolean;
|
|
2558
|
+
duration: number;
|
|
2559
|
+
}
|
|
2560
|
+
declare class ResultsCache {
|
|
2561
|
+
private cache;
|
|
2562
|
+
private workspacesKeyMap;
|
|
2563
|
+
private cachePath;
|
|
2564
|
+
private version;
|
|
2565
|
+
private root;
|
|
2566
|
+
constructor(version: string);
|
|
2567
|
+
getCachePath(): string | null;
|
|
2568
|
+
setConfig(root: string, config: ResolvedConfig['cache']): void;
|
|
2569
|
+
getResults(key: string): SuiteResultCache | undefined;
|
|
2570
|
+
readFromCache(): Promise<void>;
|
|
2571
|
+
updateResults(files: File[]): void;
|
|
2572
|
+
removeFromCache(filepath: string): void;
|
|
2573
|
+
writeToCache(): Promise<void>;
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
type FileStatsCache = Pick<Stats, 'size'>;
|
|
2577
|
+
declare class FilesStatsCache {
|
|
2578
|
+
cache: Map<string, FileStatsCache>;
|
|
2579
|
+
getStats(key: string): FileStatsCache | undefined;
|
|
2580
|
+
populateStats(root: string, specs: WorkspaceSpec[]): Promise<void>;
|
|
2581
|
+
updateStats(fsPath: string, key: string): Promise<void>;
|
|
2582
|
+
removeStats(fsPath: string): void;
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2585
|
+
declare class VitestCache {
|
|
2586
|
+
results: ResultsCache;
|
|
2587
|
+
stats: FilesStatsCache;
|
|
2588
|
+
constructor(version: string);
|
|
2589
|
+
getFileTestResults(key: string): SuiteResultCache | undefined;
|
|
2590
|
+
getFileStats(key: string): {
|
|
2591
|
+
size: number;
|
|
2592
|
+
} | undefined;
|
|
2593
|
+
static resolveCacheDir(root: string, dir?: string, projectName?: string): string;
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
declare class VitestPackageInstaller {
|
|
2597
|
+
isPackageExists(name: string, options?: {
|
|
2598
|
+
paths?: string[];
|
|
2599
|
+
}): boolean;
|
|
2600
|
+
ensureInstalled(dependency: string, root: string, version?: string): Promise<boolean>;
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
declare class StateManager {
|
|
2604
|
+
filesMap: Map<string, File[]>;
|
|
2605
|
+
pathsSet: Set<string>;
|
|
2606
|
+
idMap: Map<string, Task>;
|
|
2607
|
+
taskFileMap: WeakMap<Task, File>;
|
|
2608
|
+
errorsSet: Set<unknown>;
|
|
2609
|
+
processTimeoutCauses: Set<string>;
|
|
2610
|
+
reportedTasksMap: WeakMap<Task, TestCase | TestSuite | TestModule>;
|
|
2611
|
+
catchError(err: unknown, type: string): void;
|
|
2612
|
+
clearErrors(): void;
|
|
2613
|
+
getUnhandledErrors(): unknown[];
|
|
2614
|
+
addProcessTimeoutCause(cause: string): void;
|
|
2615
|
+
getProcessTimeoutCauses(): string[];
|
|
2616
|
+
getPaths(): string[];
|
|
2603
2617
|
/**
|
|
2604
|
-
*
|
|
2618
|
+
* Return files that were running or collected.
|
|
2605
2619
|
*/
|
|
2606
|
-
|
|
2620
|
+
getFiles(keys?: string[]): File[];
|
|
2621
|
+
getFilepaths(): string[];
|
|
2622
|
+
getFailedFilepaths(): string[];
|
|
2623
|
+
collectPaths(paths?: string[]): void;
|
|
2624
|
+
collectFiles(project: WorkspaceProject, files?: File[]): void;
|
|
2625
|
+
clearFiles(project: WorkspaceProject, paths?: string[]): void;
|
|
2626
|
+
updateId(task: Task, project: WorkspaceProject): void;
|
|
2627
|
+
getReportedEntity(task: Task): TestCase | TestSuite | TestModule | undefined;
|
|
2628
|
+
updateTasks(packs: TaskResultPack[]): void;
|
|
2629
|
+
updateUserLog(log: UserConsoleLog): void;
|
|
2630
|
+
getCountOfFailedTests(): number;
|
|
2631
|
+
cancelFiles(files: string[], project: WorkspaceProject): void;
|
|
2607
2632
|
}
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2633
|
+
|
|
2634
|
+
interface VitestOptions {
|
|
2635
|
+
packageInstaller?: VitestPackageInstaller;
|
|
2636
|
+
stdin?: NodeJS.ReadStream;
|
|
2637
|
+
stdout?: NodeJS.WriteStream | Writable;
|
|
2638
|
+
stderr?: NodeJS.WriteStream | Writable;
|
|
2639
|
+
}
|
|
2640
|
+
declare class Vitest {
|
|
2641
|
+
readonly mode: VitestRunMode;
|
|
2642
|
+
version: string;
|
|
2643
|
+
config: ResolvedConfig;
|
|
2644
|
+
configOverride: Partial<ResolvedConfig>;
|
|
2645
|
+
server: ViteDevServer;
|
|
2646
|
+
state: StateManager;
|
|
2647
|
+
snapshot: SnapshotManager;
|
|
2648
|
+
cache: VitestCache;
|
|
2649
|
+
reporters: Reporter[];
|
|
2650
|
+
coverageProvider: CoverageProvider | null | undefined;
|
|
2651
|
+
logger: Logger;
|
|
2652
|
+
pool: ProcessPool | undefined;
|
|
2653
|
+
vitenode: ViteNodeServer;
|
|
2654
|
+
invalidates: Set<string>;
|
|
2655
|
+
changedTests: Set<string>;
|
|
2656
|
+
watchedTests: Set<string>;
|
|
2657
|
+
filenamePattern?: string;
|
|
2658
|
+
runningPromise?: Promise<void>;
|
|
2659
|
+
closingPromise?: Promise<void>;
|
|
2660
|
+
isCancelling: boolean;
|
|
2661
|
+
isFirstRun: boolean;
|
|
2662
|
+
restartsCount: number;
|
|
2663
|
+
runner: ViteNodeRunner;
|
|
2664
|
+
packageInstaller: VitestPackageInstaller;
|
|
2665
|
+
private coreWorkspaceProject;
|
|
2666
|
+
private resolvedProjects;
|
|
2667
|
+
projects: WorkspaceProject[];
|
|
2668
|
+
distPath: string;
|
|
2669
|
+
private _cachedSpecs;
|
|
2670
|
+
/** @deprecated use `_cachedSpecs` */
|
|
2671
|
+
projectTestFiles: Map<string, WorkspaceSpec[]>;
|
|
2672
|
+
/** @private */
|
|
2673
|
+
_browserLastPort: number;
|
|
2674
|
+
constructor(mode: VitestRunMode, options?: VitestOptions);
|
|
2675
|
+
private _onRestartListeners;
|
|
2676
|
+
private _onClose;
|
|
2677
|
+
private _onSetServer;
|
|
2678
|
+
private _onCancelListeners;
|
|
2679
|
+
setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
|
|
2680
|
+
provide<T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]): void;
|
|
2638
2681
|
/**
|
|
2639
|
-
*
|
|
2640
|
-
* Requires initialized git repository
|
|
2641
|
-
* @default false
|
|
2682
|
+
* @deprecated internal, use `_createCoreProject` instead
|
|
2642
2683
|
*/
|
|
2643
|
-
|
|
2684
|
+
createCoreProject(): Promise<WorkspaceProject>;
|
|
2644
2685
|
/**
|
|
2645
|
-
*
|
|
2646
|
-
* Will divide tests into a `count` numbers, and run only the `indexed` part.
|
|
2647
|
-
* Cannot be used with enabled watch.
|
|
2648
|
-
* @example --shard=2/3
|
|
2686
|
+
* @internal
|
|
2649
2687
|
*/
|
|
2650
|
-
|
|
2688
|
+
_createCoreProject(): Promise<WorkspaceProject>;
|
|
2689
|
+
getCoreWorkspaceProject(): WorkspaceProject;
|
|
2651
2690
|
/**
|
|
2652
|
-
*
|
|
2691
|
+
* @deprecated use Reported Task API instead
|
|
2653
2692
|
*/
|
|
2654
|
-
|
|
2693
|
+
getProjectByTaskId(taskId: string): WorkspaceProject;
|
|
2694
|
+
getProjectByName(name?: string): WorkspaceProject;
|
|
2695
|
+
private getWorkspaceConfigPath;
|
|
2696
|
+
private resolveWorkspace;
|
|
2697
|
+
private initCoverageProvider;
|
|
2698
|
+
private initBrowserProviders;
|
|
2699
|
+
mergeReports(): Promise<void>;
|
|
2700
|
+
collect(filters?: string[]): Promise<{
|
|
2701
|
+
tests: File[];
|
|
2702
|
+
errors: unknown[];
|
|
2703
|
+
}>;
|
|
2704
|
+
listFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
2705
|
+
start(filters?: string[]): Promise<void>;
|
|
2706
|
+
init(): Promise<void>;
|
|
2707
|
+
private getTestDependencies;
|
|
2708
|
+
filterTestsBySource(specs: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
|
|
2655
2709
|
/**
|
|
2656
|
-
*
|
|
2710
|
+
* @deprecated remove when vscode extension supports "getFileWorkspaceSpecs"
|
|
2657
2711
|
*/
|
|
2658
|
-
|
|
2712
|
+
getProjectsByTestFile(file: string): WorkspaceSpec[];
|
|
2713
|
+
getFileWorkspaceSpecs(file: string): WorkspaceSpec[];
|
|
2714
|
+
initializeGlobalSetup(paths: TestSpecification[]): Promise<void>;
|
|
2715
|
+
runFiles(specs: TestSpecification[], allTestsRun: boolean): Promise<void>;
|
|
2716
|
+
collectFiles(specs: WorkspaceSpec[]): Promise<void>;
|
|
2717
|
+
cancelCurrentRun(reason: CancelReason): Promise<void>;
|
|
2718
|
+
rerunFiles(files?: string[], trigger?: string): Promise<void>;
|
|
2719
|
+
changeProjectName(pattern: string): Promise<void>;
|
|
2720
|
+
changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
|
|
2721
|
+
changeFilenamePattern(pattern: string, files?: string[]): Promise<void>;
|
|
2722
|
+
rerunFailed(): Promise<void>;
|
|
2723
|
+
updateSnapshot(files?: string[]): Promise<void>;
|
|
2724
|
+
private _rerunTimer;
|
|
2725
|
+
private scheduleRerun;
|
|
2726
|
+
getModuleProjects(filepath: string): WorkspaceProject[];
|
|
2659
2727
|
/**
|
|
2660
|
-
*
|
|
2728
|
+
* Watch only the specified tests. If no tests are provided, all tests will be watched.
|
|
2661
2729
|
*/
|
|
2662
|
-
|
|
2730
|
+
watchTests(tests: string[]): void;
|
|
2731
|
+
private updateLastChanged;
|
|
2732
|
+
onChange: (id: string) => void;
|
|
2733
|
+
onUnlink: (id: string) => void;
|
|
2734
|
+
onAdd: (id: string) => Promise<void>;
|
|
2735
|
+
private unregisterWatcher;
|
|
2736
|
+
private registerWatcher;
|
|
2663
2737
|
/**
|
|
2664
|
-
*
|
|
2738
|
+
* @returns A value indicating whether rerun is needed (changedTests was mutated)
|
|
2665
2739
|
*/
|
|
2666
|
-
|
|
2740
|
+
private handleFileChanged;
|
|
2741
|
+
private reportCoverage;
|
|
2742
|
+
close(): Promise<void>;
|
|
2667
2743
|
/**
|
|
2668
|
-
*
|
|
2744
|
+
* Close the thread pool and exit the process
|
|
2669
2745
|
*/
|
|
2670
|
-
|
|
2746
|
+
exit(force?: boolean): Promise<void>;
|
|
2747
|
+
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
|
|
2748
|
+
getTestFilepaths(): Promise<string[]>;
|
|
2749
|
+
globTestSpecs(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
2671
2750
|
/**
|
|
2672
|
-
*
|
|
2673
|
-
* @default '.vitest-reports'
|
|
2751
|
+
* @deprecated use globTestSpecs instead
|
|
2674
2752
|
*/
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
setupFiles: string[];
|
|
2683
|
-
snapshotEnvironment?: string;
|
|
2684
|
-
config?: string;
|
|
2685
|
-
filters?: string[];
|
|
2686
|
-
testNamePattern?: RegExp;
|
|
2687
|
-
related?: string[];
|
|
2688
|
-
coverage: ResolvedCoverageOptions;
|
|
2689
|
-
snapshotOptions: SnapshotStateOptions;
|
|
2690
|
-
browser: ResolvedBrowserOptions;
|
|
2691
|
-
pool: Pool;
|
|
2692
|
-
poolOptions?: ResolvedPoolOptions;
|
|
2693
|
-
reporters: (InlineReporter | ReporterWithOptions)[];
|
|
2694
|
-
defines: Record<string, any>;
|
|
2695
|
-
api?: ApiConfig;
|
|
2696
|
-
cliExclude?: string[];
|
|
2697
|
-
benchmark?: Required<Omit<BenchmarkUserOptions, 'outputFile' | 'compare' | 'outputJson'>> & Pick<BenchmarkUserOptions, 'outputFile' | 'compare' | 'outputJson'>;
|
|
2698
|
-
shard?: {
|
|
2699
|
-
index: number;
|
|
2700
|
-
count: number;
|
|
2701
|
-
};
|
|
2702
|
-
cache: {
|
|
2703
|
-
/**
|
|
2704
|
-
* @deprecated
|
|
2705
|
-
*/
|
|
2706
|
-
dir: string;
|
|
2707
|
-
} | false;
|
|
2708
|
-
sequence: {
|
|
2709
|
-
sequencer: TestSequencerConstructor;
|
|
2710
|
-
hooks: SequenceHooks;
|
|
2711
|
-
setupFiles: SequenceSetupFiles;
|
|
2712
|
-
shuffle?: boolean;
|
|
2713
|
-
concurrent?: boolean;
|
|
2714
|
-
seed: number;
|
|
2715
|
-
};
|
|
2716
|
-
typecheck: Omit<TypecheckConfig, 'enabled'> & {
|
|
2717
|
-
enabled: boolean;
|
|
2718
|
-
};
|
|
2719
|
-
runner?: string;
|
|
2720
|
-
maxWorkers: number;
|
|
2721
|
-
minWorkers: number;
|
|
2722
|
-
}
|
|
2723
|
-
type NonProjectOptions = 'shard' | 'watch' | 'run' | 'cache' | 'update' | 'reporters' | 'outputFile' | 'teardownTimeout' | 'silent' | 'forceRerunTriggers' | 'testNamePattern' | 'ui' | 'open' | 'uiBase' | 'snapshotFormat' | 'resolveSnapshotPath' | 'passWithNoTests' | 'onConsoleLog' | 'onStackTrace' | 'dangerouslyIgnoreUnhandledErrors' | 'slowTestThreshold' | 'inspect' | 'inspectBrk' | 'coverage' | 'maxWorkers' | 'minWorkers' | 'fileParallelism';
|
|
2724
|
-
type ProjectConfig = Omit<UserConfig, NonProjectOptions | 'sequencer' | 'deps' | 'poolOptions'> & {
|
|
2725
|
-
sequencer?: Omit<SequenceOptions, 'sequencer' | 'seed'>;
|
|
2726
|
-
deps?: Omit<DepsOptions, 'moduleDirectories'>;
|
|
2727
|
-
poolOptions?: {
|
|
2728
|
-
threads?: Pick<NonNullable<PoolOptions['threads']>, 'singleThread' | 'isolate'>;
|
|
2729
|
-
vmThreads?: Pick<NonNullable<PoolOptions['vmThreads']>, 'singleThread'>;
|
|
2730
|
-
forks?: Pick<NonNullable<PoolOptions['forks']>, 'singleFork' | 'isolate'>;
|
|
2731
|
-
};
|
|
2732
|
-
};
|
|
2733
|
-
type ResolvedProjectConfig = Omit<ResolvedConfig, NonProjectOptions>;
|
|
2734
|
-
interface UserWorkspaceConfig extends UserConfig$1 {
|
|
2735
|
-
test?: ProjectConfig;
|
|
2753
|
+
globTestFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
2754
|
+
private ensureSpecCached;
|
|
2755
|
+
shouldKeepServer(): boolean;
|
|
2756
|
+
onServerRestart(fn: OnServerRestartHandler): void;
|
|
2757
|
+
onAfterSetServer(fn: OnServerRestartHandler): void;
|
|
2758
|
+
onCancel(fn: (reason: CancelReason) => void): void;
|
|
2759
|
+
onClose(fn: () => void): void;
|
|
2736
2760
|
}
|
|
2737
|
-
type UserProjectConfigFn = (env: ConfigEnv) => UserWorkspaceConfig | Promise<UserWorkspaceConfig>;
|
|
2738
|
-
type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
|
|
2739
|
-
type WorkspaceProjectConfiguration = string | (UserProjectConfigExport & {
|
|
2740
|
-
/**
|
|
2741
|
-
* Relative path to the extendable config. All other options will be merged with this config.
|
|
2742
|
-
* @example '../vite.config.ts'
|
|
2743
|
-
*/
|
|
2744
|
-
extends?: string;
|
|
2745
|
-
});
|
|
2746
2761
|
|
|
2747
|
-
export { type
|
|
2762
|
+
export { type HTMLOptions as $, type ApiConfig as A, type BaseCoverageOptions as B, type CoverageProvider as C, type DepsOptimizationOptions as D, type ResolvedConfig as E, type ProjectConfig as F, type BenchmarkUserOptions as G, type VitestOptions as H, type InlineConfig as I, WorkspaceProject as J, type TestSequencer as K, Logger as L, type WorkspaceSpec as M, TestModule as N, type ModuleDiagnostic as O, type Pool as P, VitestPackageInstaller as Q, type ResolvedCoverageOptions as R, type SerializedTestSpecification as S, type TscErrorInfo as T, type UserWorkspaceConfig as U, Vitest as V, type WorkspaceProjectConfiguration as W, type ProcessPool as X, getFilePoolName as Y, TestProject as Z, type SerializedTestProject as _, type ReportContext as a, type JsonOptions$1 as a0, type JUnitOptions as a1, TestCase as a2, TestSuite as a3, type TaskOptions as a4, TestCollection as a5, type TestDiagnostic as a6, type TestResult as a7, type TestResultFailed as a8, type TestResultPassed as a9, VerboseReporter as aA, BaseReporter as aB, TestFile as aC, type FileDiagnostic as aD, ReportersMap as aE, type BuiltinReporters as aF, type BuiltinReporterOptions as aG, type JsonAssertionResult as aH, type JsonTestResult as aI, type JsonTestResults as aJ, BenchmarkReportsMap as aK, type BenchmarkBuiltinReporters as aL, type TestResultSkipped as aa, type TestSequencerConstructor as ab, TestSpecification as ac, type BrowserBuiltinProvider as ad, type BrowserCommand as ae, type BrowserCommandContext as af, type BrowserOrchestrator as ag, type BrowserProvider as ah, type BrowserProviderInitializationOptions as ai, type BrowserProviderModule as aj, type BrowserProviderOptions as ak, type BrowserServer as al, type BrowserServerState as am, type BrowserServerStateContext as an, type CDPSession as ao, type ResolvedBrowserOptions as ap, type ResolvedProjectConfig as aq, BasicReporter as ar, DefaultReporter as as, DotReporter as at, GithubActionsReporter as au, HangingProcessReporter as av, JsonReporter as aw, JUnitReporter as ax, TapFlatReporter as ay, TapReporter as az, type CoverageProviderModule as b, type CoverageV8Options as c, type UserProjectConfigFn as d, type UserProjectConfigExport as e, type VitestEnvironment as f, type RawErrsMap as g, type CollectLineNumbers as h, type CollectLines as i, type RootAndTarget as j, type Context as k, type CoverageReporter as l, type CoverageProviderName as m, type CoverageOptions as n, type CoverageIstanbulOptions as o, type CustomProviderOptions as p, type Reporter as q, type BrowserScript as r, type BrowserConfigOptions as s, type BuiltinEnvironment as t, type PoolOptions as u, type CSSModuleScopeStrategy as v, type VitestRunMode as w, type TransformModePatterns as x, type TypecheckConfig as y, type UserConfig as z };
|