vitest 2.2.0-beta.1 → 3.0.0-beta.1
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/dist/browser.d.ts +8 -8
- package/dist/browser.js +1 -1
- package/dist/chunks/{RandomSequencer.CMRlh2v4.js → RandomSequencer.gisBJ77r.js} +11 -3
- package/dist/chunks/{base.BS0HhLXd.js → base.CkcgFVQd.js} +8 -3
- package/dist/chunks/{benchmark.geERunq4.d.ts → benchmark.CFFwLv-O.d.ts} +2 -2
- package/dist/chunks/{cac.Z91LBqmg.js → cac.CWCZimpS.js} +7 -7
- package/dist/chunks/{cli-api.DVJJMJHj.js → cli-api.BKUOv0Nc.js} +928 -661
- package/dist/chunks/{config.CPguQ7J1.d.ts → config.BTPBhmK5.d.ts} +1 -1
- package/dist/chunks/{creator.IIqd8RWT.js → creator.DcAcUhMD.js} +1 -4
- package/dist/chunks/{globals.BCGEw6ON.js → globals.DJTzb7B3.js} +2 -2
- package/dist/chunks/{index.DD5eTY2y.js → index.BqHViJW9.js} +1 -1
- package/dist/chunks/{index.BjjsHdBb.js → index.CkOJwybT.js} +1 -1
- package/dist/chunks/{index.DLRzErGF.js → index.DKe7vK-G.js} +708 -548
- package/dist/chunks/{index.CqYx2Nsr.js → index.DQboAxJm.js} +23 -14
- package/dist/chunks/{inspector.70d6emsh.js → inspector.DKLceBVD.js} +1 -1
- package/dist/chunks/{reporters.B_9uUTGW.d.ts → reporters.BZbwTvrM.d.ts} +1252 -1234
- package/dist/chunks/{resolveConfig.CQIc6fe7.js → resolveConfig.3rGGWga5.js} +88 -56
- package/dist/chunks/{runBaseTests.B7hcVT-s.js → runBaseTests.C6huCAng.js} +6 -6
- package/dist/chunks/{setup-common.BfGt8K-K.js → setup-common.B5ClyS48.js} +1 -1
- package/dist/chunks/{suite.B2jumIFP.d.ts → suite.BJU7kdY9.d.ts} +4 -4
- package/dist/chunks/{utils.DNoFbBUZ.js → utils.CMUTX-p8.js} +20 -23
- package/dist/chunks/{vi.BlPttogV.js → vi.CZKezqeD.js} +18 -13
- package/dist/chunks/{vite.Bvms8Xir.d.ts → vite.DIfmneq0.d.ts} +1 -1
- package/dist/chunks/{vm.Zr4qWzDJ.js → vm.DGhTouO3.js} +10 -1
- package/dist/chunks/{worker.9VY11NZs.d.ts → worker.CmzGeuVD.d.ts} +3 -3
- package/dist/chunks/{worker.Qz1UB4Fv.d.ts → worker.umPNbBNk.d.ts} +1 -1
- package/dist/cli.js +1 -1
- package/dist/config.cjs +1 -10
- package/dist/config.d.ts +11 -11
- package/dist/config.js +1 -10
- package/dist/coverage.d.ts +7 -7
- package/dist/coverage.js +4 -4
- package/dist/execute.d.ts +3 -3
- package/dist/index.d.ts +26 -17
- package/dist/index.js +2 -2
- package/dist/node.d.ts +16 -20
- package/dist/node.js +7 -7
- package/dist/reporters.d.ts +7 -7
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +3 -4
- package/dist/runners.js +9 -14
- package/dist/suite.d.ts +2 -2
- package/dist/worker.js +1 -1
- package/dist/workers/forks.js +1 -1
- package/dist/workers/runVmTests.js +6 -6
- package/dist/workers/threads.js +1 -1
- package/dist/workers/vmForks.js +1 -1
- package/dist/workers/vmThreads.js +1 -1
- package/dist/workers.d.ts +3 -3
- package/dist/workers.js +3 -3
- package/package.json +22 -22
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import * as _vitest_runner from '@vitest/runner';
|
|
2
|
-
import { File, TaskResultPack, Task, Test,
|
|
3
|
-
import { b as Awaitable, U as UserConsoleLog,
|
|
2
|
+
import { File, TaskResultPack, Task, Test, TaskMeta, Suite, SequenceHooks, SequenceSetupFiles, CancelReason } from '@vitest/runner';
|
|
3
|
+
import { b as Awaitable, U as UserConsoleLog, A as AfterSuiteRunMeta, c as Arrayable$1, f as EnvironmentOptions, P as ProvidedContext, h as OnTestsRerunHandler, d as ArgumentsType, O as OnServerRestartHandler } from './environment.CT0jpO-1.js';
|
|
4
4
|
import { Writable } from 'node:stream';
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { TransformResult as TransformResult$1, ServerOptions, DepOptimizationConfig, AliasOptions, UserConfig as UserConfig$1, ConfigEnv, ViteDevServer, ModuleNode } from 'vite';
|
|
6
|
+
import { TestError, ParsedStack, Arrayable, ErrorWithDiff, Awaitable as Awaitable$1 } from '@vitest/utils';
|
|
7
|
+
import { RawSourceMap, ViteNodeServerOptions } from 'vite-node';
|
|
8
|
+
import { StackTraceParserOptions } from '@vitest/utils/source-map';
|
|
9
|
+
import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.BTPBhmK5.js';
|
|
9
10
|
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
|
10
11
|
import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
|
|
11
12
|
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
12
|
-
import { RawSourceMap, ViteNodeServerOptions } from 'vite-node';
|
|
13
13
|
import * as chai from 'chai';
|
|
14
|
-
import {
|
|
14
|
+
import { B as BenchmarkResult } from './benchmark.CFFwLv-O.js';
|
|
15
15
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
16
16
|
import { ViteNodeServer } from 'vite-node/server';
|
|
17
|
-
import { B as BenchmarkResult } from './benchmark.geERunq4.js';
|
|
18
17
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
19
18
|
import { Stats } from 'node:fs';
|
|
20
19
|
|
|
@@ -29,8 +28,6 @@ type SerializedTestSpecification = [
|
|
|
29
28
|
}
|
|
30
29
|
];
|
|
31
30
|
|
|
32
|
-
type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
|
|
33
|
-
|
|
34
31
|
interface Reporter {
|
|
35
32
|
onInit?: (ctx: Vitest) => void;
|
|
36
33
|
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
@@ -56,12 +53,10 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
56
53
|
failedUnwatchedFiles: Task[];
|
|
57
54
|
isTTY: boolean;
|
|
58
55
|
ctx: Vitest;
|
|
56
|
+
renderSucceed: boolean;
|
|
59
57
|
protected verbose: boolean;
|
|
60
58
|
private _filesInWatchMode;
|
|
61
59
|
private _timeStart;
|
|
62
|
-
private _lastRunTimeout;
|
|
63
|
-
private _lastRunTimer;
|
|
64
|
-
private _lastRunCount;
|
|
65
60
|
constructor(options?: BaseOptions);
|
|
66
61
|
onInit(ctx: Vitest): void;
|
|
67
62
|
log(...messages: any): void;
|
|
@@ -72,7 +67,6 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
72
67
|
protected printTask(task: Task): void;
|
|
73
68
|
private getDurationPrefix;
|
|
74
69
|
onWatcherStart(files?: File[], errors?: unknown[]): void;
|
|
75
|
-
private resetLastRunLog;
|
|
76
70
|
onWatcherRerun(files: string[], trigger?: string): void;
|
|
77
71
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
78
72
|
onTestRemoved(trigger?: string): void;
|
|
@@ -85,642 +79,149 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
85
79
|
private printTaskErrors;
|
|
86
80
|
}
|
|
87
81
|
|
|
88
|
-
interface
|
|
89
|
-
|
|
90
|
-
end: number;
|
|
91
|
-
}
|
|
92
|
-
interface ParsedTest extends Test {
|
|
93
|
-
start: number;
|
|
94
|
-
end: number;
|
|
95
|
-
}
|
|
96
|
-
interface ParsedSuite extends Suite {
|
|
97
|
-
start: number;
|
|
98
|
-
end: number;
|
|
99
|
-
}
|
|
100
|
-
interface LocalCallDefinition {
|
|
101
|
-
start: number;
|
|
102
|
-
end: number;
|
|
103
|
-
name: string;
|
|
104
|
-
type: 'suite' | 'test';
|
|
105
|
-
mode: 'run' | 'skip' | 'only' | 'todo';
|
|
106
|
-
task: ParsedSuite | ParsedFile | ParsedTest;
|
|
82
|
+
interface BlobOptions {
|
|
83
|
+
outputFile?: string;
|
|
107
84
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
85
|
+
declare class BlobReporter implements Reporter {
|
|
86
|
+
ctx: Vitest;
|
|
87
|
+
options: BlobOptions;
|
|
88
|
+
constructor(options: BlobOptions);
|
|
89
|
+
onInit(ctx: Vitest): void;
|
|
90
|
+
onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
|
|
114
91
|
}
|
|
115
92
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
filePath: string;
|
|
119
|
-
errCode: number;
|
|
120
|
-
errMsg: string;
|
|
121
|
-
line: number;
|
|
122
|
-
column: number;
|
|
123
|
-
}
|
|
124
|
-
interface CollectLineNumbers {
|
|
125
|
-
target: number;
|
|
126
|
-
next: number;
|
|
127
|
-
prev?: number;
|
|
93
|
+
interface DefaultReporterOptions extends BaseOptions {
|
|
94
|
+
summary?: boolean;
|
|
128
95
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
96
|
+
declare class DefaultReporter extends BaseReporter {
|
|
97
|
+
private options;
|
|
98
|
+
private summary?;
|
|
99
|
+
constructor(options?: DefaultReporterOptions);
|
|
100
|
+
onInit(ctx: Vitest): void;
|
|
101
|
+
onPathsCollected(paths?: string[]): void;
|
|
102
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
103
|
+
onWatcherRerun(files: string[], trigger?: string): void;
|
|
104
|
+
onFinished(files?: File[], errors?: unknown[]): void;
|
|
135
105
|
}
|
|
136
|
-
type Context = RootAndTarget & {
|
|
137
|
-
rawErrsMap: RawErrsMap;
|
|
138
|
-
openedDirs: Set<string>;
|
|
139
|
-
lastActivePath?: string;
|
|
140
|
-
};
|
|
141
106
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
stacks: ParsedStack[];
|
|
145
|
-
name: string;
|
|
146
|
-
constructor(message: string, stacks: ParsedStack[]);
|
|
107
|
+
interface HTMLOptions {
|
|
108
|
+
outputFile?: string;
|
|
147
109
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
110
|
+
|
|
111
|
+
declare class ReportedTaskImplementation {
|
|
112
|
+
/**
|
|
113
|
+
* Task instance.
|
|
114
|
+
* @experimental Public runner task API is experimental and does not follow semver.
|
|
115
|
+
*/
|
|
116
|
+
readonly task: Task;
|
|
117
|
+
/**
|
|
118
|
+
* The project assosiacted with the test or suite.
|
|
119
|
+
*/
|
|
120
|
+
readonly project: TestProject;
|
|
121
|
+
/**
|
|
122
|
+
* Unique identifier.
|
|
123
|
+
* This ID is deterministic and will be the same for the same test across multiple runs.
|
|
124
|
+
* The ID is based on the project name, module url and test position.
|
|
125
|
+
*/
|
|
126
|
+
readonly id: string;
|
|
127
|
+
/**
|
|
128
|
+
* Location in the module where the test or suite is defined.
|
|
129
|
+
*/
|
|
130
|
+
readonly location: {
|
|
131
|
+
line: number;
|
|
132
|
+
column: number;
|
|
133
|
+
} | undefined;
|
|
134
|
+
protected constructor(task: Task, project: TestProject);
|
|
135
|
+
/**
|
|
136
|
+
* Creates a new reported task instance and stores it in the project's state for future use.
|
|
137
|
+
*/
|
|
138
|
+
static register(task: Task, project: TestProject): TestCase | TestSuite | TestModule;
|
|
152
139
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
protected
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
140
|
+
declare class TestCase extends ReportedTaskImplementation {
|
|
141
|
+
#private;
|
|
142
|
+
readonly task: Test;
|
|
143
|
+
readonly type = "test";
|
|
144
|
+
/**
|
|
145
|
+
* Direct reference to the test module where the test or suite is defined.
|
|
146
|
+
*/
|
|
147
|
+
readonly module: TestModule;
|
|
148
|
+
/**
|
|
149
|
+
* Name of the test.
|
|
150
|
+
*/
|
|
151
|
+
readonly name: string;
|
|
152
|
+
/**
|
|
153
|
+
* Options that the test was initiated with.
|
|
154
|
+
*/
|
|
155
|
+
readonly options: TaskOptions;
|
|
156
|
+
/**
|
|
157
|
+
* Parent suite. If the test was called directly inside the module, the parent will be the module itself.
|
|
158
|
+
*/
|
|
159
|
+
readonly parent: TestSuite | TestModule;
|
|
160
|
+
protected constructor(task: Test, project: TestProject);
|
|
161
|
+
/**
|
|
162
|
+
* Full name of the test including all parent suites separated with `>`.
|
|
163
|
+
*/
|
|
164
|
+
get fullName(): string;
|
|
165
|
+
/**
|
|
166
|
+
* Test results. Will be `undefined` if test is not finished yet or was just collected.
|
|
167
|
+
*/
|
|
168
|
+
result(): TestResult | undefined;
|
|
169
|
+
/**
|
|
170
|
+
* Checks if the test did not fail the suite.
|
|
171
|
+
* If the test is not finished yet or was skipped, it will return `true`.
|
|
172
|
+
*/
|
|
173
|
+
ok(): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Custom metadata that was attached to the test during its execution.
|
|
176
|
+
*/
|
|
177
|
+
meta(): TaskMeta;
|
|
178
|
+
/**
|
|
179
|
+
* Useful information about the test like duration, memory usage, etc.
|
|
180
|
+
* Diagnostic is only available after the test has finished.
|
|
181
|
+
*/
|
|
182
|
+
diagnostic(): TestDiagnostic | undefined;
|
|
195
183
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
184
|
+
declare class TestCollection {
|
|
185
|
+
#private;
|
|
186
|
+
constructor(task: Suite | File, project: TestProject);
|
|
187
|
+
/**
|
|
188
|
+
* Returns the test or suite at a specific index in the array.
|
|
189
|
+
*/
|
|
190
|
+
at(index: number): TestCase | TestSuite | undefined;
|
|
191
|
+
/**
|
|
192
|
+
* The number of tests and suites in the collection.
|
|
193
|
+
*/
|
|
194
|
+
get size(): number;
|
|
195
|
+
/**
|
|
196
|
+
* Returns the collection in array form for easier manipulation.
|
|
197
|
+
*/
|
|
198
|
+
array(): (TestCase | TestSuite)[];
|
|
199
|
+
/**
|
|
200
|
+
* Filters all tests that are part of this collection and its children.
|
|
201
|
+
*/
|
|
202
|
+
allTests(state?: TestResult['state'] | 'running'): Generator<TestCase, undefined, void>;
|
|
203
|
+
/**
|
|
204
|
+
* Filters only the tests that are part of this collection.
|
|
205
|
+
*/
|
|
206
|
+
tests(state?: TestResult['state'] | 'running'): Generator<TestCase, undefined, void>;
|
|
207
|
+
/**
|
|
208
|
+
* Filters only the suites that are part of this collection.
|
|
209
|
+
*/
|
|
210
|
+
suites(): Generator<TestSuite, undefined, void>;
|
|
211
|
+
/**
|
|
212
|
+
* Filters all suites that are part of this collection and its children.
|
|
213
|
+
*/
|
|
214
|
+
allSuites(): Generator<TestSuite, undefined, void>;
|
|
215
|
+
[Symbol.iterator](): Generator<TestSuite | TestCase, undefined, void>;
|
|
199
216
|
}
|
|
200
217
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
// Write output but don't hide the cursor
|
|
210
|
-
const log = createLogUpdate(process.stdout, {
|
|
211
|
-
showCursor: true
|
|
212
|
-
});
|
|
213
|
-
```
|
|
214
|
-
*/
|
|
215
|
-
readonly showCursor?: boolean;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
type LogUpdateMethods = {
|
|
219
|
-
/**
|
|
220
|
-
Clear the logged output.
|
|
221
|
-
*/
|
|
222
|
-
clear(): void;
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
Persist the logged output. Useful if you want to start a new log session below the current one.
|
|
226
|
-
*/
|
|
227
|
-
done(): void;
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
Log to `stdout` by overwriting the previous output in the terminal.
|
|
232
|
-
|
|
233
|
-
@param text - The text to log to `stdout`.
|
|
234
|
-
|
|
235
|
-
@example
|
|
236
|
-
```
|
|
237
|
-
import logUpdate from 'log-update';
|
|
238
|
-
|
|
239
|
-
const frames = ['-', '\\', '|', '/'];
|
|
240
|
-
let index = 0;
|
|
241
|
-
|
|
242
|
-
setInterval(() => {
|
|
243
|
-
const frame = frames[index = ++index % frames.length];
|
|
244
|
-
|
|
245
|
-
logUpdate(
|
|
246
|
-
`
|
|
247
|
-
♥♥
|
|
248
|
-
${frame} unicorns ${frame}
|
|
249
|
-
♥♥
|
|
250
|
-
`
|
|
251
|
-
);
|
|
252
|
-
}, 80);
|
|
253
|
-
```
|
|
254
|
-
*/
|
|
255
|
-
declare const logUpdate: ((...text: string[]) => void) & LogUpdateMethods;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
Get a `logUpdate` method that logs to the specified stream.
|
|
260
|
-
|
|
261
|
-
@param stream - The stream to log to.
|
|
262
|
-
|
|
263
|
-
@example
|
|
264
|
-
```
|
|
265
|
-
import {createLogUpdate} from 'log-update';
|
|
266
|
-
|
|
267
|
-
// Write output but don't hide the cursor
|
|
268
|
-
const log = createLogUpdate(process.stdout);
|
|
269
|
-
```
|
|
270
|
-
*/
|
|
271
|
-
declare function createLogUpdate(
|
|
272
|
-
stream: NodeJS.WritableStream,
|
|
273
|
-
options?: Options
|
|
274
|
-
): typeof logUpdate;
|
|
275
|
-
|
|
276
|
-
interface ErrorOptions {
|
|
277
|
-
type?: string;
|
|
278
|
-
fullStack?: boolean;
|
|
279
|
-
project?: WorkspaceProject;
|
|
280
|
-
verbose?: boolean;
|
|
281
|
-
screenshotPaths?: string[];
|
|
282
|
-
task?: Task;
|
|
283
|
-
showCodeFrame?: boolean;
|
|
284
|
-
}
|
|
285
|
-
declare class Logger {
|
|
286
|
-
ctx: Vitest;
|
|
287
|
-
outputStream: NodeJS.WriteStream | Writable;
|
|
288
|
-
errorStream: NodeJS.WriteStream | Writable;
|
|
289
|
-
logUpdate: ReturnType<typeof createLogUpdate>;
|
|
290
|
-
private _clearScreenPending;
|
|
291
|
-
private _highlights;
|
|
292
|
-
console: Console;
|
|
293
|
-
constructor(ctx: Vitest, outputStream?: NodeJS.WriteStream | Writable, errorStream?: NodeJS.WriteStream | Writable);
|
|
294
|
-
log(...args: any[]): void;
|
|
295
|
-
error(...args: any[]): void;
|
|
296
|
-
warn(...args: any[]): void;
|
|
297
|
-
clearFullScreen(message?: string): void;
|
|
298
|
-
clearScreen(message: string, force?: boolean): void;
|
|
299
|
-
private _clearScreen;
|
|
300
|
-
printError(err: unknown, options?: ErrorOptions): PrintErrorResult | undefined;
|
|
301
|
-
clearHighlightCache(filename?: string): void;
|
|
302
|
-
highlight(filename: string, source: string): string;
|
|
303
|
-
printNoTestFound(filters?: string[]): void;
|
|
304
|
-
printBanner(): void;
|
|
305
|
-
printBrowserBanner(project: WorkspaceProject): void;
|
|
306
|
-
printUnhandledErrors(errors: unknown[]): void;
|
|
307
|
-
printSourceTypeErrors(errors: TypeCheckError[]): void;
|
|
308
|
-
private registerUnhandledRejection;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
interface BrowserProviderInitializationOptions {
|
|
312
|
-
browser: string;
|
|
313
|
-
options?: BrowserProviderOptions;
|
|
314
|
-
}
|
|
315
|
-
interface CDPSession {
|
|
316
|
-
send: (method: string, params?: Record<string, unknown>) => Promise<unknown>;
|
|
317
|
-
on: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
318
|
-
once: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
319
|
-
off: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
320
|
-
}
|
|
321
|
-
interface BrowserProvider {
|
|
322
|
-
name: string;
|
|
323
|
-
/**
|
|
324
|
-
* @experimental opt-in into file parallelisation
|
|
325
|
-
*/
|
|
326
|
-
supportsParallelism: boolean;
|
|
327
|
-
getSupportedBrowsers: () => readonly string[];
|
|
328
|
-
beforeCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
|
|
329
|
-
afterCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
|
|
330
|
-
getCommandsContext: (contextId: string) => Record<string, unknown>;
|
|
331
|
-
openPage: (contextId: string, url: string, beforeNavigate?: () => Promise<void>) => Promise<void>;
|
|
332
|
-
getCDPSession?: (contextId: string) => Promise<CDPSession>;
|
|
333
|
-
close: () => Awaitable$1<void>;
|
|
334
|
-
initialize(ctx: WorkspaceProject, options: BrowserProviderInitializationOptions): Awaitable$1<void>;
|
|
335
|
-
}
|
|
336
|
-
interface BrowserProviderModule {
|
|
337
|
-
new (): BrowserProvider;
|
|
338
|
-
}
|
|
339
|
-
interface BrowserProviderOptions {
|
|
340
|
-
}
|
|
341
|
-
type BrowserBuiltinProvider = 'webdriverio' | 'playwright' | 'preview';
|
|
342
|
-
interface BrowserConfigOptions {
|
|
343
|
-
/**
|
|
344
|
-
* if running tests in the browser should be the default
|
|
345
|
-
*
|
|
346
|
-
* @default false
|
|
347
|
-
*/
|
|
348
|
-
enabled?: boolean;
|
|
349
|
-
/**
|
|
350
|
-
* Name of the browser
|
|
351
|
-
*/
|
|
352
|
-
name: string;
|
|
353
|
-
/**
|
|
354
|
-
* Browser provider
|
|
355
|
-
*
|
|
356
|
-
* @default 'preview'
|
|
357
|
-
*/
|
|
358
|
-
provider?: BrowserBuiltinProvider | (string & {});
|
|
359
|
-
/**
|
|
360
|
-
* Options that are passed down to a browser provider.
|
|
361
|
-
* To support type hinting, add one of the types to your tsconfig.json "compilerOptions.types" field:
|
|
362
|
-
*
|
|
363
|
-
* - for webdriverio: `@vitest/browser/providers/webdriverio`
|
|
364
|
-
* - for playwright: `@vitest/browser/providers/playwright`
|
|
365
|
-
*
|
|
366
|
-
* @example
|
|
367
|
-
* { playwright: { launch: { devtools: true } }
|
|
368
|
-
*/
|
|
369
|
-
providerOptions?: BrowserProviderOptions;
|
|
370
|
-
/**
|
|
371
|
-
* enable headless mode
|
|
372
|
-
*
|
|
373
|
-
* @default process.env.CI
|
|
374
|
-
*/
|
|
375
|
-
headless?: boolean;
|
|
376
|
-
/**
|
|
377
|
-
* Serve API options.
|
|
378
|
-
*
|
|
379
|
-
* The default port is 63315.
|
|
380
|
-
*/
|
|
381
|
-
api?: ApiConfig | number;
|
|
382
|
-
/**
|
|
383
|
-
* Isolate test environment after each test
|
|
384
|
-
*
|
|
385
|
-
* @default true
|
|
386
|
-
*/
|
|
387
|
-
isolate?: boolean;
|
|
388
|
-
/**
|
|
389
|
-
* Run test files in parallel if provider supports this option
|
|
390
|
-
* This option only has effect in headless mode (enabled in CI by default)
|
|
391
|
-
*
|
|
392
|
-
* @default // Same as "test.fileParallelism"
|
|
393
|
-
*/
|
|
394
|
-
fileParallelism?: boolean;
|
|
395
|
-
/**
|
|
396
|
-
* Show Vitest UI
|
|
397
|
-
*
|
|
398
|
-
* @default !process.env.CI
|
|
399
|
-
*/
|
|
400
|
-
ui?: boolean;
|
|
401
|
-
/**
|
|
402
|
-
* Default viewport size
|
|
403
|
-
*/
|
|
404
|
-
viewport?: {
|
|
405
|
-
/**
|
|
406
|
-
* Width of the viewport
|
|
407
|
-
* @default 414
|
|
408
|
-
*/
|
|
409
|
-
width: number;
|
|
410
|
-
/**
|
|
411
|
-
* Height of the viewport
|
|
412
|
-
* @default 896
|
|
413
|
-
*/
|
|
414
|
-
height: number;
|
|
415
|
-
};
|
|
416
|
-
/**
|
|
417
|
-
* Locator options
|
|
418
|
-
*/
|
|
419
|
-
locators?: {
|
|
420
|
-
/**
|
|
421
|
-
* Attribute used to locate elements by test id
|
|
422
|
-
* @default 'data-testid'
|
|
423
|
-
*/
|
|
424
|
-
testIdAttribute?: string;
|
|
425
|
-
};
|
|
426
|
-
/**
|
|
427
|
-
* Directory where screenshots will be saved when page.screenshot() is called
|
|
428
|
-
* If not set, all screenshots are saved to __screenshots__ directory in the same folder as the test file.
|
|
429
|
-
* If this is set, it will be resolved relative to the project root.
|
|
430
|
-
* @default __screenshots__
|
|
431
|
-
*/
|
|
432
|
-
screenshotDirectory?: string;
|
|
433
|
-
/**
|
|
434
|
-
* Should Vitest take screenshots if the test fails
|
|
435
|
-
* @default !browser.ui
|
|
436
|
-
*/
|
|
437
|
-
screenshotFailures?: boolean;
|
|
438
|
-
/**
|
|
439
|
-
* Scripts injected into the tester iframe.
|
|
440
|
-
* @deprecated Will be removed in the future, use `testerHtmlPath` instead.
|
|
441
|
-
*/
|
|
442
|
-
testerScripts?: BrowserScript[];
|
|
443
|
-
/**
|
|
444
|
-
* Path to the index.html file that will be used to run tests.
|
|
445
|
-
*/
|
|
446
|
-
testerHtmlPath?: string;
|
|
447
|
-
/**
|
|
448
|
-
* Scripts injected into the main window.
|
|
449
|
-
*/
|
|
450
|
-
orchestratorScripts?: BrowserScript[];
|
|
451
|
-
/**
|
|
452
|
-
* Commands that will be executed on the server
|
|
453
|
-
* via the browser `import("@vitest/browser/context").commands` API.
|
|
454
|
-
* @see {@link https://vitest.dev/guide/browser/commands}
|
|
455
|
-
*/
|
|
456
|
-
commands?: Record<string, BrowserCommand<any>>;
|
|
457
|
-
}
|
|
458
|
-
interface BrowserCommandContext {
|
|
459
|
-
testPath: string | undefined;
|
|
460
|
-
provider: BrowserProvider;
|
|
461
|
-
project: WorkspaceProject;
|
|
462
|
-
contextId: string;
|
|
463
|
-
}
|
|
464
|
-
interface BrowserServerStateContext {
|
|
465
|
-
files: string[];
|
|
466
|
-
method: 'run' | 'collect';
|
|
467
|
-
resolve: () => void;
|
|
468
|
-
reject: (v: unknown) => void;
|
|
469
|
-
}
|
|
470
|
-
interface BrowserOrchestrator {
|
|
471
|
-
createTesters: (files: string[]) => Promise<void>;
|
|
472
|
-
onCancel: (reason: CancelReason) => Promise<void>;
|
|
473
|
-
$close: () => void;
|
|
474
|
-
}
|
|
475
|
-
interface BrowserServerState {
|
|
476
|
-
orchestrators: Map<string, BrowserOrchestrator>;
|
|
477
|
-
getContext: (contextId: string) => BrowserServerStateContext | undefined;
|
|
478
|
-
createAsyncContext: (method: 'collect' | 'run', contextId: string, files: string[]) => Promise<void>;
|
|
479
|
-
}
|
|
480
|
-
interface BrowserServer {
|
|
481
|
-
vite: ViteDevServer;
|
|
482
|
-
state: BrowserServerState;
|
|
483
|
-
provider: BrowserProvider;
|
|
484
|
-
close: () => Promise<void>;
|
|
485
|
-
initBrowserProvider: () => Promise<void>;
|
|
486
|
-
parseStacktrace: (stack: string) => ParsedStack[];
|
|
487
|
-
parseErrorStacktrace: (error: ErrorWithDiff, options?: StackTraceParserOptions) => ParsedStack[];
|
|
488
|
-
}
|
|
489
|
-
interface BrowserCommand<Payload extends unknown[]> {
|
|
490
|
-
(context: BrowserCommandContext, ...payload: Payload): Awaitable$1<any>;
|
|
491
|
-
}
|
|
492
|
-
interface BrowserScript {
|
|
493
|
-
/**
|
|
494
|
-
* If "content" is provided and type is "module", this will be its identifier.
|
|
495
|
-
*
|
|
496
|
-
* If you are using TypeScript, you can add `.ts` extension here for example.
|
|
497
|
-
* @default `injected-${index}.js`
|
|
498
|
-
*/
|
|
499
|
-
id?: string;
|
|
500
|
-
/**
|
|
501
|
-
* JavaScript content to be injected. This string is processed by Vite plugins if type is "module".
|
|
502
|
-
*
|
|
503
|
-
* You can use `id` to give Vite a hint about the file extension.
|
|
504
|
-
*/
|
|
505
|
-
content?: string;
|
|
506
|
-
/**
|
|
507
|
-
* Path to the script. This value is resolved by Vite so it can be a node module or a file path.
|
|
508
|
-
*/
|
|
509
|
-
src?: string;
|
|
510
|
-
/**
|
|
511
|
-
* If the script should be loaded asynchronously.
|
|
512
|
-
*/
|
|
513
|
-
async?: boolean;
|
|
514
|
-
/**
|
|
515
|
-
* Script type.
|
|
516
|
-
* @default 'module'
|
|
517
|
-
*/
|
|
518
|
-
type?: string;
|
|
519
|
-
}
|
|
520
|
-
interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
521
|
-
enabled: boolean;
|
|
522
|
-
headless: boolean;
|
|
523
|
-
isolate: boolean;
|
|
524
|
-
fileParallelism: boolean;
|
|
525
|
-
api: ApiConfig;
|
|
526
|
-
ui: boolean;
|
|
527
|
-
viewport: {
|
|
528
|
-
width: number;
|
|
529
|
-
height: number;
|
|
530
|
-
};
|
|
531
|
-
screenshotFailures: boolean;
|
|
532
|
-
locators: {
|
|
533
|
-
testIdAttribute: string;
|
|
534
|
-
};
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
interface InitializeProjectOptions extends UserWorkspaceConfig {
|
|
538
|
-
workspaceConfigPath: string;
|
|
539
|
-
extends?: string;
|
|
540
|
-
}
|
|
541
|
-
declare class WorkspaceProject {
|
|
542
|
-
path: string | number;
|
|
543
|
-
ctx: Vitest;
|
|
544
|
-
options?: InitializeProjectOptions | undefined;
|
|
545
|
-
configOverride: Partial<ResolvedConfig> | undefined;
|
|
546
|
-
config: ResolvedConfig;
|
|
547
|
-
server: ViteDevServer;
|
|
548
|
-
vitenode: ViteNodeServer;
|
|
549
|
-
runner: ViteNodeRunner;
|
|
550
|
-
browser?: BrowserServer;
|
|
551
|
-
typechecker?: Typechecker;
|
|
552
|
-
closingPromise: Promise<unknown> | undefined;
|
|
553
|
-
testFilesList: string[] | null;
|
|
554
|
-
typecheckFilesList: string[] | null;
|
|
555
|
-
testProject: TestProject;
|
|
556
|
-
readonly id: string;
|
|
557
|
-
readonly tmpDir: string;
|
|
558
|
-
private _globalSetups;
|
|
559
|
-
private _provided;
|
|
560
|
-
constructor(path: string | number, ctx: Vitest, options?: InitializeProjectOptions | undefined);
|
|
561
|
-
getName(): string;
|
|
562
|
-
isCore(): boolean;
|
|
563
|
-
provide<T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]): void;
|
|
564
|
-
getProvidedContext(): ProvidedContext;
|
|
565
|
-
createSpec(moduleId: string, pool: string): WorkspaceSpec;
|
|
566
|
-
initializeGlobalSetup(): Promise<void>;
|
|
567
|
-
teardownGlobalSetup(): Promise<void>;
|
|
568
|
-
get logger(): Logger;
|
|
569
|
-
getModulesByFilepath(file: string): Set<vite.ModuleNode>;
|
|
570
|
-
getModuleById(id: string): vite.ModuleNode | undefined;
|
|
571
|
-
getSourceMapModuleById(id: string): TransformResult$1['map'] | undefined;
|
|
572
|
-
get reporters(): Reporter[];
|
|
573
|
-
globTestFiles(filters?: string[]): Promise<{
|
|
574
|
-
testFiles: string[];
|
|
575
|
-
typecheckTestFiles: string[];
|
|
576
|
-
}>;
|
|
577
|
-
globAllTestFiles(include: string[], exclude: string[], includeSource: string[] | undefined, cwd: string): Promise<string[]>;
|
|
578
|
-
isTestFile(id: string): boolean | null;
|
|
579
|
-
isTypecheckFile(id: string): boolean | null;
|
|
580
|
-
globFiles(include: string[], exclude: string[], cwd: string): Promise<string[]>;
|
|
581
|
-
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
582
|
-
isInSourceTestFile(code: string): boolean;
|
|
583
|
-
filterFiles(testFiles: string[], filters: string[], dir: string): string[];
|
|
584
|
-
initBrowserServer(): Promise<void>;
|
|
585
|
-
static createBasicProject(ctx: Vitest): WorkspaceProject;
|
|
586
|
-
static createCoreProject(ctx: Vitest): Promise<WorkspaceProject>;
|
|
587
|
-
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
588
|
-
isBrowserEnabled(): boolean;
|
|
589
|
-
getSerializableConfig(): SerializedConfig;
|
|
590
|
-
close(): Promise<unknown>;
|
|
591
|
-
private clearTmpDir;
|
|
592
|
-
initBrowserProvider(): Promise<void>;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
interface BlobOptions {
|
|
596
|
-
outputFile?: string;
|
|
597
|
-
}
|
|
598
|
-
declare class BlobReporter implements Reporter {
|
|
599
|
-
ctx: Vitest;
|
|
600
|
-
options: BlobOptions;
|
|
601
|
-
constructor(options: BlobOptions);
|
|
602
|
-
onInit(ctx: Vitest): void;
|
|
603
|
-
onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
interface HTMLOptions {
|
|
607
|
-
outputFile?: string;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
declare class ReportedTaskImplementation {
|
|
611
|
-
/**
|
|
612
|
-
* Task instance.
|
|
613
|
-
* @experimental Public runner task API is experimental and does not follow semver.
|
|
614
|
-
*/
|
|
615
|
-
readonly task: Task;
|
|
616
|
-
/**
|
|
617
|
-
* The project assosiacted with the test or suite.
|
|
618
|
-
*/
|
|
619
|
-
readonly project: TestProject;
|
|
620
|
-
/**
|
|
621
|
-
* Unique identifier.
|
|
622
|
-
* This ID is deterministic and will be the same for the same test across multiple runs.
|
|
623
|
-
* The ID is based on the project name, module url and test position.
|
|
624
|
-
*/
|
|
625
|
-
readonly id: string;
|
|
626
|
-
/**
|
|
627
|
-
* Location in the module where the test or suite is defined.
|
|
628
|
-
*/
|
|
629
|
-
readonly location: {
|
|
630
|
-
line: number;
|
|
631
|
-
column: number;
|
|
632
|
-
} | undefined;
|
|
633
|
-
protected constructor(task: Task, project: WorkspaceProject);
|
|
634
|
-
/**
|
|
635
|
-
* Creates a new reported task instance and stores it in the project's state for future use.
|
|
636
|
-
*/
|
|
637
|
-
static register(task: Task, project: WorkspaceProject): TestCase | TestSuite | TestModule;
|
|
638
|
-
}
|
|
639
|
-
declare class TestCase extends ReportedTaskImplementation {
|
|
640
|
-
#private;
|
|
641
|
-
readonly task: Test | Custom;
|
|
642
|
-
readonly type = "test";
|
|
643
|
-
/**
|
|
644
|
-
* Direct reference to the test module where the test or suite is defined.
|
|
645
|
-
*/
|
|
646
|
-
readonly module: TestModule;
|
|
647
|
-
/**
|
|
648
|
-
* Name of the test.
|
|
649
|
-
*/
|
|
650
|
-
readonly name: string;
|
|
651
|
-
/**
|
|
652
|
-
* Options that the test was initiated with.
|
|
653
|
-
*/
|
|
654
|
-
readonly options: TaskOptions;
|
|
655
|
-
/**
|
|
656
|
-
* Parent suite. If the test was called directly inside the module, the parent will be the module itself.
|
|
657
|
-
*/
|
|
658
|
-
readonly parent: TestSuite | TestModule;
|
|
659
|
-
protected constructor(task: Test | Custom, project: WorkspaceProject);
|
|
660
|
-
/**
|
|
661
|
-
* Full name of the test including all parent suites separated with `>`.
|
|
662
|
-
*/
|
|
663
|
-
get fullName(): string;
|
|
664
|
-
/**
|
|
665
|
-
* Test results. Will be `undefined` if test is not finished yet or was just collected.
|
|
666
|
-
*/
|
|
667
|
-
result(): TestResult | undefined;
|
|
668
|
-
/**
|
|
669
|
-
* Checks if the test did not fail the suite.
|
|
670
|
-
* If the test is not finished yet or was skipped, it will return `true`.
|
|
671
|
-
*/
|
|
672
|
-
ok(): boolean;
|
|
673
|
-
/**
|
|
674
|
-
* Custom metadata that was attached to the test during its execution.
|
|
675
|
-
*/
|
|
676
|
-
meta(): TaskMeta;
|
|
677
|
-
/**
|
|
678
|
-
* Useful information about the test like duration, memory usage, etc.
|
|
679
|
-
* Diagnostic is only available after the test has finished.
|
|
680
|
-
*/
|
|
681
|
-
diagnostic(): TestDiagnostic | undefined;
|
|
682
|
-
}
|
|
683
|
-
declare class TestCollection {
|
|
684
|
-
#private;
|
|
685
|
-
constructor(task: Suite | File, project: WorkspaceProject);
|
|
686
|
-
/**
|
|
687
|
-
* Returns the test or suite at a specific index in the array.
|
|
688
|
-
*/
|
|
689
|
-
at(index: number): TestCase | TestSuite | undefined;
|
|
690
|
-
/**
|
|
691
|
-
* The number of tests and suites in the collection.
|
|
692
|
-
*/
|
|
693
|
-
get size(): number;
|
|
694
|
-
/**
|
|
695
|
-
* Returns the collection in array form for easier manipulation.
|
|
696
|
-
*/
|
|
697
|
-
array(): (TestCase | TestSuite)[];
|
|
698
|
-
/**
|
|
699
|
-
* Filters all tests that are part of this collection and its children.
|
|
700
|
-
*/
|
|
701
|
-
allTests(state?: TestResult['state'] | 'running'): Generator<TestCase, undefined, void>;
|
|
702
|
-
/**
|
|
703
|
-
* Filters only the tests that are part of this collection.
|
|
704
|
-
*/
|
|
705
|
-
tests(state?: TestResult['state'] | 'running'): Generator<TestCase, undefined, void>;
|
|
706
|
-
/**
|
|
707
|
-
* Filters only the suites that are part of this collection.
|
|
708
|
-
*/
|
|
709
|
-
suites(): Generator<TestSuite, undefined, void>;
|
|
710
|
-
/**
|
|
711
|
-
* Filters all suites that are part of this collection and its children.
|
|
712
|
-
*/
|
|
713
|
-
allSuites(): Generator<TestSuite, undefined, void>;
|
|
714
|
-
[Symbol.iterator](): Generator<TestSuite | TestCase, undefined, void>;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
declare abstract class SuiteImplementation extends ReportedTaskImplementation {
|
|
718
|
-
readonly task: Suite | File;
|
|
719
|
-
/**
|
|
720
|
-
* Collection of suites and tests that are part of this suite.
|
|
721
|
-
*/
|
|
722
|
-
readonly children: TestCollection;
|
|
723
|
-
protected constructor(task: Suite | File, project: WorkspaceProject);
|
|
218
|
+
declare abstract class SuiteImplementation extends ReportedTaskImplementation {
|
|
219
|
+
readonly task: Suite | File;
|
|
220
|
+
/**
|
|
221
|
+
* Collection of suites and tests that are part of this suite.
|
|
222
|
+
*/
|
|
223
|
+
readonly children: TestCollection;
|
|
224
|
+
protected constructor(task: Suite | File, project: TestProject);
|
|
724
225
|
}
|
|
725
226
|
declare class TestSuite extends SuiteImplementation {
|
|
726
227
|
#private;
|
|
@@ -742,7 +243,7 @@ declare class TestSuite extends SuiteImplementation {
|
|
|
742
243
|
* Options that suite was initiated with.
|
|
743
244
|
*/
|
|
744
245
|
readonly options: TaskOptions;
|
|
745
|
-
protected constructor(task: Suite, project:
|
|
246
|
+
protected constructor(task: Suite, project: TestProject);
|
|
746
247
|
/**
|
|
747
248
|
* Full name of the suite including all parent suites separated with `>`.
|
|
748
249
|
*/
|
|
@@ -758,7 +259,7 @@ declare class TestModule extends SuiteImplementation {
|
|
|
758
259
|
* This value corresponds to Vite's `ModuleGraph` id.
|
|
759
260
|
*/
|
|
760
261
|
readonly moduleId: string;
|
|
761
|
-
protected constructor(task: File, project:
|
|
262
|
+
protected constructor(task: File, project: TestProject);
|
|
762
263
|
/**
|
|
763
264
|
* Useful information about the module like duration, memory usage, etc.
|
|
764
265
|
* If the module was not executed yet, all diagnostic values will return `0`.
|
|
@@ -869,55 +370,16 @@ interface ModuleDiagnostic {
|
|
|
869
370
|
|
|
870
371
|
declare class BasicReporter extends BaseReporter {
|
|
871
372
|
constructor();
|
|
373
|
+
onInit(ctx: Vitest): void;
|
|
872
374
|
reportSummary(files: File[], errors: unknown[]): void;
|
|
873
375
|
}
|
|
874
376
|
|
|
875
|
-
interface ListRendererOptions {
|
|
876
|
-
renderSucceed?: boolean;
|
|
877
|
-
logger: Logger;
|
|
878
|
-
showHeap: boolean;
|
|
879
|
-
slowTestThreshold: number;
|
|
880
|
-
mode: VitestRunMode;
|
|
881
|
-
}
|
|
882
|
-
declare function createListRenderer(_tasks: Task[], options: ListRendererOptions): {
|
|
883
|
-
start(): any;
|
|
884
|
-
update(_tasks: Task[]): any;
|
|
885
|
-
stop(): any;
|
|
886
|
-
clear(): void;
|
|
887
|
-
};
|
|
888
|
-
|
|
889
|
-
declare class DefaultReporter extends BaseReporter {
|
|
890
|
-
renderer?: ReturnType<typeof createListRenderer>;
|
|
891
|
-
rendererOptions: ListRendererOptions;
|
|
892
|
-
private renderSucceedDefault?;
|
|
893
|
-
onPathsCollected(paths?: string[]): void;
|
|
894
|
-
onTestRemoved(trigger?: string): Promise<void>;
|
|
895
|
-
onCollected(): void;
|
|
896
|
-
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): void;
|
|
897
|
-
onWatcherStart(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
898
|
-
stopListRender(): void;
|
|
899
|
-
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
900
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
interface DotRendererOptions {
|
|
904
|
-
logger: Logger;
|
|
905
|
-
}
|
|
906
|
-
declare function createDotRenderer(_tasks: Task[], options: DotRendererOptions): {
|
|
907
|
-
start(): any;
|
|
908
|
-
update(_tasks: Task[]): any;
|
|
909
|
-
stop(): Promise<any>;
|
|
910
|
-
clear(): void;
|
|
911
|
-
};
|
|
912
|
-
|
|
913
377
|
declare class DotReporter extends BaseReporter {
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
920
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
378
|
+
private summary?;
|
|
379
|
+
onInit(ctx: Vitest): void;
|
|
380
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
381
|
+
onWatcherRerun(files: string[], trigger?: string): void;
|
|
382
|
+
onFinished(files?: File[], errors?: unknown[]): void;
|
|
921
383
|
}
|
|
922
384
|
|
|
923
385
|
declare class GithubActionsReporter implements Reporter {
|
|
@@ -1095,9 +557,18 @@ declare class JsonReporter implements Reporter {
|
|
|
1095
557
|
writeReport(report: string): Promise<void>;
|
|
1096
558
|
}
|
|
1097
559
|
|
|
560
|
+
interface ClassnameTemplateVariables {
|
|
561
|
+
filename: string;
|
|
562
|
+
filepath: string;
|
|
563
|
+
}
|
|
1098
564
|
interface JUnitOptions {
|
|
1099
565
|
outputFile?: string;
|
|
566
|
+
/** @deprecated Use `classnameTemplate` instead. */
|
|
1100
567
|
classname?: string;
|
|
568
|
+
/**
|
|
569
|
+
* Template for the classname attribute. Can be either a string or a function. The string can contain placeholders {filename} and {filepath}.
|
|
570
|
+
*/
|
|
571
|
+
classnameTemplate?: string | ((classnameVariables: ClassnameTemplateVariables) => string);
|
|
1101
572
|
suiteName?: string;
|
|
1102
573
|
/**
|
|
1103
574
|
* Write <system-out> and <system-err> for console output
|
|
@@ -1143,10 +614,233 @@ declare class TapFlatReporter extends TapReporter {
|
|
|
1143
614
|
|
|
1144
615
|
declare class VerboseReporter extends DefaultReporter {
|
|
1145
616
|
protected verbose: boolean;
|
|
1146
|
-
|
|
617
|
+
renderSucceed: boolean;
|
|
1147
618
|
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1148
619
|
}
|
|
1149
620
|
|
|
621
|
+
interface ParsedFile extends File {
|
|
622
|
+
start: number;
|
|
623
|
+
end: number;
|
|
624
|
+
}
|
|
625
|
+
interface ParsedTest extends Test {
|
|
626
|
+
start: number;
|
|
627
|
+
end: number;
|
|
628
|
+
}
|
|
629
|
+
interface ParsedSuite extends Suite {
|
|
630
|
+
start: number;
|
|
631
|
+
end: number;
|
|
632
|
+
}
|
|
633
|
+
interface LocalCallDefinition {
|
|
634
|
+
start: number;
|
|
635
|
+
end: number;
|
|
636
|
+
name: string;
|
|
637
|
+
type: 'suite' | 'test';
|
|
638
|
+
mode: 'run' | 'skip' | 'only' | 'todo';
|
|
639
|
+
task: ParsedSuite | ParsedFile | ParsedTest;
|
|
640
|
+
}
|
|
641
|
+
interface FileInformation {
|
|
642
|
+
file: File;
|
|
643
|
+
filepath: string;
|
|
644
|
+
parsed: string;
|
|
645
|
+
map: RawSourceMap | null;
|
|
646
|
+
definitions: LocalCallDefinition[];
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
type RawErrsMap = Map<string, TscErrorInfo[]>;
|
|
650
|
+
interface TscErrorInfo {
|
|
651
|
+
filePath: string;
|
|
652
|
+
errCode: number;
|
|
653
|
+
errMsg: string;
|
|
654
|
+
line: number;
|
|
655
|
+
column: number;
|
|
656
|
+
}
|
|
657
|
+
interface CollectLineNumbers {
|
|
658
|
+
target: number;
|
|
659
|
+
next: number;
|
|
660
|
+
prev?: number;
|
|
661
|
+
}
|
|
662
|
+
type CollectLines = {
|
|
663
|
+
[key in keyof CollectLineNumbers]: string;
|
|
664
|
+
};
|
|
665
|
+
interface RootAndTarget {
|
|
666
|
+
root: string;
|
|
667
|
+
targetAbsPath: string;
|
|
668
|
+
}
|
|
669
|
+
type Context = RootAndTarget & {
|
|
670
|
+
rawErrsMap: RawErrsMap;
|
|
671
|
+
openedDirs: Set<string>;
|
|
672
|
+
lastActivePath?: string;
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
declare class TypeCheckError extends Error {
|
|
676
|
+
message: string;
|
|
677
|
+
stacks: ParsedStack[];
|
|
678
|
+
name: string;
|
|
679
|
+
constructor(message: string, stacks: ParsedStack[]);
|
|
680
|
+
}
|
|
681
|
+
interface TypecheckResults {
|
|
682
|
+
files: File[];
|
|
683
|
+
sourceErrors: TypeCheckError[];
|
|
684
|
+
time: number;
|
|
685
|
+
}
|
|
686
|
+
type Callback<Args extends Array<any> = []> = (...args: Args) => Awaitable<void>;
|
|
687
|
+
declare class Typechecker {
|
|
688
|
+
protected ctx: TestProject;
|
|
689
|
+
private _onParseStart?;
|
|
690
|
+
private _onParseEnd?;
|
|
691
|
+
private _onWatcherRerun?;
|
|
692
|
+
private _result;
|
|
693
|
+
private _startTime;
|
|
694
|
+
private _output;
|
|
695
|
+
private _tests;
|
|
696
|
+
private tempConfigPath?;
|
|
697
|
+
private allowJs?;
|
|
698
|
+
private process?;
|
|
699
|
+
protected files: string[];
|
|
700
|
+
constructor(ctx: TestProject);
|
|
701
|
+
setFiles(files: string[]): void;
|
|
702
|
+
onParseStart(fn: Callback): void;
|
|
703
|
+
onParseEnd(fn: Callback<[TypecheckResults]>): void;
|
|
704
|
+
onWatcherRerun(fn: Callback): void;
|
|
705
|
+
protected collectFileTests(filepath: string): Promise<FileInformation | null>;
|
|
706
|
+
protected getFiles(): string[];
|
|
707
|
+
collectTests(): Promise<Record<string, FileInformation>>;
|
|
708
|
+
protected markPassed(file: File): void;
|
|
709
|
+
protected prepareResults(output: string): Promise<{
|
|
710
|
+
files: File[];
|
|
711
|
+
sourceErrors: TypeCheckError[];
|
|
712
|
+
time: number;
|
|
713
|
+
}>;
|
|
714
|
+
protected parseTscLikeOutput(output: string): Promise<Map<string, {
|
|
715
|
+
error: TypeCheckError;
|
|
716
|
+
originalError: TscErrorInfo;
|
|
717
|
+
}[]>>;
|
|
718
|
+
clear(): Promise<void>;
|
|
719
|
+
stop(): Promise<void>;
|
|
720
|
+
protected ensurePackageInstalled(ctx: Vitest, checker: string): Promise<void>;
|
|
721
|
+
prepare(): Promise<void>;
|
|
722
|
+
getExitCode(): number | false;
|
|
723
|
+
getOutput(): string;
|
|
724
|
+
start(): Promise<void>;
|
|
725
|
+
getResult(): TypecheckResults;
|
|
726
|
+
getTestFiles(): File[];
|
|
727
|
+
getTestPacks(): TaskResultPack[];
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
interface PrintErrorResult {
|
|
731
|
+
nearest?: ParsedStack;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
interface Options {
|
|
735
|
+
/**
|
|
736
|
+
Show the cursor. This can be useful when a CLI accepts input from a user.
|
|
737
|
+
|
|
738
|
+
@example
|
|
739
|
+
```
|
|
740
|
+
import {createLogUpdate} from 'log-update';
|
|
741
|
+
|
|
742
|
+
// Write output but don't hide the cursor
|
|
743
|
+
const log = createLogUpdate(process.stdout, {
|
|
744
|
+
showCursor: true
|
|
745
|
+
});
|
|
746
|
+
```
|
|
747
|
+
*/
|
|
748
|
+
readonly showCursor?: boolean;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
type LogUpdateMethods = {
|
|
752
|
+
/**
|
|
753
|
+
Clear the logged output.
|
|
754
|
+
*/
|
|
755
|
+
clear(): void;
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
Persist the logged output. Useful if you want to start a new log session below the current one.
|
|
759
|
+
*/
|
|
760
|
+
done(): void;
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
Log to `stdout` by overwriting the previous output in the terminal.
|
|
765
|
+
|
|
766
|
+
@param text - The text to log to `stdout`.
|
|
767
|
+
|
|
768
|
+
@example
|
|
769
|
+
```
|
|
770
|
+
import logUpdate from 'log-update';
|
|
771
|
+
|
|
772
|
+
const frames = ['-', '\\', '|', '/'];
|
|
773
|
+
let index = 0;
|
|
774
|
+
|
|
775
|
+
setInterval(() => {
|
|
776
|
+
const frame = frames[index = ++index % frames.length];
|
|
777
|
+
|
|
778
|
+
logUpdate(
|
|
779
|
+
`
|
|
780
|
+
♥♥
|
|
781
|
+
${frame} unicorns ${frame}
|
|
782
|
+
♥♥
|
|
783
|
+
`
|
|
784
|
+
);
|
|
785
|
+
}, 80);
|
|
786
|
+
```
|
|
787
|
+
*/
|
|
788
|
+
declare const logUpdate: ((...text: string[]) => void) & LogUpdateMethods;
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
Get a `logUpdate` method that logs to the specified stream.
|
|
793
|
+
|
|
794
|
+
@param stream - The stream to log to.
|
|
795
|
+
|
|
796
|
+
@example
|
|
797
|
+
```
|
|
798
|
+
import {createLogUpdate} from 'log-update';
|
|
799
|
+
|
|
800
|
+
// Write output but don't hide the cursor
|
|
801
|
+
const log = createLogUpdate(process.stdout);
|
|
802
|
+
```
|
|
803
|
+
*/
|
|
804
|
+
declare function createLogUpdate(
|
|
805
|
+
stream: NodeJS.WritableStream,
|
|
806
|
+
options?: Options
|
|
807
|
+
): typeof logUpdate;
|
|
808
|
+
|
|
809
|
+
interface ErrorOptions {
|
|
810
|
+
type?: string;
|
|
811
|
+
fullStack?: boolean;
|
|
812
|
+
project?: TestProject;
|
|
813
|
+
verbose?: boolean;
|
|
814
|
+
screenshotPaths?: string[];
|
|
815
|
+
task?: Task;
|
|
816
|
+
showCodeFrame?: boolean;
|
|
817
|
+
}
|
|
818
|
+
declare class Logger {
|
|
819
|
+
ctx: Vitest;
|
|
820
|
+
outputStream: NodeJS.WriteStream | Writable;
|
|
821
|
+
errorStream: NodeJS.WriteStream | Writable;
|
|
822
|
+
logUpdate: ReturnType<typeof createLogUpdate>;
|
|
823
|
+
private _clearScreenPending;
|
|
824
|
+
private _highlights;
|
|
825
|
+
console: Console;
|
|
826
|
+
constructor(ctx: Vitest, outputStream?: NodeJS.WriteStream | Writable, errorStream?: NodeJS.WriteStream | Writable);
|
|
827
|
+
log(...args: any[]): void;
|
|
828
|
+
error(...args: any[]): void;
|
|
829
|
+
warn(...args: any[]): void;
|
|
830
|
+
clearFullScreen(message?: string): void;
|
|
831
|
+
clearScreen(message: string, force?: boolean): void;
|
|
832
|
+
private _clearScreen;
|
|
833
|
+
printError(err: unknown, options?: ErrorOptions): PrintErrorResult | undefined;
|
|
834
|
+
clearHighlightCache(filename?: string): void;
|
|
835
|
+
highlight(filename: string, source: string): string;
|
|
836
|
+
printNoTestFound(filters?: string[]): void;
|
|
837
|
+
printBanner(): void;
|
|
838
|
+
printBrowserBanner(project: TestProject): void;
|
|
839
|
+
printUnhandledErrors(errors: unknown[]): void;
|
|
840
|
+
printSourceTypeErrors(errors: TypeCheckError[]): void;
|
|
841
|
+
private registerUnhandledRejection;
|
|
842
|
+
}
|
|
843
|
+
|
|
1150
844
|
interface TableRendererOptions {
|
|
1151
845
|
renderSucceed?: boolean;
|
|
1152
846
|
logger: Logger;
|
|
@@ -1155,9 +849,9 @@ interface TableRendererOptions {
|
|
|
1155
849
|
compare?: FlatBenchmarkReport;
|
|
1156
850
|
}
|
|
1157
851
|
declare function createTableRenderer(_tasks: Task[], options: TableRendererOptions): {
|
|
1158
|
-
start(): any;
|
|
1159
|
-
update(_tasks: Task[]): any;
|
|
1160
|
-
stop(): any;
|
|
852
|
+
start(): /*elided*/ any;
|
|
853
|
+
update(_tasks: Task[]): /*elided*/ any;
|
|
854
|
+
stop(): /*elided*/ any;
|
|
1161
855
|
clear(): void;
|
|
1162
856
|
};
|
|
1163
857
|
|
|
@@ -1211,9 +905,9 @@ declare const ReportersMap: {
|
|
|
1211
905
|
};
|
|
1212
906
|
type BuiltinReporters = keyof typeof ReportersMap;
|
|
1213
907
|
interface BuiltinReporterOptions {
|
|
1214
|
-
'default':
|
|
908
|
+
'default': DefaultReporterOptions;
|
|
1215
909
|
'basic': BaseOptions;
|
|
1216
|
-
'verbose':
|
|
910
|
+
'verbose': DefaultReporterOptions;
|
|
1217
911
|
'dot': BaseOptions;
|
|
1218
912
|
'json': JsonOptions$1;
|
|
1219
913
|
'blob': BlobOptions;
|
|
@@ -1224,6 +918,8 @@ interface BuiltinReporterOptions {
|
|
|
1224
918
|
'html': HTMLOptions;
|
|
1225
919
|
}
|
|
1226
920
|
|
|
921
|
+
type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
|
|
922
|
+
|
|
1227
923
|
interface TestSequencer {
|
|
1228
924
|
/**
|
|
1229
925
|
* Slicing tests into shards. Will be run before `sort`.
|
|
@@ -1899,751 +1595,1081 @@ interface InlineConfig {
|
|
|
1899
1595
|
* Exclude globs for test files
|
|
1900
1596
|
* @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.*']
|
|
1901
1597
|
*/
|
|
1902
|
-
exclude?: string[];
|
|
1598
|
+
exclude?: string[];
|
|
1599
|
+
/**
|
|
1600
|
+
* Include globs for in-source test files
|
|
1601
|
+
*
|
|
1602
|
+
* @default []
|
|
1603
|
+
*/
|
|
1604
|
+
includeSource?: string[];
|
|
1605
|
+
/**
|
|
1606
|
+
* Handling for dependencies inlining or externalizing
|
|
1607
|
+
*
|
|
1608
|
+
*/
|
|
1609
|
+
deps?: DepsOptions;
|
|
1610
|
+
/**
|
|
1611
|
+
* Vite-node server options
|
|
1612
|
+
*/
|
|
1613
|
+
server?: Omit<ViteNodeServerOptions, 'transformMode'>;
|
|
1614
|
+
/**
|
|
1615
|
+
* Base directory to scan for the test files
|
|
1616
|
+
*
|
|
1617
|
+
* @default `config.root`
|
|
1618
|
+
*/
|
|
1619
|
+
dir?: string;
|
|
1620
|
+
/**
|
|
1621
|
+
* Register apis globally
|
|
1622
|
+
*
|
|
1623
|
+
* @default false
|
|
1624
|
+
*/
|
|
1625
|
+
globals?: boolean;
|
|
1626
|
+
/**
|
|
1627
|
+
* Running environment
|
|
1628
|
+
*
|
|
1629
|
+
* Supports 'node', 'jsdom', 'happy-dom', 'edge-runtime'
|
|
1630
|
+
*
|
|
1631
|
+
* If used unsupported string, will try to load the package `vitest-environment-${env}`
|
|
1632
|
+
*
|
|
1633
|
+
* @default 'node'
|
|
1634
|
+
*/
|
|
1635
|
+
environment?: VitestEnvironment;
|
|
1636
|
+
/**
|
|
1637
|
+
* Environment options.
|
|
1638
|
+
*/
|
|
1639
|
+
environmentOptions?: EnvironmentOptions;
|
|
1640
|
+
/**
|
|
1641
|
+
* Automatically assign environment based on globs. The first match will be used.
|
|
1642
|
+
* This has effect only when running tests inside Node.js.
|
|
1643
|
+
*
|
|
1644
|
+
* Format: [glob, environment-name]
|
|
1645
|
+
*
|
|
1646
|
+
* @deprecated use [`workspace`](https://vitest.dev/config/#environmentmatchglobs) instead
|
|
1647
|
+
* @default []
|
|
1648
|
+
* @example [
|
|
1649
|
+
* // all tests in tests/dom will run in jsdom
|
|
1650
|
+
* ['tests/dom/**', 'jsdom'],
|
|
1651
|
+
* // all tests in tests/ with .edge.test.ts will run in edge-runtime
|
|
1652
|
+
* ['**\/*.edge.test.ts', 'edge-runtime'],
|
|
1653
|
+
* // ...
|
|
1654
|
+
* ]
|
|
1655
|
+
*/
|
|
1656
|
+
environmentMatchGlobs?: [string, VitestEnvironment][];
|
|
1657
|
+
/**
|
|
1658
|
+
* Run tests in an isolated environment. This option has no effect on vmThreads pool.
|
|
1659
|
+
*
|
|
1660
|
+
* Disabling this option might improve performance if your code doesn't rely on side effects.
|
|
1661
|
+
*
|
|
1662
|
+
* @default true
|
|
1663
|
+
*/
|
|
1664
|
+
isolate?: boolean;
|
|
1665
|
+
/**
|
|
1666
|
+
* Pool used to run tests in.
|
|
1667
|
+
*
|
|
1668
|
+
* Supports 'threads', 'forks', 'vmThreads'
|
|
1669
|
+
*
|
|
1670
|
+
* @default 'forks'
|
|
1671
|
+
*/
|
|
1672
|
+
pool?: Exclude<Pool, 'browser'>;
|
|
1673
|
+
/**
|
|
1674
|
+
* Pool options
|
|
1675
|
+
*/
|
|
1676
|
+
poolOptions?: PoolOptions;
|
|
1677
|
+
/**
|
|
1678
|
+
* Maximum number or percentage of workers to run tests in. `poolOptions.{threads,vmThreads}.maxThreads`/`poolOptions.forks.maxForks` has higher priority.
|
|
1679
|
+
*/
|
|
1680
|
+
maxWorkers?: number | string;
|
|
1681
|
+
/**
|
|
1682
|
+
* Minimum number or percentage of workers to run tests in. `poolOptions.{threads,vmThreads}.minThreads`/`poolOptions.forks.minForks` has higher priority.
|
|
1683
|
+
*/
|
|
1684
|
+
minWorkers?: number | string;
|
|
1685
|
+
/**
|
|
1686
|
+
* Should all test files run in parallel. Doesn't affect tests running in the same file.
|
|
1687
|
+
* Setting this to `false` will override `maxWorkers` and `minWorkers` options to `1`.
|
|
1688
|
+
*
|
|
1689
|
+
* @default true
|
|
1690
|
+
*/
|
|
1691
|
+
fileParallelism?: boolean;
|
|
1692
|
+
/**
|
|
1693
|
+
* Automatically assign pool based on globs. The first match will be used.
|
|
1694
|
+
*
|
|
1695
|
+
* Format: [glob, pool-name]
|
|
1696
|
+
*
|
|
1697
|
+
* @deprecated use [`workspace`](https://vitest.dev/config/#poolmatchglobs) instead
|
|
1698
|
+
* @default []
|
|
1699
|
+
* @example [
|
|
1700
|
+
* // all tests in "forks" directory will run using "poolOptions.forks" API
|
|
1701
|
+
* ['tests/forks/**', 'forks'],
|
|
1702
|
+
* // all other tests will run based on "poolOptions.threads" option, if you didn't specify other globs
|
|
1703
|
+
* // ...
|
|
1704
|
+
* ]
|
|
1705
|
+
*/
|
|
1706
|
+
poolMatchGlobs?: [string, Exclude<Pool, 'browser'>][];
|
|
1707
|
+
/**
|
|
1708
|
+
* Path to a workspace configuration file
|
|
1709
|
+
*/
|
|
1710
|
+
workspace?: string | TestProjectConfiguration[];
|
|
1711
|
+
/**
|
|
1712
|
+
* Update snapshot
|
|
1713
|
+
*
|
|
1714
|
+
* @default false
|
|
1715
|
+
*/
|
|
1716
|
+
update?: boolean;
|
|
1717
|
+
/**
|
|
1718
|
+
* Watch mode
|
|
1719
|
+
*
|
|
1720
|
+
* @default !process.env.CI
|
|
1721
|
+
*/
|
|
1722
|
+
watch?: boolean;
|
|
1723
|
+
/**
|
|
1724
|
+
* Project root
|
|
1725
|
+
*
|
|
1726
|
+
* @default process.cwd()
|
|
1727
|
+
*/
|
|
1728
|
+
root?: string;
|
|
1729
|
+
/**
|
|
1730
|
+
* Custom reporter for output. Can contain one or more built-in report names, reporter instances,
|
|
1731
|
+
* and/or paths to custom reporters.
|
|
1732
|
+
*
|
|
1733
|
+
* @default []
|
|
1734
|
+
*/
|
|
1735
|
+
reporters?: Arrayable$1<ReporterName | InlineReporter> | ((ReporterName | InlineReporter) | [ReporterName] | ReporterWithOptions)[];
|
|
1736
|
+
/**
|
|
1737
|
+
* Write test results to a file when the --reporter=json` or `--reporter=junit` option is also specified.
|
|
1738
|
+
* Also definable individually per reporter by using an object instead.
|
|
1739
|
+
*/
|
|
1740
|
+
outputFile?: string | (Partial<Record<BuiltinReporters, string>> & Record<string, string>);
|
|
1741
|
+
/**
|
|
1742
|
+
* Default timeout of a test in milliseconds
|
|
1743
|
+
*
|
|
1744
|
+
* @default 5000
|
|
1745
|
+
*/
|
|
1746
|
+
testTimeout?: number;
|
|
1747
|
+
/**
|
|
1748
|
+
* Default timeout of a hook in milliseconds
|
|
1749
|
+
*
|
|
1750
|
+
* @default 10000
|
|
1751
|
+
*/
|
|
1752
|
+
hookTimeout?: number;
|
|
1753
|
+
/**
|
|
1754
|
+
* Default timeout to wait for close when Vitest shuts down, in milliseconds
|
|
1755
|
+
*
|
|
1756
|
+
* @default 10000
|
|
1757
|
+
*/
|
|
1758
|
+
teardownTimeout?: number;
|
|
1759
|
+
/**
|
|
1760
|
+
* Silent mode
|
|
1761
|
+
*
|
|
1762
|
+
* @default false
|
|
1763
|
+
*/
|
|
1764
|
+
silent?: boolean;
|
|
1765
|
+
/**
|
|
1766
|
+
* Hide logs for skipped tests
|
|
1767
|
+
*
|
|
1768
|
+
* @default false
|
|
1769
|
+
*/
|
|
1770
|
+
hideSkippedTests?: boolean;
|
|
1771
|
+
/**
|
|
1772
|
+
* Path to setup files
|
|
1773
|
+
*/
|
|
1774
|
+
setupFiles?: string | string[];
|
|
1775
|
+
/**
|
|
1776
|
+
* Path to global setup files
|
|
1777
|
+
*/
|
|
1778
|
+
globalSetup?: string | string[];
|
|
1779
|
+
/**
|
|
1780
|
+
* Glob patter of file paths that will trigger the whole suite rerun
|
|
1781
|
+
*
|
|
1782
|
+
* Useful if you are testing calling CLI commands
|
|
1783
|
+
*
|
|
1784
|
+
* @default ['**\/package.json/**', '**\/{vitest,vite}.config.*\/**']
|
|
1785
|
+
*/
|
|
1786
|
+
forceRerunTriggers?: string[];
|
|
1787
|
+
/**
|
|
1788
|
+
* Coverage options
|
|
1789
|
+
*/
|
|
1790
|
+
coverage?: CoverageOptions;
|
|
1791
|
+
/**
|
|
1792
|
+
* run test names with the specified pattern
|
|
1793
|
+
*/
|
|
1794
|
+
testNamePattern?: string | RegExp;
|
|
1795
|
+
/**
|
|
1796
|
+
* Will call `.mockClear()` on all spies before each test
|
|
1797
|
+
* @default false
|
|
1798
|
+
*/
|
|
1799
|
+
clearMocks?: boolean;
|
|
1800
|
+
/**
|
|
1801
|
+
* Will call `.mockReset()` on all spies before each test
|
|
1802
|
+
* @default false
|
|
1803
|
+
*/
|
|
1804
|
+
mockReset?: boolean;
|
|
1805
|
+
/**
|
|
1806
|
+
* Will call `.mockRestore()` on all spies before each test
|
|
1807
|
+
* @default false
|
|
1808
|
+
*/
|
|
1809
|
+
restoreMocks?: boolean;
|
|
1810
|
+
/**
|
|
1811
|
+
* Will restore all global stubs to their original values before each test
|
|
1812
|
+
* @default false
|
|
1813
|
+
*/
|
|
1814
|
+
unstubGlobals?: boolean;
|
|
1815
|
+
/**
|
|
1816
|
+
* Will restore all env stubs to their original values before each test
|
|
1817
|
+
* @default false
|
|
1818
|
+
*/
|
|
1819
|
+
unstubEnvs?: boolean;
|
|
1820
|
+
/**
|
|
1821
|
+
* Serve API options.
|
|
1822
|
+
*
|
|
1823
|
+
* When set to true, the default port is 51204.
|
|
1824
|
+
*
|
|
1825
|
+
* @default false
|
|
1826
|
+
*/
|
|
1827
|
+
api?: boolean | number | ApiConfig;
|
|
1828
|
+
/**
|
|
1829
|
+
* Enable Vitest UI
|
|
1830
|
+
*
|
|
1831
|
+
* @default false
|
|
1832
|
+
*/
|
|
1833
|
+
ui?: boolean;
|
|
1834
|
+
/**
|
|
1835
|
+
* options for test in a browser environment
|
|
1836
|
+
* @experimental
|
|
1837
|
+
*
|
|
1838
|
+
* @default false
|
|
1839
|
+
*/
|
|
1840
|
+
browser?: BrowserConfigOptions;
|
|
1841
|
+
/**
|
|
1842
|
+
* Open UI automatically.
|
|
1843
|
+
*
|
|
1844
|
+
* @default !process.env.CI
|
|
1845
|
+
*/
|
|
1846
|
+
open?: boolean;
|
|
1903
1847
|
/**
|
|
1904
|
-
*
|
|
1848
|
+
* Base url for the UI
|
|
1905
1849
|
*
|
|
1906
|
-
* @default
|
|
1850
|
+
* @default '/__vitest__/'
|
|
1907
1851
|
*/
|
|
1908
|
-
|
|
1852
|
+
uiBase?: string;
|
|
1909
1853
|
/**
|
|
1910
|
-
*
|
|
1911
|
-
*
|
|
1854
|
+
* Determine the transform method for all modules imported inside a test that matches the glob pattern.
|
|
1912
1855
|
*/
|
|
1913
|
-
|
|
1856
|
+
testTransformMode?: TransformModePatterns;
|
|
1914
1857
|
/**
|
|
1915
|
-
*
|
|
1858
|
+
* Format options for snapshot testing.
|
|
1916
1859
|
*/
|
|
1917
|
-
|
|
1860
|
+
snapshotFormat?: Omit<PrettyFormatOptions, 'plugins'>;
|
|
1918
1861
|
/**
|
|
1919
|
-
*
|
|
1920
|
-
*
|
|
1921
|
-
* @default `config.root`
|
|
1862
|
+
* Path to a module which has a default export of diff config.
|
|
1922
1863
|
*/
|
|
1923
|
-
|
|
1864
|
+
diff?: string | SerializedDiffOptions;
|
|
1924
1865
|
/**
|
|
1925
|
-
*
|
|
1926
|
-
*
|
|
1927
|
-
* @default false
|
|
1866
|
+
* Paths to snapshot serializer modules.
|
|
1928
1867
|
*/
|
|
1929
|
-
|
|
1868
|
+
snapshotSerializers?: string[];
|
|
1930
1869
|
/**
|
|
1931
|
-
*
|
|
1932
|
-
*
|
|
1933
|
-
* Supports 'node', 'jsdom', 'happy-dom', 'edge-runtime'
|
|
1934
|
-
*
|
|
1935
|
-
* If used unsupported string, will try to load the package `vitest-environment-${env}`
|
|
1936
|
-
*
|
|
1937
|
-
* @default 'node'
|
|
1870
|
+
* Resolve custom snapshot path
|
|
1938
1871
|
*/
|
|
1939
|
-
|
|
1872
|
+
resolveSnapshotPath?: ResolveSnapshotPathHandler;
|
|
1940
1873
|
/**
|
|
1941
|
-
*
|
|
1874
|
+
* Path to a custom snapshot environment module that has a default export of `SnapshotEnvironment` object.
|
|
1942
1875
|
*/
|
|
1943
|
-
|
|
1876
|
+
snapshotEnvironment?: string;
|
|
1944
1877
|
/**
|
|
1945
|
-
*
|
|
1946
|
-
* This has effect only when running tests inside Node.js.
|
|
1947
|
-
*
|
|
1948
|
-
* Format: [glob, environment-name]
|
|
1949
|
-
*
|
|
1950
|
-
* @default []
|
|
1951
|
-
* @example [
|
|
1952
|
-
* // all tests in tests/dom will run in jsdom
|
|
1953
|
-
* ['tests/dom/**', 'jsdom'],
|
|
1954
|
-
* // all tests in tests/ with .edge.test.ts will run in edge-runtime
|
|
1955
|
-
* ['**\/*.edge.test.ts', 'edge-runtime'],
|
|
1956
|
-
* // ...
|
|
1957
|
-
* ]
|
|
1878
|
+
* Pass with no tests
|
|
1958
1879
|
*/
|
|
1959
|
-
|
|
1880
|
+
passWithNoTests?: boolean;
|
|
1960
1881
|
/**
|
|
1961
|
-
*
|
|
1962
|
-
*
|
|
1963
|
-
* Disabling this option might improve performance if your code doesn't rely on side effects.
|
|
1882
|
+
* Allow tests and suites that are marked as only
|
|
1964
1883
|
*
|
|
1965
|
-
* @default
|
|
1884
|
+
* @default !process.env.CI
|
|
1966
1885
|
*/
|
|
1967
|
-
|
|
1886
|
+
allowOnly?: boolean;
|
|
1968
1887
|
/**
|
|
1969
|
-
*
|
|
1970
|
-
*
|
|
1971
|
-
* Supports 'threads', 'forks', 'vmThreads'
|
|
1972
|
-
*
|
|
1973
|
-
* @default 'forks'
|
|
1888
|
+
* Show heap usage after each test. Useful for debugging memory leaks.
|
|
1974
1889
|
*/
|
|
1975
|
-
|
|
1890
|
+
logHeapUsage?: boolean;
|
|
1976
1891
|
/**
|
|
1977
|
-
*
|
|
1892
|
+
* Custom environment variables assigned to `process.env` before running tests.
|
|
1978
1893
|
*/
|
|
1979
|
-
|
|
1894
|
+
env?: Partial<NodeJS.ProcessEnv>;
|
|
1980
1895
|
/**
|
|
1981
|
-
*
|
|
1896
|
+
* Options for @sinon/fake-timers
|
|
1982
1897
|
*/
|
|
1983
|
-
|
|
1898
|
+
fakeTimers?: FakeTimerInstallOpts;
|
|
1984
1899
|
/**
|
|
1985
|
-
*
|
|
1900
|
+
* Custom handler for console.log in tests.
|
|
1901
|
+
*
|
|
1902
|
+
* Return `false` to ignore the log.
|
|
1986
1903
|
*/
|
|
1987
|
-
|
|
1904
|
+
onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => boolean | void;
|
|
1988
1905
|
/**
|
|
1989
|
-
*
|
|
1990
|
-
*
|
|
1906
|
+
* Enable stack trace filtering. If absent, all stack trace frames
|
|
1907
|
+
* will be shown.
|
|
1991
1908
|
*
|
|
1992
|
-
*
|
|
1909
|
+
* Return `false` to omit the frame.
|
|
1993
1910
|
*/
|
|
1994
|
-
|
|
1911
|
+
onStackTrace?: (error: ErrorWithDiff, frame: ParsedStack) => boolean | void;
|
|
1995
1912
|
/**
|
|
1996
|
-
*
|
|
1913
|
+
* Indicates if CSS files should be processed.
|
|
1997
1914
|
*
|
|
1998
|
-
*
|
|
1915
|
+
* When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
|
|
1999
1916
|
*
|
|
2000
|
-
* @default []
|
|
2001
|
-
* @example [
|
|
2002
|
-
* // all tests in "forks" directory will run using "poolOptions.forks" API
|
|
2003
|
-
* ['tests/forks/**', 'forks'],
|
|
2004
|
-
* // all other tests will run based on "poolOptions.threads" option, if you didn't specify other globs
|
|
2005
|
-
* // ...
|
|
2006
|
-
* ]
|
|
1917
|
+
* @default { include: [], modules: { classNameStrategy: false } }
|
|
2007
1918
|
*/
|
|
2008
|
-
|
|
1919
|
+
css?: boolean | {
|
|
1920
|
+
include?: RegExp | RegExp[];
|
|
1921
|
+
exclude?: RegExp | RegExp[];
|
|
1922
|
+
modules?: {
|
|
1923
|
+
classNameStrategy?: CSSModuleScopeStrategy;
|
|
1924
|
+
};
|
|
1925
|
+
};
|
|
2009
1926
|
/**
|
|
2010
|
-
*
|
|
1927
|
+
* A number of tests that are allowed to run at the same time marked with `test.concurrent`.
|
|
1928
|
+
* @default 5
|
|
2011
1929
|
*/
|
|
2012
|
-
|
|
1930
|
+
maxConcurrency?: number;
|
|
2013
1931
|
/**
|
|
2014
|
-
*
|
|
2015
|
-
*
|
|
2016
|
-
* @default false
|
|
1932
|
+
* Options for configuring cache policy.
|
|
1933
|
+
* @default { dir: 'node_modules/.vite/vitest' }
|
|
2017
1934
|
*/
|
|
2018
|
-
|
|
1935
|
+
cache?: false | {
|
|
1936
|
+
/**
|
|
1937
|
+
* @deprecated Use Vite's "cacheDir" instead if you want to change the cache director. Note caches will be written to "cacheDir\/vitest".
|
|
1938
|
+
*/
|
|
1939
|
+
dir: string;
|
|
1940
|
+
};
|
|
2019
1941
|
/**
|
|
2020
|
-
*
|
|
2021
|
-
*
|
|
2022
|
-
* @default !process.env.CI
|
|
1942
|
+
* Options for configuring the order of running tests.
|
|
2023
1943
|
*/
|
|
2024
|
-
|
|
1944
|
+
sequence?: SequenceOptions;
|
|
2025
1945
|
/**
|
|
2026
|
-
*
|
|
2027
|
-
*
|
|
2028
|
-
*
|
|
1946
|
+
* Specifies an `Object`, or an `Array` of `Object`,
|
|
1947
|
+
* which defines aliases used to replace values in `import` or `require` statements.
|
|
1948
|
+
* Will be merged with the default aliases inside `resolve.alias`.
|
|
2029
1949
|
*/
|
|
2030
|
-
|
|
1950
|
+
alias?: AliasOptions;
|
|
2031
1951
|
/**
|
|
2032
|
-
*
|
|
2033
|
-
* and/or paths to custom reporters.
|
|
1952
|
+
* Ignore any unhandled errors that occur
|
|
2034
1953
|
*
|
|
2035
|
-
* @default
|
|
1954
|
+
* @default false
|
|
2036
1955
|
*/
|
|
2037
|
-
|
|
1956
|
+
dangerouslyIgnoreUnhandledErrors?: boolean;
|
|
2038
1957
|
/**
|
|
2039
|
-
*
|
|
2040
|
-
* Also definable individually per reporter by using an object instead.
|
|
1958
|
+
* Options for configuring typechecking test environment.
|
|
2041
1959
|
*/
|
|
2042
|
-
|
|
1960
|
+
typecheck?: Partial<TypecheckConfig>;
|
|
2043
1961
|
/**
|
|
2044
|
-
*
|
|
1962
|
+
* The number of milliseconds after which a test is considered slow and reported as such in the results.
|
|
2045
1963
|
*
|
|
2046
|
-
* @default
|
|
1964
|
+
* @default 300
|
|
2047
1965
|
*/
|
|
2048
|
-
|
|
1966
|
+
slowTestThreshold?: number;
|
|
2049
1967
|
/**
|
|
2050
|
-
*
|
|
2051
|
-
*
|
|
2052
|
-
* @default 10000
|
|
1968
|
+
* Path to a custom test runner.
|
|
2053
1969
|
*/
|
|
2054
|
-
|
|
1970
|
+
runner?: string;
|
|
2055
1971
|
/**
|
|
2056
|
-
*
|
|
1972
|
+
* Debug tests by opening `node:inspector` in worker / child process.
|
|
1973
|
+
* Provides similar experience as `--inspect` Node CLI argument.
|
|
2057
1974
|
*
|
|
2058
|
-
*
|
|
1975
|
+
* Requires `poolOptions.threads.singleThread: true` OR `poolOptions.forks.singleFork: true`.
|
|
2059
1976
|
*/
|
|
2060
|
-
|
|
1977
|
+
inspect?: boolean | string;
|
|
2061
1978
|
/**
|
|
2062
|
-
*
|
|
1979
|
+
* Debug tests by opening `node:inspector` in worker / child process and wait for debugger to connect.
|
|
1980
|
+
* Provides similar experience as `--inspect-brk` Node CLI argument.
|
|
2063
1981
|
*
|
|
2064
|
-
*
|
|
1982
|
+
* Requires `poolOptions.threads.singleThread: true` OR `poolOptions.forks.singleFork: true`.
|
|
2065
1983
|
*/
|
|
2066
|
-
|
|
1984
|
+
inspectBrk?: boolean | string;
|
|
2067
1985
|
/**
|
|
2068
|
-
*
|
|
2069
|
-
*
|
|
2070
|
-
* @default false
|
|
1986
|
+
* Inspector options. If `--inspect` or `--inspect-brk` is enabled, these options will be passed to the inspector.
|
|
2071
1987
|
*/
|
|
2072
|
-
|
|
1988
|
+
inspector?: {
|
|
1989
|
+
/**
|
|
1990
|
+
* Enable inspector
|
|
1991
|
+
*/
|
|
1992
|
+
enabled?: boolean;
|
|
1993
|
+
/**
|
|
1994
|
+
* Port to run inspector on
|
|
1995
|
+
*/
|
|
1996
|
+
port?: number;
|
|
1997
|
+
/**
|
|
1998
|
+
* Host to run inspector on
|
|
1999
|
+
*/
|
|
2000
|
+
host?: string;
|
|
2001
|
+
/**
|
|
2002
|
+
* Wait for debugger to connect before running tests
|
|
2003
|
+
*/
|
|
2004
|
+
waitForDebugger?: boolean;
|
|
2005
|
+
};
|
|
2073
2006
|
/**
|
|
2074
|
-
*
|
|
2007
|
+
* Define variables that will be returned from `inject` in the test environment.
|
|
2008
|
+
* @example
|
|
2009
|
+
* ```ts
|
|
2010
|
+
* // vitest.config.ts
|
|
2011
|
+
* export default defineConfig({
|
|
2012
|
+
* test: {
|
|
2013
|
+
* provide: {
|
|
2014
|
+
* someKey: 'someValue'
|
|
2015
|
+
* }
|
|
2016
|
+
* }
|
|
2017
|
+
* })
|
|
2018
|
+
* ```
|
|
2019
|
+
* ```ts
|
|
2020
|
+
* // test file
|
|
2021
|
+
* import { inject } from 'vitest'
|
|
2022
|
+
* const value = inject('someKey') // 'someValue'
|
|
2023
|
+
* ```
|
|
2075
2024
|
*/
|
|
2076
|
-
|
|
2025
|
+
provide?: Partial<ProvidedContext>;
|
|
2077
2026
|
/**
|
|
2078
|
-
*
|
|
2027
|
+
* Configuration options for expect() matches.
|
|
2079
2028
|
*/
|
|
2080
|
-
|
|
2029
|
+
expect?: {
|
|
2030
|
+
/**
|
|
2031
|
+
* Throw an error if tests don't have any expect() assertions.
|
|
2032
|
+
*/
|
|
2033
|
+
requireAssertions?: boolean;
|
|
2034
|
+
/**
|
|
2035
|
+
* Default options for expect.poll()
|
|
2036
|
+
*/
|
|
2037
|
+
poll?: {
|
|
2038
|
+
/**
|
|
2039
|
+
* Timeout in milliseconds
|
|
2040
|
+
* @default 1000
|
|
2041
|
+
*/
|
|
2042
|
+
timeout?: number;
|
|
2043
|
+
/**
|
|
2044
|
+
* Polling interval in milliseconds
|
|
2045
|
+
* @default 50
|
|
2046
|
+
*/
|
|
2047
|
+
interval?: number;
|
|
2048
|
+
};
|
|
2049
|
+
};
|
|
2050
|
+
/**
|
|
2051
|
+
* Modify default Chai config. Vitest uses Chai for `expect` and `assert` matches.
|
|
2052
|
+
* https://github.com/chaijs/chai/blob/4.x.x/lib/chai/config.js
|
|
2053
|
+
*/
|
|
2054
|
+
chaiConfig?: ChaiConfig;
|
|
2081
2055
|
/**
|
|
2082
|
-
*
|
|
2083
|
-
*
|
|
2084
|
-
* Useful if you are testing calling CLI commands
|
|
2085
|
-
*
|
|
2086
|
-
* @default ['**\/package.json/**', '**\/{vitest,vite}.config.*\/**']
|
|
2056
|
+
* Stop test execution when given number of tests have failed.
|
|
2087
2057
|
*/
|
|
2088
|
-
|
|
2058
|
+
bail?: number;
|
|
2089
2059
|
/**
|
|
2090
|
-
*
|
|
2060
|
+
* Retry the test specific number of times if it fails.
|
|
2061
|
+
*
|
|
2062
|
+
* @default 0
|
|
2091
2063
|
*/
|
|
2092
|
-
|
|
2064
|
+
retry?: number;
|
|
2093
2065
|
/**
|
|
2094
|
-
*
|
|
2066
|
+
* Show full diff when snapshot fails instead of a patch.
|
|
2095
2067
|
*/
|
|
2096
|
-
|
|
2068
|
+
expandSnapshotDiff?: boolean;
|
|
2097
2069
|
/**
|
|
2098
|
-
*
|
|
2070
|
+
* By default, Vitest automatically intercepts console logging during tests for extra formatting of test file, test title, etc...
|
|
2071
|
+
* This is also required for console log preview on Vitest UI.
|
|
2072
|
+
* However, disabling such interception might help when you want to debug a code with normal synchronus terminal console logging.
|
|
2073
|
+
*
|
|
2074
|
+
* This option has no effect on browser pool since Vitest preserves original logging on browser devtools.
|
|
2075
|
+
*
|
|
2099
2076
|
* @default false
|
|
2100
2077
|
*/
|
|
2101
|
-
|
|
2078
|
+
disableConsoleIntercept?: boolean;
|
|
2102
2079
|
/**
|
|
2103
|
-
*
|
|
2080
|
+
* Always print console stack traces.
|
|
2081
|
+
*
|
|
2104
2082
|
* @default false
|
|
2105
2083
|
*/
|
|
2106
|
-
|
|
2084
|
+
printConsoleTrace?: boolean;
|
|
2107
2085
|
/**
|
|
2108
|
-
*
|
|
2086
|
+
* Include "location" property inside the test definition
|
|
2087
|
+
*
|
|
2109
2088
|
* @default false
|
|
2110
2089
|
*/
|
|
2111
|
-
|
|
2090
|
+
includeTaskLocation?: boolean;
|
|
2091
|
+
}
|
|
2092
|
+
interface TypecheckConfig {
|
|
2112
2093
|
/**
|
|
2113
|
-
*
|
|
2114
|
-
* @default false
|
|
2094
|
+
* Run typechecking tests alongisde regular tests.
|
|
2115
2095
|
*/
|
|
2116
|
-
|
|
2096
|
+
enabled?: boolean;
|
|
2117
2097
|
/**
|
|
2118
|
-
*
|
|
2119
|
-
* @default false
|
|
2098
|
+
* When typechecking is enabled, only run typechecking tests.
|
|
2120
2099
|
*/
|
|
2121
|
-
|
|
2100
|
+
only?: boolean;
|
|
2122
2101
|
/**
|
|
2123
|
-
*
|
|
2124
|
-
*
|
|
2125
|
-
* When set to true, the default port is 51204.
|
|
2102
|
+
* What tools to use for type checking.
|
|
2126
2103
|
*
|
|
2127
|
-
* @default
|
|
2104
|
+
* @default 'tsc'
|
|
2128
2105
|
*/
|
|
2129
|
-
|
|
2106
|
+
checker: 'tsc' | 'vue-tsc' | (string & Record<never, never>);
|
|
2130
2107
|
/**
|
|
2131
|
-
*
|
|
2108
|
+
* Pattern for files that should be treated as test files
|
|
2132
2109
|
*
|
|
2133
|
-
* @default
|
|
2110
|
+
* @default ['**\/*.{test,spec}-d.?(c|m)[jt]s?(x)']
|
|
2134
2111
|
*/
|
|
2135
|
-
|
|
2112
|
+
include: string[];
|
|
2136
2113
|
/**
|
|
2137
|
-
*
|
|
2138
|
-
* @experimental
|
|
2114
|
+
* Pattern for files that should not be treated as test files
|
|
2139
2115
|
*
|
|
2140
|
-
* @default
|
|
2116
|
+
* @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.*']
|
|
2141
2117
|
*/
|
|
2142
|
-
|
|
2118
|
+
exclude: string[];
|
|
2143
2119
|
/**
|
|
2144
|
-
*
|
|
2145
|
-
*
|
|
2146
|
-
* @default !process.env.CI
|
|
2120
|
+
* Check JS files that have `@ts-check` comment.
|
|
2121
|
+
* If you have it enabled in tsconfig, this will not overwrite it.
|
|
2147
2122
|
*/
|
|
2148
|
-
|
|
2123
|
+
allowJs?: boolean;
|
|
2149
2124
|
/**
|
|
2150
|
-
*
|
|
2151
|
-
*
|
|
2152
|
-
* @default '/__vitest__/'
|
|
2125
|
+
* Do not fail, if Vitest found errors outside the test files.
|
|
2153
2126
|
*/
|
|
2154
|
-
|
|
2127
|
+
ignoreSourceErrors?: boolean;
|
|
2155
2128
|
/**
|
|
2156
|
-
*
|
|
2129
|
+
* Path to tsconfig, relative to the project root.
|
|
2157
2130
|
*/
|
|
2158
|
-
|
|
2131
|
+
tsconfig?: string;
|
|
2132
|
+
}
|
|
2133
|
+
interface UserConfig extends InlineConfig {
|
|
2159
2134
|
/**
|
|
2160
|
-
*
|
|
2135
|
+
* Path to the config file.
|
|
2136
|
+
*
|
|
2137
|
+
* Default resolving to `vitest.config.*`, `vite.config.*`
|
|
2138
|
+
*
|
|
2139
|
+
* Setting to `false` will disable config resolving.
|
|
2161
2140
|
*/
|
|
2162
|
-
|
|
2141
|
+
config?: string | false | undefined;
|
|
2163
2142
|
/**
|
|
2164
|
-
*
|
|
2143
|
+
* Do not run tests when Vitest starts.
|
|
2144
|
+
*
|
|
2145
|
+
* Vitest will only run tests if it's called programmatically or the test file changes.
|
|
2146
|
+
*
|
|
2147
|
+
* CLI file filters will be ignored.
|
|
2165
2148
|
*/
|
|
2166
|
-
|
|
2149
|
+
standalone?: boolean;
|
|
2167
2150
|
/**
|
|
2168
|
-
*
|
|
2151
|
+
* Use happy-dom
|
|
2169
2152
|
*/
|
|
2170
|
-
|
|
2153
|
+
dom?: boolean;
|
|
2171
2154
|
/**
|
|
2172
|
-
*
|
|
2155
|
+
* Run tests that cover a list of source files
|
|
2173
2156
|
*/
|
|
2174
|
-
|
|
2157
|
+
related?: string[] | string;
|
|
2175
2158
|
/**
|
|
2176
|
-
*
|
|
2159
|
+
* Overrides Vite mode
|
|
2160
|
+
* @default 'test'
|
|
2177
2161
|
*/
|
|
2178
|
-
|
|
2162
|
+
mode?: string;
|
|
2179
2163
|
/**
|
|
2180
|
-
*
|
|
2164
|
+
* Runs tests that are affected by the changes in the repository, or between specified branch or commit hash
|
|
2165
|
+
* Requires initialized git repository
|
|
2166
|
+
* @default false
|
|
2181
2167
|
*/
|
|
2182
|
-
|
|
2168
|
+
changed?: boolean | string;
|
|
2183
2169
|
/**
|
|
2184
|
-
*
|
|
2185
|
-
*
|
|
2186
|
-
*
|
|
2170
|
+
* Test suite shard to execute in a format of <index>/<count>.
|
|
2171
|
+
* Will divide tests into a `count` numbers, and run only the `indexed` part.
|
|
2172
|
+
* Cannot be used with enabled watch.
|
|
2173
|
+
* @example --shard=2/3
|
|
2187
2174
|
*/
|
|
2188
|
-
|
|
2175
|
+
shard?: string;
|
|
2189
2176
|
/**
|
|
2190
|
-
*
|
|
2177
|
+
* Name of the project or projects to run.
|
|
2191
2178
|
*/
|
|
2192
|
-
|
|
2179
|
+
project?: string | string[];
|
|
2193
2180
|
/**
|
|
2194
|
-
*
|
|
2181
|
+
* Additional exclude patterns
|
|
2195
2182
|
*/
|
|
2196
|
-
|
|
2183
|
+
cliExclude?: string[];
|
|
2197
2184
|
/**
|
|
2198
|
-
*
|
|
2185
|
+
* Override vite config's clearScreen from cli
|
|
2199
2186
|
*/
|
|
2200
|
-
|
|
2187
|
+
clearScreen?: boolean;
|
|
2201
2188
|
/**
|
|
2202
|
-
*
|
|
2203
|
-
*
|
|
2204
|
-
* Return `false` to ignore the log.
|
|
2189
|
+
* benchmark.compare option exposed at the top level for cli
|
|
2205
2190
|
*/
|
|
2206
|
-
|
|
2191
|
+
compare?: string;
|
|
2207
2192
|
/**
|
|
2208
|
-
*
|
|
2209
|
-
* will be shown.
|
|
2210
|
-
*
|
|
2211
|
-
* Return `false` to omit the frame.
|
|
2193
|
+
* benchmark.outputJson option exposed at the top level for cli
|
|
2212
2194
|
*/
|
|
2213
|
-
|
|
2195
|
+
outputJson?: string;
|
|
2214
2196
|
/**
|
|
2215
|
-
*
|
|
2216
|
-
*
|
|
2217
|
-
* When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
|
|
2218
|
-
*
|
|
2219
|
-
* @default { include: [], modules: { classNameStrategy: false } }
|
|
2197
|
+
* Directory of blob reports to merge
|
|
2198
|
+
* @default '.vitest-reports'
|
|
2220
2199
|
*/
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2200
|
+
mergeReports?: string;
|
|
2201
|
+
}
|
|
2202
|
+
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'> {
|
|
2203
|
+
mode: VitestRunMode;
|
|
2204
|
+
base?: string;
|
|
2205
|
+
diff?: string | SerializedDiffOptions;
|
|
2206
|
+
bail?: number;
|
|
2207
|
+
setupFiles: string[];
|
|
2208
|
+
snapshotEnvironment?: string;
|
|
2209
|
+
config?: string;
|
|
2210
|
+
filters?: string[];
|
|
2211
|
+
testNamePattern?: RegExp;
|
|
2212
|
+
related?: string[];
|
|
2213
|
+
coverage: ResolvedCoverageOptions;
|
|
2214
|
+
snapshotOptions: SnapshotStateOptions;
|
|
2215
|
+
browser: ResolvedBrowserOptions;
|
|
2216
|
+
pool: Pool;
|
|
2217
|
+
poolOptions?: ResolvedPoolOptions;
|
|
2218
|
+
reporters: (InlineReporter | ReporterWithOptions)[];
|
|
2219
|
+
defines: Record<string, any>;
|
|
2220
|
+
api?: ApiConfig;
|
|
2221
|
+
cliExclude?: string[];
|
|
2222
|
+
benchmark?: Required<Omit<BenchmarkUserOptions, 'outputFile' | 'compare' | 'outputJson'>> & Pick<BenchmarkUserOptions, 'outputFile' | 'compare' | 'outputJson'>;
|
|
2223
|
+
shard?: {
|
|
2224
|
+
index: number;
|
|
2225
|
+
count: number;
|
|
2226
|
+
};
|
|
2227
|
+
cache: {
|
|
2228
|
+
/**
|
|
2229
|
+
* @deprecated
|
|
2230
|
+
*/
|
|
2231
|
+
dir: string;
|
|
2232
|
+
} | false;
|
|
2233
|
+
sequence: {
|
|
2234
|
+
sequencer: TestSequencerConstructor;
|
|
2235
|
+
hooks: SequenceHooks;
|
|
2236
|
+
setupFiles: SequenceSetupFiles;
|
|
2237
|
+
shuffle?: boolean;
|
|
2238
|
+
concurrent?: boolean;
|
|
2239
|
+
seed: number;
|
|
2240
|
+
};
|
|
2241
|
+
typecheck: Omit<TypecheckConfig, 'enabled'> & {
|
|
2242
|
+
enabled: boolean;
|
|
2243
|
+
};
|
|
2244
|
+
runner?: string;
|
|
2245
|
+
maxWorkers: number;
|
|
2246
|
+
minWorkers: number;
|
|
2247
|
+
}
|
|
2248
|
+
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';
|
|
2249
|
+
type ProjectConfig = Omit<UserConfig, NonProjectOptions | 'sequencer' | 'deps' | 'poolOptions'> & {
|
|
2250
|
+
sequencer?: Omit<SequenceOptions, 'sequencer' | 'seed'>;
|
|
2251
|
+
deps?: Omit<DepsOptions, 'moduleDirectories'>;
|
|
2252
|
+
poolOptions?: {
|
|
2253
|
+
threads?: Pick<NonNullable<PoolOptions['threads']>, 'singleThread' | 'isolate'>;
|
|
2254
|
+
vmThreads?: Pick<NonNullable<PoolOptions['vmThreads']>, 'singleThread'>;
|
|
2255
|
+
forks?: Pick<NonNullable<PoolOptions['forks']>, 'singleFork' | 'isolate'>;
|
|
2227
2256
|
};
|
|
2257
|
+
};
|
|
2258
|
+
type ResolvedProjectConfig = Omit<ResolvedConfig, Exclude<NonProjectOptions, 'coverage' | 'watch'>>;
|
|
2259
|
+
interface UserWorkspaceConfig extends UserConfig$1 {
|
|
2260
|
+
test?: ProjectConfig;
|
|
2261
|
+
}
|
|
2262
|
+
type UserProjectConfigFn = (env: ConfigEnv) => UserWorkspaceConfig | Promise<UserWorkspaceConfig>;
|
|
2263
|
+
type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
|
|
2264
|
+
type TestProjectConfiguration = string | (UserProjectConfigExport & {
|
|
2228
2265
|
/**
|
|
2229
|
-
*
|
|
2230
|
-
*
|
|
2266
|
+
* Relative path to the extendable config. All other options will be merged with this config.
|
|
2267
|
+
* If `true`, the project will inherit all options from the root config.
|
|
2268
|
+
* @example '../vite.config.ts'
|
|
2231
2269
|
*/
|
|
2232
|
-
|
|
2270
|
+
extends?: string | true;
|
|
2271
|
+
});
|
|
2272
|
+
/** @deprecated use `TestProjectConfiguration` instead */
|
|
2273
|
+
type WorkspaceProjectConfiguration = TestProjectConfiguration;
|
|
2274
|
+
|
|
2275
|
+
interface BrowserProviderInitializationOptions {
|
|
2276
|
+
browser: string;
|
|
2277
|
+
options?: BrowserProviderOptions;
|
|
2278
|
+
}
|
|
2279
|
+
interface CDPSession {
|
|
2280
|
+
send: (method: string, params?: Record<string, unknown>) => Promise<unknown>;
|
|
2281
|
+
on: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
2282
|
+
once: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
2283
|
+
off: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
2284
|
+
}
|
|
2285
|
+
interface BrowserProvider {
|
|
2286
|
+
name: string;
|
|
2287
|
+
/**
|
|
2288
|
+
* @experimental opt-in into file parallelisation
|
|
2289
|
+
*/
|
|
2290
|
+
supportsParallelism: boolean;
|
|
2291
|
+
getSupportedBrowsers: () => readonly string[];
|
|
2292
|
+
beforeCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
|
|
2293
|
+
afterCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
|
|
2294
|
+
getCommandsContext: (contextId: string) => Record<string, unknown>;
|
|
2295
|
+
openPage: (contextId: string, url: string, beforeNavigate?: () => Promise<void>) => Promise<void>;
|
|
2296
|
+
getCDPSession?: (contextId: string) => Promise<CDPSession>;
|
|
2297
|
+
close: () => Awaitable$1<void>;
|
|
2298
|
+
initialize(ctx: TestProject, options: BrowserProviderInitializationOptions): Awaitable$1<void>;
|
|
2299
|
+
}
|
|
2300
|
+
interface BrowserProviderModule {
|
|
2301
|
+
new (): BrowserProvider;
|
|
2302
|
+
}
|
|
2303
|
+
interface BrowserProviderOptions {
|
|
2304
|
+
}
|
|
2305
|
+
type BrowserBuiltinProvider = 'webdriverio' | 'playwright' | 'preview';
|
|
2306
|
+
interface BrowserConfigOptions {
|
|
2233
2307
|
/**
|
|
2234
|
-
*
|
|
2235
|
-
*
|
|
2308
|
+
* if running tests in the browser should be the default
|
|
2309
|
+
*
|
|
2310
|
+
* @default false
|
|
2236
2311
|
*/
|
|
2237
|
-
|
|
2238
|
-
/**
|
|
2239
|
-
* @deprecated Use Vite's "cacheDir" instead if you want to change the cache director. Note caches will be written to "cacheDir\/vitest".
|
|
2240
|
-
*/
|
|
2241
|
-
dir: string;
|
|
2242
|
-
};
|
|
2312
|
+
enabled?: boolean;
|
|
2243
2313
|
/**
|
|
2244
|
-
*
|
|
2314
|
+
* Name of the browser
|
|
2245
2315
|
*/
|
|
2246
|
-
|
|
2316
|
+
name: string;
|
|
2247
2317
|
/**
|
|
2248
|
-
*
|
|
2249
|
-
*
|
|
2250
|
-
*
|
|
2318
|
+
* Browser provider
|
|
2319
|
+
*
|
|
2320
|
+
* @default 'preview'
|
|
2251
2321
|
*/
|
|
2252
|
-
|
|
2322
|
+
provider?: BrowserBuiltinProvider | (string & {});
|
|
2253
2323
|
/**
|
|
2254
|
-
*
|
|
2324
|
+
* Options that are passed down to a browser provider.
|
|
2325
|
+
* To support type hinting, add one of the types to your tsconfig.json "compilerOptions.types" field:
|
|
2255
2326
|
*
|
|
2256
|
-
*
|
|
2327
|
+
* - for webdriverio: `@vitest/browser/providers/webdriverio`
|
|
2328
|
+
* - for playwright: `@vitest/browser/providers/playwright`
|
|
2329
|
+
*
|
|
2330
|
+
* @example
|
|
2331
|
+
* { playwright: { launch: { devtools: true } }
|
|
2257
2332
|
*/
|
|
2258
|
-
|
|
2333
|
+
providerOptions?: BrowserProviderOptions;
|
|
2259
2334
|
/**
|
|
2260
|
-
*
|
|
2335
|
+
* enable headless mode
|
|
2336
|
+
*
|
|
2337
|
+
* @default process.env.CI
|
|
2261
2338
|
*/
|
|
2262
|
-
|
|
2339
|
+
headless?: boolean;
|
|
2263
2340
|
/**
|
|
2264
|
-
*
|
|
2341
|
+
* Serve API options.
|
|
2265
2342
|
*
|
|
2266
|
-
*
|
|
2343
|
+
* The default port is 63315.
|
|
2267
2344
|
*/
|
|
2268
|
-
|
|
2345
|
+
api?: ApiConfig | number;
|
|
2269
2346
|
/**
|
|
2270
|
-
*
|
|
2347
|
+
* Isolate test environment after each test
|
|
2348
|
+
*
|
|
2349
|
+
* @default true
|
|
2271
2350
|
*/
|
|
2272
|
-
|
|
2351
|
+
isolate?: boolean;
|
|
2273
2352
|
/**
|
|
2274
|
-
*
|
|
2275
|
-
*
|
|
2353
|
+
* Run test files in parallel if provider supports this option
|
|
2354
|
+
* This option only has effect in headless mode (enabled in CI by default)
|
|
2276
2355
|
*
|
|
2277
|
-
*
|
|
2356
|
+
* @default // Same as "test.fileParallelism"
|
|
2278
2357
|
*/
|
|
2279
|
-
|
|
2358
|
+
fileParallelism?: boolean;
|
|
2280
2359
|
/**
|
|
2281
|
-
*
|
|
2282
|
-
* Provides similar experience as `--inspect-brk` Node CLI argument.
|
|
2360
|
+
* Show Vitest UI
|
|
2283
2361
|
*
|
|
2284
|
-
*
|
|
2362
|
+
* @default !process.env.CI
|
|
2285
2363
|
*/
|
|
2286
|
-
|
|
2364
|
+
ui?: boolean;
|
|
2287
2365
|
/**
|
|
2288
|
-
*
|
|
2366
|
+
* Default viewport size
|
|
2289
2367
|
*/
|
|
2290
|
-
|
|
2291
|
-
/**
|
|
2292
|
-
* Enable inspector
|
|
2293
|
-
*/
|
|
2294
|
-
enabled?: boolean;
|
|
2295
|
-
/**
|
|
2296
|
-
* Port to run inspector on
|
|
2297
|
-
*/
|
|
2298
|
-
port?: number;
|
|
2368
|
+
viewport?: {
|
|
2299
2369
|
/**
|
|
2300
|
-
*
|
|
2370
|
+
* Width of the viewport
|
|
2371
|
+
* @default 414
|
|
2301
2372
|
*/
|
|
2302
|
-
|
|
2373
|
+
width: number;
|
|
2303
2374
|
/**
|
|
2304
|
-
*
|
|
2375
|
+
* Height of the viewport
|
|
2376
|
+
* @default 896
|
|
2305
2377
|
*/
|
|
2306
|
-
|
|
2378
|
+
height: number;
|
|
2307
2379
|
};
|
|
2308
2380
|
/**
|
|
2309
|
-
*
|
|
2310
|
-
* @example
|
|
2311
|
-
* ```ts
|
|
2312
|
-
* // vitest.config.ts
|
|
2313
|
-
* export default defineConfig({
|
|
2314
|
-
* test: {
|
|
2315
|
-
* provide: {
|
|
2316
|
-
* someKey: 'someValue'
|
|
2317
|
-
* }
|
|
2318
|
-
* }
|
|
2319
|
-
* })
|
|
2320
|
-
* ```
|
|
2321
|
-
* ```ts
|
|
2322
|
-
* // test file
|
|
2323
|
-
* import { inject } from 'vitest'
|
|
2324
|
-
* const value = inject('someKey') // 'someValue'
|
|
2325
|
-
* ```
|
|
2326
|
-
*/
|
|
2327
|
-
provide?: Partial<ProvidedContext>;
|
|
2328
|
-
/**
|
|
2329
|
-
* Configuration options for expect() matches.
|
|
2381
|
+
* Locator options
|
|
2330
2382
|
*/
|
|
2331
|
-
|
|
2332
|
-
/**
|
|
2333
|
-
* Throw an error if tests don't have any expect() assertions.
|
|
2334
|
-
*/
|
|
2335
|
-
requireAssertions?: boolean;
|
|
2383
|
+
locators?: {
|
|
2336
2384
|
/**
|
|
2337
|
-
*
|
|
2385
|
+
* Attribute used to locate elements by test id
|
|
2386
|
+
* @default 'data-testid'
|
|
2338
2387
|
*/
|
|
2339
|
-
|
|
2340
|
-
/**
|
|
2341
|
-
* Timeout in milliseconds
|
|
2342
|
-
* @default 1000
|
|
2343
|
-
*/
|
|
2344
|
-
timeout?: number;
|
|
2345
|
-
/**
|
|
2346
|
-
* Polling interval in milliseconds
|
|
2347
|
-
* @default 50
|
|
2348
|
-
*/
|
|
2349
|
-
interval?: number;
|
|
2350
|
-
};
|
|
2388
|
+
testIdAttribute?: string;
|
|
2351
2389
|
};
|
|
2352
2390
|
/**
|
|
2353
|
-
*
|
|
2354
|
-
*
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
/**
|
|
2358
|
-
* Stop test execution when given number of tests have failed.
|
|
2391
|
+
* Directory where screenshots will be saved when page.screenshot() is called
|
|
2392
|
+
* If not set, all screenshots are saved to __screenshots__ directory in the same folder as the test file.
|
|
2393
|
+
* If this is set, it will be resolved relative to the project root.
|
|
2394
|
+
* @default __screenshots__
|
|
2359
2395
|
*/
|
|
2360
|
-
|
|
2396
|
+
screenshotDirectory?: string;
|
|
2361
2397
|
/**
|
|
2362
|
-
*
|
|
2363
|
-
*
|
|
2364
|
-
* @default 0
|
|
2398
|
+
* Should Vitest take screenshots if the test fails
|
|
2399
|
+
* @default !browser.ui
|
|
2365
2400
|
*/
|
|
2366
|
-
|
|
2401
|
+
screenshotFailures?: boolean;
|
|
2367
2402
|
/**
|
|
2368
|
-
*
|
|
2403
|
+
* Scripts injected into the tester iframe.
|
|
2404
|
+
* @deprecated Will be removed in the future, use `testerHtmlPath` instead.
|
|
2369
2405
|
*/
|
|
2370
|
-
|
|
2406
|
+
testerScripts?: BrowserScript[];
|
|
2371
2407
|
/**
|
|
2372
|
-
*
|
|
2373
|
-
* This is also required for console log preview on Vitest UI.
|
|
2374
|
-
* However, disabling such interception might help when you want to debug a code with normal synchronus terminal console logging.
|
|
2375
|
-
*
|
|
2376
|
-
* This option has no effect on browser pool since Vitest preserves original logging on browser devtools.
|
|
2377
|
-
*
|
|
2378
|
-
* @default false
|
|
2408
|
+
* Path to the index.html file that will be used to run tests.
|
|
2379
2409
|
*/
|
|
2380
|
-
|
|
2410
|
+
testerHtmlPath?: string;
|
|
2381
2411
|
/**
|
|
2382
|
-
*
|
|
2383
|
-
*
|
|
2384
|
-
* @default false
|
|
2412
|
+
* Scripts injected into the main window.
|
|
2385
2413
|
*/
|
|
2386
|
-
|
|
2414
|
+
orchestratorScripts?: BrowserScript[];
|
|
2387
2415
|
/**
|
|
2388
|
-
*
|
|
2389
|
-
*
|
|
2390
|
-
* @
|
|
2416
|
+
* Commands that will be executed on the server
|
|
2417
|
+
* via the browser `import("@vitest/browser/context").commands` API.
|
|
2418
|
+
* @see {@link https://vitest.dev/guide/browser/commands}
|
|
2391
2419
|
*/
|
|
2392
|
-
|
|
2420
|
+
commands?: Record<string, BrowserCommand<any>>;
|
|
2393
2421
|
}
|
|
2394
|
-
interface
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
/**
|
|
2416
|
-
* Pattern for files that should not be treated as test files
|
|
2417
|
-
*
|
|
2418
|
-
* @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.*']
|
|
2419
|
-
*/
|
|
2420
|
-
exclude: string[];
|
|
2421
|
-
/**
|
|
2422
|
-
* Check JS files that have `@ts-check` comment.
|
|
2423
|
-
* If you have it enabled in tsconfig, this will not overwrite it.
|
|
2424
|
-
*/
|
|
2425
|
-
allowJs?: boolean;
|
|
2426
|
-
/**
|
|
2427
|
-
* Do not fail, if Vitest found errors outside the test files.
|
|
2428
|
-
*/
|
|
2429
|
-
ignoreSourceErrors?: boolean;
|
|
2430
|
-
/**
|
|
2431
|
-
* Path to tsconfig, relative to the project root.
|
|
2432
|
-
*/
|
|
2433
|
-
tsconfig?: string;
|
|
2422
|
+
interface BrowserCommandContext {
|
|
2423
|
+
testPath: string | undefined;
|
|
2424
|
+
provider: BrowserProvider;
|
|
2425
|
+
project: TestProject;
|
|
2426
|
+
contextId: string;
|
|
2427
|
+
}
|
|
2428
|
+
interface BrowserServerStateContext {
|
|
2429
|
+
files: string[];
|
|
2430
|
+
method: 'run' | 'collect';
|
|
2431
|
+
resolve: () => void;
|
|
2432
|
+
reject: (v: unknown) => void;
|
|
2433
|
+
}
|
|
2434
|
+
interface BrowserOrchestrator {
|
|
2435
|
+
createTesters: (files: string[]) => Promise<void>;
|
|
2436
|
+
onCancel: (reason: CancelReason) => Promise<void>;
|
|
2437
|
+
$close: () => void;
|
|
2438
|
+
}
|
|
2439
|
+
interface BrowserServerState {
|
|
2440
|
+
orchestrators: Map<string, BrowserOrchestrator>;
|
|
2441
|
+
getContext: (contextId: string) => BrowserServerStateContext | undefined;
|
|
2442
|
+
createAsyncContext: (method: 'collect' | 'run', contextId: string, files: string[]) => Promise<void>;
|
|
2434
2443
|
}
|
|
2435
|
-
interface
|
|
2444
|
+
interface BrowserServer {
|
|
2445
|
+
vite: ViteDevServer;
|
|
2446
|
+
state: BrowserServerState;
|
|
2447
|
+
provider: BrowserProvider;
|
|
2448
|
+
close: () => Promise<void>;
|
|
2449
|
+
initBrowserProvider: () => Promise<void>;
|
|
2450
|
+
parseStacktrace: (stack: string) => ParsedStack[];
|
|
2451
|
+
parseErrorStacktrace: (error: ErrorWithDiff, options?: StackTraceParserOptions) => ParsedStack[];
|
|
2452
|
+
}
|
|
2453
|
+
interface BrowserCommand<Payload extends unknown[]> {
|
|
2454
|
+
(context: BrowserCommandContext, ...payload: Payload): Awaitable$1<any>;
|
|
2455
|
+
}
|
|
2456
|
+
interface BrowserScript {
|
|
2436
2457
|
/**
|
|
2437
|
-
*
|
|
2438
|
-
*
|
|
2439
|
-
* Default resolving to `vitest.config.*`, `vite.config.*`
|
|
2458
|
+
* If "content" is provided and type is "module", this will be its identifier.
|
|
2440
2459
|
*
|
|
2441
|
-
*
|
|
2460
|
+
* If you are using TypeScript, you can add `.ts` extension here for example.
|
|
2461
|
+
* @default `injected-${index}.js`
|
|
2442
2462
|
*/
|
|
2443
|
-
|
|
2463
|
+
id?: string;
|
|
2444
2464
|
/**
|
|
2445
|
-
*
|
|
2446
|
-
*
|
|
2447
|
-
* Vitest will only run tests if it's called programmatically or the test file changes.
|
|
2465
|
+
* JavaScript content to be injected. This string is processed by Vite plugins if type is "module".
|
|
2448
2466
|
*
|
|
2449
|
-
*
|
|
2467
|
+
* You can use `id` to give Vite a hint about the file extension.
|
|
2450
2468
|
*/
|
|
2451
|
-
|
|
2469
|
+
content?: string;
|
|
2452
2470
|
/**
|
|
2453
|
-
*
|
|
2471
|
+
* Path to the script. This value is resolved by Vite so it can be a node module or a file path.
|
|
2454
2472
|
*/
|
|
2455
|
-
|
|
2473
|
+
src?: string;
|
|
2456
2474
|
/**
|
|
2457
|
-
*
|
|
2475
|
+
* If the script should be loaded asynchronously.
|
|
2458
2476
|
*/
|
|
2459
|
-
|
|
2477
|
+
async?: boolean;
|
|
2460
2478
|
/**
|
|
2461
|
-
*
|
|
2462
|
-
* @default '
|
|
2479
|
+
* Script type.
|
|
2480
|
+
* @default 'module'
|
|
2463
2481
|
*/
|
|
2464
|
-
|
|
2482
|
+
type?: string;
|
|
2483
|
+
}
|
|
2484
|
+
interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
2485
|
+
enabled: boolean;
|
|
2486
|
+
headless: boolean;
|
|
2487
|
+
isolate: boolean;
|
|
2488
|
+
fileParallelism: boolean;
|
|
2489
|
+
api: ApiConfig;
|
|
2490
|
+
ui: boolean;
|
|
2491
|
+
viewport: {
|
|
2492
|
+
width: number;
|
|
2493
|
+
height: number;
|
|
2494
|
+
};
|
|
2495
|
+
screenshotFailures: boolean;
|
|
2496
|
+
locators: {
|
|
2497
|
+
testIdAttribute: string;
|
|
2498
|
+
};
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
declare class TestSpecification {
|
|
2465
2502
|
/**
|
|
2466
|
-
*
|
|
2467
|
-
* Requires initialized git repository
|
|
2468
|
-
* @default false
|
|
2503
|
+
* @deprecated use `project` instead
|
|
2469
2504
|
*/
|
|
2470
|
-
|
|
2505
|
+
readonly 0: TestProject;
|
|
2471
2506
|
/**
|
|
2472
|
-
*
|
|
2473
|
-
* Will divide tests into a `count` numbers, and run only the `indexed` part.
|
|
2474
|
-
* Cannot be used with enabled watch.
|
|
2475
|
-
* @example --shard=2/3
|
|
2507
|
+
* @deprecated use `moduleId` instead
|
|
2476
2508
|
*/
|
|
2477
|
-
|
|
2509
|
+
readonly 1: string;
|
|
2478
2510
|
/**
|
|
2479
|
-
*
|
|
2511
|
+
* @deprecated use `pool` instead
|
|
2480
2512
|
*/
|
|
2481
|
-
|
|
2513
|
+
readonly 2: {
|
|
2514
|
+
pool: Pool;
|
|
2515
|
+
};
|
|
2516
|
+
readonly project: TestProject;
|
|
2517
|
+
readonly moduleId: string;
|
|
2518
|
+
readonly pool: Pool;
|
|
2519
|
+
/** @private */
|
|
2520
|
+
readonly testLocations: number[] | undefined;
|
|
2521
|
+
constructor(project: TestProject, moduleId: string, pool: Pool, testLocations?: number[] | undefined);
|
|
2522
|
+
toJSON(): SerializedTestSpecification;
|
|
2482
2523
|
/**
|
|
2483
|
-
*
|
|
2524
|
+
* for backwards compatibility
|
|
2525
|
+
* @deprecated
|
|
2484
2526
|
*/
|
|
2485
|
-
|
|
2527
|
+
[Symbol.iterator](): Generator<string | TestProject, void, unknown>;
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
declare class TestProject {
|
|
2531
|
+
/** @deprecated */
|
|
2532
|
+
path: string | number;
|
|
2533
|
+
/** @deprecated */
|
|
2534
|
+
options?: InitializeProjectOptions | undefined;
|
|
2486
2535
|
/**
|
|
2487
|
-
*
|
|
2536
|
+
* The global Vitest instance.
|
|
2537
|
+
* @experimental The public Vitest API is experimental and does not follow semver.
|
|
2488
2538
|
*/
|
|
2489
|
-
|
|
2539
|
+
readonly vitest: Vitest;
|
|
2490
2540
|
/**
|
|
2491
|
-
*
|
|
2541
|
+
* Resolved global configuration. If there are no workspace projects, this will be the same as `config`.
|
|
2492
2542
|
*/
|
|
2493
|
-
|
|
2543
|
+
readonly globalConfig: ResolvedConfig;
|
|
2494
2544
|
/**
|
|
2495
|
-
*
|
|
2545
|
+
* Browser instance if the browser is enabled. This is initialized when the tests run for the first time.
|
|
2496
2546
|
*/
|
|
2497
|
-
|
|
2547
|
+
browser?: BrowserServer;
|
|
2548
|
+
/** @deprecated use `vitest` instead */
|
|
2549
|
+
ctx: Vitest;
|
|
2498
2550
|
/**
|
|
2499
|
-
*
|
|
2500
|
-
* @default '.vitest-reports'
|
|
2551
|
+
* Temporary directory for the project. This is unique for each project. Vitest stores transformed content here.
|
|
2501
2552
|
*/
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
pool: Pool;
|
|
2519
|
-
poolOptions?: ResolvedPoolOptions;
|
|
2520
|
-
reporters: (InlineReporter | ReporterWithOptions)[];
|
|
2521
|
-
defines: Record<string, any>;
|
|
2522
|
-
api?: ApiConfig;
|
|
2523
|
-
cliExclude?: string[];
|
|
2524
|
-
benchmark?: Required<Omit<BenchmarkUserOptions, 'outputFile' | 'compare' | 'outputJson'>> & Pick<BenchmarkUserOptions, 'outputFile' | 'compare' | 'outputJson'>;
|
|
2525
|
-
shard?: {
|
|
2526
|
-
index: number;
|
|
2527
|
-
count: number;
|
|
2528
|
-
};
|
|
2529
|
-
cache: {
|
|
2530
|
-
/**
|
|
2531
|
-
* @deprecated
|
|
2532
|
-
*/
|
|
2533
|
-
dir: string;
|
|
2534
|
-
} | false;
|
|
2535
|
-
sequence: {
|
|
2536
|
-
sequencer: TestSequencerConstructor;
|
|
2537
|
-
hooks: SequenceHooks;
|
|
2538
|
-
setupFiles: SequenceSetupFiles;
|
|
2539
|
-
shuffle?: boolean;
|
|
2540
|
-
concurrent?: boolean;
|
|
2541
|
-
seed: number;
|
|
2542
|
-
};
|
|
2543
|
-
typecheck: Omit<TypecheckConfig, 'enabled'> & {
|
|
2544
|
-
enabled: boolean;
|
|
2545
|
-
};
|
|
2546
|
-
runner?: string;
|
|
2547
|
-
maxWorkers: number;
|
|
2548
|
-
minWorkers: number;
|
|
2549
|
-
}
|
|
2550
|
-
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';
|
|
2551
|
-
type ProjectConfig = Omit<UserConfig, NonProjectOptions | 'sequencer' | 'deps' | 'poolOptions'> & {
|
|
2552
|
-
sequencer?: Omit<SequenceOptions, 'sequencer' | 'seed'>;
|
|
2553
|
-
deps?: Omit<DepsOptions, 'moduleDirectories'>;
|
|
2554
|
-
poolOptions?: {
|
|
2555
|
-
threads?: Pick<NonNullable<PoolOptions['threads']>, 'singleThread' | 'isolate'>;
|
|
2556
|
-
vmThreads?: Pick<NonNullable<PoolOptions['vmThreads']>, 'singleThread'>;
|
|
2557
|
-
forks?: Pick<NonNullable<PoolOptions['forks']>, 'singleFork' | 'isolate'>;
|
|
2558
|
-
};
|
|
2559
|
-
};
|
|
2560
|
-
type ResolvedProjectConfig = Omit<ResolvedConfig, NonProjectOptions>;
|
|
2561
|
-
interface UserWorkspaceConfig extends UserConfig$1 {
|
|
2562
|
-
test?: ProjectConfig;
|
|
2563
|
-
}
|
|
2564
|
-
type UserProjectConfigFn = (env: ConfigEnv) => UserWorkspaceConfig | Promise<UserWorkspaceConfig>;
|
|
2565
|
-
type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
|
|
2566
|
-
type WorkspaceProjectConfiguration = string | (UserProjectConfigExport & {
|
|
2553
|
+
readonly tmpDir: string;
|
|
2554
|
+
vitenode: ViteNodeServer;
|
|
2555
|
+
runner: ViteNodeRunner;
|
|
2556
|
+
typechecker?: Typechecker;
|
|
2557
|
+
private closingPromise;
|
|
2558
|
+
private testFilesList;
|
|
2559
|
+
private typecheckFilesList;
|
|
2560
|
+
private _globalSetups?;
|
|
2561
|
+
private _provided;
|
|
2562
|
+
private _config?;
|
|
2563
|
+
private _vite?;
|
|
2564
|
+
constructor(
|
|
2565
|
+
/** @deprecated */
|
|
2566
|
+
path: string | number, vitest: Vitest,
|
|
2567
|
+
/** @deprecated */
|
|
2568
|
+
options?: InitializeProjectOptions | undefined);
|
|
2567
2569
|
/**
|
|
2568
|
-
*
|
|
2569
|
-
* @example '../vite.config.ts'
|
|
2570
|
+
* Provide a value to the test context. This value will be available to all tests with `inject`.
|
|
2570
2571
|
*/
|
|
2571
|
-
extends
|
|
2572
|
-
});
|
|
2573
|
-
|
|
2574
|
-
declare class TestProject {
|
|
2572
|
+
provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
|
|
2575
2573
|
/**
|
|
2576
|
-
* The global
|
|
2577
|
-
* @experimental The public Vitest API is experimental and does not follow semver.
|
|
2574
|
+
* Get the provided context. The project context is merged with the global context.
|
|
2578
2575
|
*/
|
|
2579
|
-
|
|
2576
|
+
getProvidedContext(): ProvidedContext;
|
|
2580
2577
|
/**
|
|
2581
|
-
*
|
|
2582
|
-
* @
|
|
2578
|
+
* Creates a new test specification. Specifications describe how to run tests.
|
|
2579
|
+
* @param moduleId The file path
|
|
2583
2580
|
*/
|
|
2584
|
-
|
|
2581
|
+
createSpecification(moduleId: string, pool?: string, testLocations?: number[] | undefined): TestSpecification;
|
|
2582
|
+
toJSON(): SerializedTestProject;
|
|
2585
2583
|
/**
|
|
2586
2584
|
* Vite's dev server instance. Every workspace project has its own server.
|
|
2587
2585
|
*/
|
|
2588
|
-
|
|
2586
|
+
get vite(): ViteDevServer;
|
|
2589
2587
|
/**
|
|
2590
2588
|
* Resolved project configuration.
|
|
2591
2589
|
*/
|
|
2592
|
-
|
|
2593
|
-
/**
|
|
2594
|
-
* Resolved global configuration. If there are no workspace projects, this will be the same as `config`.
|
|
2595
|
-
*/
|
|
2596
|
-
readonly globalConfig: ResolvedConfig;
|
|
2590
|
+
get config(): ResolvedConfig;
|
|
2597
2591
|
/**
|
|
2598
2592
|
* The name of the project or an empty string if not set.
|
|
2599
2593
|
*/
|
|
2600
|
-
|
|
2601
|
-
constructor(workspaceProject: WorkspaceProject);
|
|
2594
|
+
get name(): string;
|
|
2602
2595
|
/**
|
|
2603
2596
|
* Serialized project configuration. This is the config that tests receive.
|
|
2604
2597
|
*/
|
|
2605
2598
|
get serializedConfig(): SerializedConfig;
|
|
2599
|
+
/** @deprecated use `vite` instead */
|
|
2600
|
+
get server(): ViteDevServer;
|
|
2606
2601
|
/**
|
|
2607
|
-
*
|
|
2602
|
+
* Check if this is the root project. The root project is the one that has the root config.
|
|
2608
2603
|
*/
|
|
2609
|
-
|
|
2604
|
+
isRootProject(): boolean;
|
|
2605
|
+
/** @deprecated use `isRootProject` instead */
|
|
2606
|
+
isCore(): boolean;
|
|
2607
|
+
/** @deprecated use `createSpecification` instead */
|
|
2608
|
+
createSpec(moduleId: string, pool: string): WorkspaceSpec;
|
|
2609
|
+
/** @deprecated */
|
|
2610
|
+
initializeGlobalSetup(): Promise<void>;
|
|
2611
|
+
onTestsRerun(cb: OnTestsRerunHandler): void;
|
|
2612
|
+
/** @deprecated */
|
|
2613
|
+
teardownGlobalSetup(): Promise<void>;
|
|
2614
|
+
/** @deprecated use `vitest.logger` instead */
|
|
2615
|
+
get logger(): Logger;
|
|
2616
|
+
/** @deprecated use `.vite` or `.browser.vite` directly */
|
|
2617
|
+
getModulesByFilepath(file: string): Set<ModuleNode>;
|
|
2618
|
+
/** @deprecated use `.vite` or `.browser.vite` directly */
|
|
2619
|
+
getModuleById(id: string): ModuleNode | undefined;
|
|
2620
|
+
/** @deprecated use `.vite` or `.browser.vite` directly */
|
|
2621
|
+
getSourceMapModuleById(id: string): TransformResult$1['map'] | undefined;
|
|
2622
|
+
/** @deprecated use `vitest.reporters` instead */
|
|
2623
|
+
get reporters(): Reporter[];
|
|
2610
2624
|
/**
|
|
2611
|
-
*
|
|
2625
|
+
* Get all files in the project that match the globs in the config and the filters.
|
|
2626
|
+
* @param filters String filters to match the test files.
|
|
2612
2627
|
*/
|
|
2613
|
-
|
|
2614
|
-
|
|
2628
|
+
globTestFiles(filters?: string[]): Promise<{
|
|
2629
|
+
/**
|
|
2630
|
+
* Test files that match the filters.
|
|
2631
|
+
*/
|
|
2632
|
+
testFiles: string[];
|
|
2633
|
+
/**
|
|
2634
|
+
* Typecheck test files that match the filters. This will be empty unless `typecheck.enabled` is `true`.
|
|
2635
|
+
*/
|
|
2636
|
+
typecheckTestFiles: string[];
|
|
2637
|
+
}>;
|
|
2638
|
+
private globAllTestFiles;
|
|
2639
|
+
isBrowserEnabled(): boolean;
|
|
2640
|
+
/** @deprecated use `serializedConfig` instead */
|
|
2641
|
+
getSerializableConfig(): SerializedConfig;
|
|
2642
|
+
/**
|
|
2643
|
+
* Test if a file matches the test globs. This does the actual glob matching unlike `isTestFile`.
|
|
2644
|
+
*/
|
|
2645
|
+
matchesTestGlob(filepath: string, source?: string): boolean;
|
|
2646
|
+
/** @deprecated use `matchesTestGlob` instead */
|
|
2647
|
+
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
2648
|
+
private isInSourceTestCode;
|
|
2649
|
+
private filterFiles;
|
|
2650
|
+
/**
|
|
2651
|
+
* Closes the project and all associated resources. This can only be called once; the closing promise is cached until the server restarts.
|
|
2652
|
+
* If the resources are needed again, create a new project.
|
|
2653
|
+
*/
|
|
2654
|
+
close(): Promise<void>;
|
|
2655
|
+
/** @deprecated use `name` instead */
|
|
2656
|
+
getName(): string;
|
|
2657
|
+
/** @deprecated internal */
|
|
2658
|
+
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
2659
|
+
private _serializeOverridenConfig;
|
|
2660
|
+
private clearTmpDir;
|
|
2661
|
+
/** @deprecated */
|
|
2662
|
+
initBrowserProvider(): Promise<void>;
|
|
2615
2663
|
}
|
|
2664
|
+
|
|
2616
2665
|
interface SerializedTestProject {
|
|
2617
2666
|
name: string;
|
|
2618
2667
|
serializedConfig: SerializedConfig;
|
|
2619
2668
|
context: ProvidedContext;
|
|
2620
2669
|
}
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
* @deprecated use `project` instead
|
|
2625
|
-
*/
|
|
2626
|
-
readonly 0: WorkspaceProject;
|
|
2627
|
-
/**
|
|
2628
|
-
* @deprecated use `moduleId` instead
|
|
2629
|
-
*/
|
|
2630
|
-
readonly 1: string;
|
|
2631
|
-
/**
|
|
2632
|
-
* @deprecated use `pool` instead
|
|
2633
|
-
*/
|
|
2634
|
-
readonly 2: {
|
|
2635
|
-
pool: Pool;
|
|
2636
|
-
};
|
|
2637
|
-
readonly project: TestProject;
|
|
2638
|
-
readonly moduleId: string;
|
|
2639
|
-
readonly pool: Pool;
|
|
2640
|
-
constructor(workspaceProject: WorkspaceProject, moduleId: string, pool: Pool);
|
|
2641
|
-
toJSON(): SerializedTestSpecification;
|
|
2642
|
-
/**
|
|
2643
|
-
* for backwards compatibility
|
|
2644
|
-
* @deprecated
|
|
2645
|
-
*/
|
|
2646
|
-
[Symbol.iterator](): Generator<string | WorkspaceProject, void, unknown>;
|
|
2670
|
+
interface InitializeProjectOptions extends UserWorkspaceConfig {
|
|
2671
|
+
configFile: string | false;
|
|
2672
|
+
extends?: string;
|
|
2647
2673
|
}
|
|
2648
2674
|
|
|
2649
2675
|
/**
|
|
@@ -2653,7 +2679,7 @@ type WorkspaceSpec = TestSpecification & [
|
|
|
2653
2679
|
/**
|
|
2654
2680
|
* @deprecated use spec.project instead
|
|
2655
2681
|
*/
|
|
2656
|
-
project:
|
|
2682
|
+
project: TestProject,
|
|
2657
2683
|
/**
|
|
2658
2684
|
* @deprecated use spec.moduleId instead
|
|
2659
2685
|
*/
|
|
@@ -2672,7 +2698,7 @@ interface ProcessPool {
|
|
|
2672
2698
|
collectTests: RunWithFiles;
|
|
2673
2699
|
close?: () => Awaitable$1<void>;
|
|
2674
2700
|
}
|
|
2675
|
-
declare function getFilePoolName(project:
|
|
2701
|
+
declare function getFilePoolName(project: TestProject, file: string): Pool;
|
|
2676
2702
|
|
|
2677
2703
|
interface SuiteResultCache {
|
|
2678
2704
|
failed: boolean;
|
|
@@ -2739,17 +2765,18 @@ declare class StateManager {
|
|
|
2739
2765
|
* Return files that were running or collected.
|
|
2740
2766
|
*/
|
|
2741
2767
|
getFiles(keys?: string[]): File[];
|
|
2768
|
+
getTestModules(keys?: string[]): TestModule[];
|
|
2742
2769
|
getFilepaths(): string[];
|
|
2743
2770
|
getFailedFilepaths(): string[];
|
|
2744
2771
|
collectPaths(paths?: string[]): void;
|
|
2745
|
-
collectFiles(project:
|
|
2746
|
-
clearFiles(project:
|
|
2747
|
-
updateId(task: Task, project:
|
|
2772
|
+
collectFiles(project: TestProject, files?: File[]): void;
|
|
2773
|
+
clearFiles(project: TestProject, paths?: string[]): void;
|
|
2774
|
+
updateId(task: Task, project: TestProject): void;
|
|
2748
2775
|
getReportedEntity(task: Task): TestCase | TestSuite | TestModule | undefined;
|
|
2749
2776
|
updateTasks(packs: TaskResultPack[]): void;
|
|
2750
2777
|
updateUserLog(log: UserConsoleLog): void;
|
|
2751
2778
|
getCountOfFailedTests(): number;
|
|
2752
|
-
cancelFiles(files: string[], project:
|
|
2779
|
+
cancelFiles(files: string[], project: TestProject): void;
|
|
2753
2780
|
}
|
|
2754
2781
|
|
|
2755
2782
|
interface VitestOptions {
|
|
@@ -2783,17 +2810,14 @@ declare class Vitest {
|
|
|
2783
2810
|
restartsCount: number;
|
|
2784
2811
|
runner: ViteNodeRunner;
|
|
2785
2812
|
packageInstaller: VitestPackageInstaller;
|
|
2786
|
-
private coreWorkspaceProject;
|
|
2787
2813
|
/** @private */
|
|
2788
|
-
resolvedProjects:
|
|
2789
|
-
projects:
|
|
2814
|
+
resolvedProjects: TestProject[];
|
|
2815
|
+
projects: TestProject[];
|
|
2790
2816
|
distPath: string;
|
|
2791
2817
|
private _cachedSpecs;
|
|
2792
2818
|
private _workspaceConfigPath?;
|
|
2793
2819
|
/** @deprecated use `_cachedSpecs` */
|
|
2794
|
-
projectTestFiles: Map<string,
|
|
2795
|
-
/** @private */
|
|
2796
|
-
_browserLastPort: number;
|
|
2820
|
+
projectTestFiles: Map<string, TestSpecification[]>;
|
|
2797
2821
|
constructor(mode: VitestRunMode, options?: VitestOptions);
|
|
2798
2822
|
private _onRestartListeners;
|
|
2799
2823
|
private _onClose;
|
|
@@ -2802,21 +2826,13 @@ declare class Vitest {
|
|
|
2802
2826
|
private _onUserTestsRerun;
|
|
2803
2827
|
setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
|
|
2804
2828
|
provide<T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]): void;
|
|
2805
|
-
|
|
2806
|
-
* @deprecated internal, use `_createCoreProject` instead
|
|
2807
|
-
*/
|
|
2808
|
-
createCoreProject(): Promise<WorkspaceProject>;
|
|
2809
|
-
/**
|
|
2810
|
-
* @internal
|
|
2811
|
-
*/
|
|
2812
|
-
_createCoreProject(): Promise<WorkspaceProject>;
|
|
2813
|
-
getCoreWorkspaceProject(): WorkspaceProject;
|
|
2829
|
+
getRootTestProject(): TestProject;
|
|
2814
2830
|
/**
|
|
2815
2831
|
* @deprecated use Reported Task API instead
|
|
2816
2832
|
*/
|
|
2817
|
-
getProjectByTaskId(taskId: string):
|
|
2818
|
-
getProjectByName(name?: string):
|
|
2819
|
-
private
|
|
2833
|
+
getProjectByTaskId(taskId: string): TestProject;
|
|
2834
|
+
getProjectByName(name?: string): TestProject;
|
|
2835
|
+
private resolveWorkspaceConfigPath;
|
|
2820
2836
|
private resolveWorkspace;
|
|
2821
2837
|
private initCoverageProvider;
|
|
2822
2838
|
mergeReports(): Promise<void>;
|
|
@@ -2833,13 +2849,15 @@ declare class Vitest {
|
|
|
2833
2849
|
* @deprecated remove when vscode extension supports "getFileWorkspaceSpecs"
|
|
2834
2850
|
*/
|
|
2835
2851
|
getProjectsByTestFile(file: string): WorkspaceSpec[];
|
|
2836
|
-
getFileWorkspaceSpecs(file: string):
|
|
2852
|
+
getFileWorkspaceSpecs(file: string): TestSpecification[];
|
|
2837
2853
|
initializeGlobalSetup(paths: TestSpecification[]): Promise<void>;
|
|
2838
2854
|
runFiles(specs: TestSpecification[], allTestsRun: boolean): Promise<void>;
|
|
2839
2855
|
collectFiles(specs: WorkspaceSpec[]): Promise<void>;
|
|
2840
2856
|
cancelCurrentRun(reason: CancelReason): Promise<void>;
|
|
2841
2857
|
initBrowserServers(): Promise<void>;
|
|
2842
|
-
rerunFiles(files?: string[], trigger?: string, allTestsRun?: boolean): Promise<void>;
|
|
2858
|
+
rerunFiles(files?: string[], trigger?: string, allTestsRun?: boolean, resetTestNamePattern?: boolean): Promise<void>;
|
|
2859
|
+
private isSuite;
|
|
2860
|
+
rerunTask(id: string): Promise<void>;
|
|
2843
2861
|
changeProjectName(pattern: string): Promise<void>;
|
|
2844
2862
|
changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
|
|
2845
2863
|
changeFilenamePattern(pattern: string, files?: string[]): Promise<void>;
|
|
@@ -2847,7 +2865,7 @@ declare class Vitest {
|
|
|
2847
2865
|
updateSnapshot(files?: string[]): Promise<void>;
|
|
2848
2866
|
private _rerunTimer;
|
|
2849
2867
|
private scheduleRerun;
|
|
2850
|
-
getModuleProjects(filepath: string):
|
|
2868
|
+
getModuleProjects(filepath: string): TestProject[];
|
|
2851
2869
|
/**
|
|
2852
2870
|
* Watch only the specified tests. If no tests are provided, all tests will be watched.
|
|
2853
2871
|
*/
|
|
@@ -2873,7 +2891,7 @@ declare class Vitest {
|
|
|
2873
2891
|
getTestFilepaths(): Promise<string[]>;
|
|
2874
2892
|
globTestSpecs(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
2875
2893
|
/**
|
|
2876
|
-
* @deprecated use globTestSpecs instead
|
|
2894
|
+
* @deprecated use `globTestSpecs` instead
|
|
2877
2895
|
*/
|
|
2878
2896
|
globTestFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
2879
2897
|
private ensureSpecCached;
|
|
@@ -2885,4 +2903,4 @@ declare class Vitest {
|
|
|
2885
2903
|
onTestsRerun(fn: OnTestsRerunHandler): void;
|
|
2886
2904
|
}
|
|
2887
2905
|
|
|
2888
|
-
export { type SerializedTestProject as $, type ApiConfig as A, type BaseCoverageOptions as B, CoverageMap as C, type DepsOptimizationOptions as D, type
|
|
2906
|
+
export { type SerializedTestProject as $, type ApiConfig as A, type BaseCoverageOptions as B, CoverageMap as C, type DepsOptimizationOptions as D, type TypecheckConfig as E, type UserConfig as F, type ResolvedConfig as G, type ProjectConfig as H, type InlineConfig as I, type BenchmarkUserOptions as J, type VitestOptions as K, Logger as L, TestProject as M, type TestSequencer as N, type WorkspaceSpec as O, type Pool as P, TestModule as Q, type ResolvedCoverageOptions as R, type SerializedTestSpecification as S, type TestProjectConfiguration as T, type UserWorkspaceConfig as U, Vitest as V, type WorkspaceProjectConfiguration as W, type ModuleDiagnostic as X, VitestPackageInstaller as Y, type ProcessPool as Z, getFilePoolName as _, type ReportContext as a, type HTMLOptions as a0, type JsonOptions$1 as a1, type JUnitOptions as a2, TestCase as a3, TestSuite as a4, type TaskOptions as a5, TestCollection as a6, type TestDiagnostic as a7, type TestResult as a8, type TestResultFailed as a9, JUnitReporter as aA, TapFlatReporter as aB, TapReporter as aC, VerboseReporter as aD, BaseReporter as aE, TestFile as aF, type FileDiagnostic as aG, ReportersMap as aH, type BuiltinReporters as aI, type BuiltinReporterOptions as aJ, type JsonAssertionResult as aK, type JsonTestResult as aL, type JsonTestResults as aM, BenchmarkReportsMap as aN, type BenchmarkBuiltinReporters as aO, type TestResultPassed as aa, type TestResultSkipped as ab, type TestSequencerConstructor as ac, TestSpecification as ad, type BrowserBuiltinProvider as ae, type BrowserCommand as af, type BrowserCommandContext as ag, type BrowserOrchestrator as ah, type BrowserProvider as ai, type BrowserProviderInitializationOptions as aj, type BrowserProviderModule as ak, type BrowserProviderOptions as al, type BrowserServer as am, type BrowserServerState as an, type BrowserServerStateContext as ao, type CDPSession as ap, type ResolvedBrowserOptions as aq, type ResolvedProjectConfig as ar, type ResolveSnapshotPathHandler as as, type ResolveSnapshotPathHandlerContext as at, BasicReporter as au, DefaultReporter as av, DotReporter as aw, GithubActionsReporter as ax, HangingProcessReporter as ay, JsonReporter as az, type CoverageProvider as b, type CoverageProviderModule as c, type CoverageV8Options as d, type UserProjectConfigFn as e, type UserProjectConfigExport as f, type VitestEnvironment as g, type RawErrsMap as h, type TscErrorInfo as i, type CollectLineNumbers as j, type CollectLines as k, type RootAndTarget as l, type Context as m, type CoverageReporter as n, type CoverageProviderName as o, type CoverageOptions as p, type CoverageIstanbulOptions as q, type CustomProviderOptions as r, type Reporter as s, type BrowserScript as t, type BrowserConfigOptions as u, type BuiltinEnvironment as v, type PoolOptions as w, type CSSModuleScopeStrategy as x, type VitestRunMode as y, type TransformModePatterns as z };
|