vitest 3.0.0-beta.1 → 3.0.0-beta.3
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 +12 -9
- package/dist/browser.js +2 -2
- package/dist/chunks/{RandomSequencer.gisBJ77r.js → RandomSequencer.C6x84bNN.js} +4 -3
- package/dist/chunks/{base.CkcgFVQd.js → base.CQ2VEtuH.js} +1 -1
- package/dist/chunks/{cac.CWCZimpS.js → cac.e7qW4xLT.js} +34 -18
- package/dist/chunks/{cli-api.BKUOv0Nc.js → cli-api.CWDlED-m.js} +1126 -537
- package/dist/chunks/{coverage.BoMDb1ip.js → coverage.BWeNbfBa.js} +4 -4
- package/dist/chunks/{creator.DcAcUhMD.js → creator.Ot9GlSGw.js} +16 -14
- package/dist/chunks/{environment.CT0jpO-1.d.ts → environment.d8YfPkTm.d.ts} +1 -3
- package/dist/chunks/{globals.DJTzb7B3.js → globals.BFncSRNA.js} +2 -2
- package/dist/chunks/{index.CkOJwybT.js → index.BBoOXW-l.js} +7 -2
- package/dist/chunks/{index.BqHViJW9.js → index.CkWmZCXU.js} +1 -1
- package/dist/chunks/{index.DKe7vK-G.js → index.CzkCSFCy.js} +670 -628
- package/dist/chunks/{reporters.BZbwTvrM.d.ts → reporters.DCiyjXOg.d.ts} +634 -532
- package/dist/chunks/{resolveConfig.3rGGWga5.js → resolveConfig.C1d7TK-U.js} +5560 -5541
- package/dist/chunks/{runBaseTests.C6huCAng.js → runBaseTests.qNWRkgHj.js} +11 -10
- package/dist/chunks/{setup-common.B5ClyS48.js → setup-common.Cp_bu5q3.js} +1 -1
- package/dist/chunks/types.BOjykUpq.d.ts +27 -0
- package/dist/chunks/{utils.CMUTX-p8.js → utils.Coei4Wlj.js} +1 -1
- package/dist/chunks/{vi.CZKezqeD.js → vi.S4Fq8wSo.js} +2 -1
- package/dist/chunks/{vite.DIfmneq0.d.ts → vite.CRSMFy31.d.ts} +1 -1
- package/dist/chunks/{worker.umPNbBNk.d.ts → worker.R-PA7DpW.d.ts} +1 -1
- package/dist/chunks/{worker.CmzGeuVD.d.ts → worker.XbtCXEXv.d.ts} +4 -3
- package/dist/cli.js +1 -1
- package/dist/config.cjs +1 -0
- package/dist/config.d.ts +6 -8
- package/dist/config.js +1 -0
- package/dist/coverage.d.ts +4 -6
- package/dist/coverage.js +33 -8
- package/dist/environments.d.ts +2 -2
- package/dist/execute.d.ts +2 -2
- package/dist/index.d.ts +11 -14
- package/dist/index.js +2 -2
- package/dist/node.d.ts +22 -17
- package/dist/node.js +66 -32
- package/dist/reporters.d.ts +4 -6
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +2 -2
- package/dist/runners.js +3 -3
- package/dist/suite.d.ts +1 -1
- package/dist/workers/forks.js +1 -1
- package/dist/workers/runVmTests.js +7 -7
- package/dist/workers/threads.js +1 -1
- package/dist/workers.d.ts +3 -3
- package/dist/workers.js +1 -1
- package/package.json +15 -15
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import * as _vitest_runner from '@vitest/runner';
|
|
2
|
-
import {
|
|
3
|
-
import { b as Awaitable, U as UserConsoleLog, A as AfterSuiteRunMeta, c as Arrayable$1, f as EnvironmentOptions, P as ProvidedContext
|
|
2
|
+
import { TaskMeta, Suite, File, TaskResultPack, Task, 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 } from './environment.d8YfPkTm.js';
|
|
4
|
+
import { TestError, ParsedStack, Arrayable, ErrorWithDiff, Awaitable as Awaitable$1 } from '@vitest/utils';
|
|
4
5
|
import { Writable } from 'node:stream';
|
|
5
6
|
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
7
|
import { StackTraceParserOptions } from '@vitest/utils/source-map';
|
|
9
8
|
import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.BTPBhmK5.js';
|
|
10
9
|
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
|
11
10
|
import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
|
|
12
11
|
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
12
|
+
import { ViteNodeServerOptions } from 'vite-node';
|
|
13
13
|
import * as chai from 'chai';
|
|
14
14
|
import { B as BenchmarkResult } from './benchmark.CFFwLv-O.js';
|
|
15
|
-
import { ViteNodeRunner } from 'vite-node/client';
|
|
16
|
-
import { ViteNodeServer } from 'vite-node/server';
|
|
17
15
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
18
16
|
import { Stats } from 'node:fs';
|
|
19
17
|
|
|
@@ -25,95 +23,11 @@ type SerializedTestSpecification = [
|
|
|
25
23
|
file: string,
|
|
26
24
|
options: {
|
|
27
25
|
pool: string;
|
|
26
|
+
testLines?: number[] | undefined;
|
|
28
27
|
}
|
|
29
28
|
];
|
|
30
29
|
|
|
31
|
-
interface Reporter {
|
|
32
|
-
onInit?: (ctx: Vitest) => void;
|
|
33
|
-
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
34
|
-
onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable<void>;
|
|
35
|
-
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
36
|
-
onFinished?: (files: File[], errors: unknown[], coverage?: unknown) => Awaitable<void>;
|
|
37
|
-
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
38
|
-
onTestRemoved?: (trigger?: string) => Awaitable<void>;
|
|
39
|
-
onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
40
|
-
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
41
|
-
onServerRestart?: (reason?: string) => Awaitable<void>;
|
|
42
|
-
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
43
|
-
onProcessTimeout?: () => Awaitable<void>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
interface BaseOptions {
|
|
47
|
-
isTTY?: boolean;
|
|
48
|
-
}
|
|
49
|
-
declare abstract class BaseReporter implements Reporter {
|
|
50
|
-
start: number;
|
|
51
|
-
end: number;
|
|
52
|
-
watchFilters?: string[];
|
|
53
|
-
failedUnwatchedFiles: Task[];
|
|
54
|
-
isTTY: boolean;
|
|
55
|
-
ctx: Vitest;
|
|
56
|
-
renderSucceed: boolean;
|
|
57
|
-
protected verbose: boolean;
|
|
58
|
-
private _filesInWatchMode;
|
|
59
|
-
private _timeStart;
|
|
60
|
-
constructor(options?: BaseOptions);
|
|
61
|
-
onInit(ctx: Vitest): void;
|
|
62
|
-
log(...messages: any): void;
|
|
63
|
-
error(...messages: any): void;
|
|
64
|
-
relative(path: string): string;
|
|
65
|
-
onFinished(files?: File[], errors?: unknown[]): void;
|
|
66
|
-
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
67
|
-
protected printTask(task: Task): void;
|
|
68
|
-
private getDurationPrefix;
|
|
69
|
-
onWatcherStart(files?: File[], errors?: unknown[]): void;
|
|
70
|
-
onWatcherRerun(files: string[], trigger?: string): void;
|
|
71
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
72
|
-
onTestRemoved(trigger?: string): void;
|
|
73
|
-
shouldLog(log: UserConsoleLog): boolean;
|
|
74
|
-
onServerRestart(reason?: string): void;
|
|
75
|
-
reportSummary(files: File[], errors: unknown[]): void;
|
|
76
|
-
reportTestSummary(files: File[], errors: unknown[]): void;
|
|
77
|
-
private printErrorsSummary;
|
|
78
|
-
reportBenchmarkSummary(files: File[]): void;
|
|
79
|
-
private printTaskErrors;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
interface BlobOptions {
|
|
83
|
-
outputFile?: string;
|
|
84
|
-
}
|
|
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>;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
interface DefaultReporterOptions extends BaseOptions {
|
|
94
|
-
summary?: boolean;
|
|
95
|
-
}
|
|
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;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
interface HTMLOptions {
|
|
108
|
-
outputFile?: string;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
30
|
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
31
|
/**
|
|
118
32
|
* The project assosiacted with the test or suite.
|
|
119
33
|
*/
|
|
@@ -121,7 +35,7 @@ declare class ReportedTaskImplementation {
|
|
|
121
35
|
/**
|
|
122
36
|
* Unique identifier.
|
|
123
37
|
* 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
|
|
38
|
+
* The ID is based on the project name, module url and test order.
|
|
125
39
|
*/
|
|
126
40
|
readonly id: string;
|
|
127
41
|
/**
|
|
@@ -131,15 +45,14 @@ declare class ReportedTaskImplementation {
|
|
|
131
45
|
line: number;
|
|
132
46
|
column: number;
|
|
133
47
|
} | undefined;
|
|
134
|
-
protected constructor(task: Task, project: TestProject);
|
|
135
48
|
/**
|
|
136
|
-
*
|
|
49
|
+
* Checks if the test did not fail the suite.
|
|
50
|
+
* If the test is not finished yet or was skipped, it will return `true`.
|
|
137
51
|
*/
|
|
138
|
-
|
|
52
|
+
ok(): boolean;
|
|
139
53
|
}
|
|
140
54
|
declare class TestCase extends ReportedTaskImplementation {
|
|
141
55
|
#private;
|
|
142
|
-
readonly task: Test;
|
|
143
56
|
readonly type = "test";
|
|
144
57
|
/**
|
|
145
58
|
* Direct reference to the test module where the test or suite is defined.
|
|
@@ -157,20 +70,18 @@ declare class TestCase extends ReportedTaskImplementation {
|
|
|
157
70
|
* Parent suite. If the test was called directly inside the module, the parent will be the module itself.
|
|
158
71
|
*/
|
|
159
72
|
readonly parent: TestSuite | TestModule;
|
|
160
|
-
protected constructor(task: Test, project: TestProject);
|
|
161
73
|
/**
|
|
162
74
|
* Full name of the test including all parent suites separated with `>`.
|
|
163
75
|
*/
|
|
164
76
|
get fullName(): string;
|
|
165
77
|
/**
|
|
166
|
-
* Test results. Will be `undefined` if test is not finished yet or was just collected.
|
|
78
|
+
* Test results. Will be `undefined` if test is skipped, not finished yet or was just collected.
|
|
167
79
|
*/
|
|
168
80
|
result(): TestResult | undefined;
|
|
169
81
|
/**
|
|
170
|
-
* Checks if the test
|
|
171
|
-
* If the test is not finished yet or was skipped, it will return `true`.
|
|
82
|
+
* Checks if the test was skipped during collection or dynamically with `ctx.skip()`.
|
|
172
83
|
*/
|
|
173
|
-
|
|
84
|
+
skipped(): boolean;
|
|
174
85
|
/**
|
|
175
86
|
* Custom metadata that was attached to the test during its execution.
|
|
176
87
|
*/
|
|
@@ -185,7 +96,7 @@ declare class TestCollection {
|
|
|
185
96
|
#private;
|
|
186
97
|
constructor(task: Suite | File, project: TestProject);
|
|
187
98
|
/**
|
|
188
|
-
* Returns the test or suite at a specific index
|
|
99
|
+
* Returns the test or suite at a specific index.
|
|
189
100
|
*/
|
|
190
101
|
at(index: number): TestCase | TestSuite | undefined;
|
|
191
102
|
/**
|
|
@@ -216,16 +127,21 @@ declare class TestCollection {
|
|
|
216
127
|
}
|
|
217
128
|
|
|
218
129
|
declare abstract class SuiteImplementation extends ReportedTaskImplementation {
|
|
219
|
-
readonly task: Suite | File;
|
|
220
130
|
/**
|
|
221
131
|
* Collection of suites and tests that are part of this suite.
|
|
222
132
|
*/
|
|
223
133
|
readonly children: TestCollection;
|
|
224
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Checks if the suite was skipped during collection.
|
|
136
|
+
*/
|
|
137
|
+
skipped(): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Errors that happened outside of the test run during collection, like syntax errors.
|
|
140
|
+
*/
|
|
141
|
+
errors(): TestError[];
|
|
225
142
|
}
|
|
226
143
|
declare class TestSuite extends SuiteImplementation {
|
|
227
144
|
#private;
|
|
228
|
-
readonly task: Suite;
|
|
229
145
|
readonly type = "suite";
|
|
230
146
|
/**
|
|
231
147
|
* Name of the test or the suite.
|
|
@@ -243,14 +159,17 @@ declare class TestSuite extends SuiteImplementation {
|
|
|
243
159
|
* Options that suite was initiated with.
|
|
244
160
|
*/
|
|
245
161
|
readonly options: TaskOptions;
|
|
246
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Checks if the suite has any failed tests.
|
|
164
|
+
* This will also return `false` if suite failed during collection.
|
|
165
|
+
*/
|
|
166
|
+
ok: () => boolean;
|
|
247
167
|
/**
|
|
248
168
|
* Full name of the suite including all parent suites separated with `>`.
|
|
249
169
|
*/
|
|
250
170
|
get fullName(): string;
|
|
251
171
|
}
|
|
252
172
|
declare class TestModule extends SuiteImplementation {
|
|
253
|
-
readonly task: File;
|
|
254
173
|
readonly location: undefined;
|
|
255
174
|
readonly type = "module";
|
|
256
175
|
/**
|
|
@@ -259,7 +178,15 @@ declare class TestModule extends SuiteImplementation {
|
|
|
259
178
|
* This value corresponds to Vite's `ModuleGraph` id.
|
|
260
179
|
*/
|
|
261
180
|
readonly moduleId: string;
|
|
262
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Checks if the module has any failed tests.
|
|
183
|
+
* This will also return `false` if module failed during collection.
|
|
184
|
+
*/
|
|
185
|
+
ok: () => boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Checks if the module was skipped and didn't run.
|
|
188
|
+
*/
|
|
189
|
+
skipped: () => boolean;
|
|
263
190
|
/**
|
|
264
191
|
* Useful information about the module like duration, memory usage, etc.
|
|
265
192
|
* If the module was not executed yet, all diagnostic values will return `0`.
|
|
@@ -272,7 +199,7 @@ interface TaskOptions {
|
|
|
272
199
|
shuffle: boolean | undefined;
|
|
273
200
|
retry: number | undefined;
|
|
274
201
|
repeats: number | undefined;
|
|
275
|
-
mode: 'run' | 'only' | 'skip' | 'todo';
|
|
202
|
+
mode: 'run' | 'only' | 'skip' | 'todo' | 'queued';
|
|
276
203
|
}
|
|
277
204
|
type TestResult = TestResultPassed | TestResultFailed | TestResultSkipped;
|
|
278
205
|
interface TestResultPassed {
|
|
@@ -299,8 +226,8 @@ interface TestResultFailed {
|
|
|
299
226
|
}
|
|
300
227
|
interface TestResultSkipped {
|
|
301
228
|
/**
|
|
302
|
-
* The test was skipped with `only
|
|
303
|
-
* You can see which one was used in the `mode` option.
|
|
229
|
+
* The test was skipped with `only` (on another test), `skip` or `todo` flag.
|
|
230
|
+
* You can see which one was used in the `options.mode` option.
|
|
304
231
|
*/
|
|
305
232
|
state: 'skipped';
|
|
306
233
|
/**
|
|
@@ -308,7 +235,7 @@ interface TestResultSkipped {
|
|
|
308
235
|
*/
|
|
309
236
|
errors: undefined;
|
|
310
237
|
/**
|
|
311
|
-
* A custom note.
|
|
238
|
+
* A custom note passed down to `ctx.skip(note)`.
|
|
312
239
|
*/
|
|
313
240
|
note: string | undefined;
|
|
314
241
|
}
|
|
@@ -368,6 +295,88 @@ interface ModuleDiagnostic {
|
|
|
368
295
|
duration: number;
|
|
369
296
|
}
|
|
370
297
|
|
|
298
|
+
interface Reporter {
|
|
299
|
+
onInit?: (ctx: Vitest) => void;
|
|
300
|
+
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
301
|
+
onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable<void>;
|
|
302
|
+
onTestModuleQueued?: (file: TestModule) => Awaitable<void>;
|
|
303
|
+
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
304
|
+
onFinished?: (files: File[], errors: unknown[], coverage?: unknown) => Awaitable<void>;
|
|
305
|
+
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
306
|
+
onTestRemoved?: (trigger?: string) => Awaitable<void>;
|
|
307
|
+
onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
308
|
+
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
309
|
+
onServerRestart?: (reason?: string) => Awaitable<void>;
|
|
310
|
+
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
311
|
+
onProcessTimeout?: () => Awaitable<void>;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
interface BaseOptions {
|
|
315
|
+
isTTY?: boolean;
|
|
316
|
+
}
|
|
317
|
+
declare abstract class BaseReporter implements Reporter {
|
|
318
|
+
start: number;
|
|
319
|
+
end: number;
|
|
320
|
+
watchFilters?: string[];
|
|
321
|
+
failedUnwatchedFiles: Task[];
|
|
322
|
+
isTTY: boolean;
|
|
323
|
+
ctx: Vitest;
|
|
324
|
+
renderSucceed: boolean;
|
|
325
|
+
protected verbose: boolean;
|
|
326
|
+
private _filesInWatchMode;
|
|
327
|
+
private _timeStart;
|
|
328
|
+
constructor(options?: BaseOptions);
|
|
329
|
+
onInit(ctx: Vitest): void;
|
|
330
|
+
log(...messages: any): void;
|
|
331
|
+
error(...messages: any): void;
|
|
332
|
+
relative(path: string): string;
|
|
333
|
+
onFinished(files?: File[], errors?: unknown[]): void;
|
|
334
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
335
|
+
protected printTask(task: Task): void;
|
|
336
|
+
private getDurationPrefix;
|
|
337
|
+
onWatcherStart(files?: File[], errors?: unknown[]): void;
|
|
338
|
+
onWatcherRerun(files: string[], trigger?: string): void;
|
|
339
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
340
|
+
onTestRemoved(trigger?: string): void;
|
|
341
|
+
shouldLog(log: UserConsoleLog): boolean;
|
|
342
|
+
onServerRestart(reason?: string): void;
|
|
343
|
+
reportSummary(files: File[], errors: unknown[]): void;
|
|
344
|
+
reportTestSummary(files: File[], errors: unknown[]): void;
|
|
345
|
+
private printErrorsSummary;
|
|
346
|
+
reportBenchmarkSummary(files: File[]): void;
|
|
347
|
+
private printTaskErrors;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
interface BlobOptions {
|
|
351
|
+
outputFile?: string;
|
|
352
|
+
}
|
|
353
|
+
declare class BlobReporter implements Reporter {
|
|
354
|
+
ctx: Vitest;
|
|
355
|
+
options: BlobOptions;
|
|
356
|
+
constructor(options: BlobOptions);
|
|
357
|
+
onInit(ctx: Vitest): void;
|
|
358
|
+
onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
interface DefaultReporterOptions extends BaseOptions {
|
|
362
|
+
summary?: boolean;
|
|
363
|
+
}
|
|
364
|
+
declare class DefaultReporter extends BaseReporter {
|
|
365
|
+
private options;
|
|
366
|
+
private summary?;
|
|
367
|
+
constructor(options?: DefaultReporterOptions);
|
|
368
|
+
onTestModuleQueued(file: TestModule): void;
|
|
369
|
+
onInit(ctx: Vitest): void;
|
|
370
|
+
onPathsCollected(paths?: string[]): void;
|
|
371
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
372
|
+
onWatcherRerun(files: string[], trigger?: string): void;
|
|
373
|
+
onFinished(files?: File[], errors?: unknown[]): void;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
interface HTMLOptions {
|
|
377
|
+
outputFile?: string;
|
|
378
|
+
}
|
|
379
|
+
|
|
371
380
|
declare class BasicReporter extends BaseReporter {
|
|
372
381
|
constructor();
|
|
373
382
|
onInit(ctx: Vitest): void;
|
|
@@ -618,114 +627,12 @@ declare class VerboseReporter extends DefaultReporter {
|
|
|
618
627
|
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
619
628
|
}
|
|
620
629
|
|
|
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
630
|
declare class TypeCheckError extends Error {
|
|
676
631
|
message: string;
|
|
677
632
|
stacks: ParsedStack[];
|
|
678
633
|
name: string;
|
|
679
634
|
constructor(message: string, stacks: ParsedStack[]);
|
|
680
635
|
}
|
|
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
636
|
|
|
730
637
|
interface PrintErrorResult {
|
|
731
638
|
nearest?: ParsedStack;
|
|
@@ -920,13 +827,175 @@ interface BuiltinReporterOptions {
|
|
|
920
827
|
|
|
921
828
|
type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
|
|
922
829
|
|
|
830
|
+
type BuiltinPool = 'browser' | 'threads' | 'forks' | 'vmThreads' | 'vmForks' | 'typescript';
|
|
831
|
+
type Pool = BuiltinPool | (string & {});
|
|
832
|
+
interface PoolOptions extends Record<string, unknown> {
|
|
833
|
+
/**
|
|
834
|
+
* Run tests in `node:worker_threads`.
|
|
835
|
+
*
|
|
836
|
+
* Test isolation (when enabled) is done by spawning a new thread for each test file.
|
|
837
|
+
*
|
|
838
|
+
* This pool is used by default.
|
|
839
|
+
*/
|
|
840
|
+
threads?: ThreadsOptions & WorkerContextOptions;
|
|
841
|
+
/**
|
|
842
|
+
* Run tests in `node:child_process` using [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
843
|
+
*
|
|
844
|
+
* Test isolation (when enabled) is done by spawning a new child process for each test file.
|
|
845
|
+
*/
|
|
846
|
+
forks?: ForksOptions & WorkerContextOptions;
|
|
847
|
+
/**
|
|
848
|
+
* Run tests in isolated `node:vm`.
|
|
849
|
+
* Test files are run parallel using `node:worker_threads`.
|
|
850
|
+
*
|
|
851
|
+
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
852
|
+
*/
|
|
853
|
+
vmThreads?: ThreadsOptions & VmOptions;
|
|
854
|
+
/**
|
|
855
|
+
* Run tests in isolated `node:vm`.
|
|
856
|
+
*
|
|
857
|
+
* Test files are run parallel using `node:child_process` [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
858
|
+
*
|
|
859
|
+
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
860
|
+
*/
|
|
861
|
+
vmForks?: ForksOptions & VmOptions;
|
|
862
|
+
}
|
|
863
|
+
interface ResolvedPoolOptions extends PoolOptions {
|
|
864
|
+
threads?: ResolvedThreadsOptions & WorkerContextOptions;
|
|
865
|
+
forks?: ResolvedForksOptions & WorkerContextOptions;
|
|
866
|
+
vmThreads?: ResolvedThreadsOptions & VmOptions;
|
|
867
|
+
vmForks?: ResolvedForksOptions & VmOptions;
|
|
868
|
+
}
|
|
869
|
+
interface ThreadsOptions {
|
|
870
|
+
/** Minimum amount of threads to use */
|
|
871
|
+
minThreads?: number | string;
|
|
872
|
+
/** Maximum amount of threads to use */
|
|
873
|
+
maxThreads?: number | string;
|
|
874
|
+
/**
|
|
875
|
+
* Run tests inside a single thread.
|
|
876
|
+
*
|
|
877
|
+
* @default false
|
|
878
|
+
*/
|
|
879
|
+
singleThread?: boolean;
|
|
880
|
+
/**
|
|
881
|
+
* Use Atomics to synchronize threads
|
|
882
|
+
*
|
|
883
|
+
* This can improve performance in some cases, but might cause segfault in older Node versions.
|
|
884
|
+
*
|
|
885
|
+
* @default false
|
|
886
|
+
*/
|
|
887
|
+
useAtomics?: boolean;
|
|
888
|
+
}
|
|
889
|
+
interface ResolvedThreadsOptions extends ThreadsOptions {
|
|
890
|
+
minThreads?: number;
|
|
891
|
+
maxThreads?: number;
|
|
892
|
+
}
|
|
893
|
+
interface ForksOptions {
|
|
894
|
+
/** Minimum amount of child processes to use */
|
|
895
|
+
minForks?: number | string;
|
|
896
|
+
/** Maximum amount of child processes to use */
|
|
897
|
+
maxForks?: number | string;
|
|
898
|
+
/**
|
|
899
|
+
* Run tests inside a single fork.
|
|
900
|
+
*
|
|
901
|
+
* @default false
|
|
902
|
+
*/
|
|
903
|
+
singleFork?: boolean;
|
|
904
|
+
}
|
|
905
|
+
interface ResolvedForksOptions extends ForksOptions {
|
|
906
|
+
minForks?: number;
|
|
907
|
+
maxForks?: number;
|
|
908
|
+
}
|
|
909
|
+
interface WorkerContextOptions {
|
|
910
|
+
/**
|
|
911
|
+
* Isolate test environment by recycling `worker_threads` or `child_process` after each test
|
|
912
|
+
*
|
|
913
|
+
* @default true
|
|
914
|
+
*/
|
|
915
|
+
isolate?: boolean;
|
|
916
|
+
/**
|
|
917
|
+
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
918
|
+
*
|
|
919
|
+
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
920
|
+
*
|
|
921
|
+
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
922
|
+
*
|
|
923
|
+
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
924
|
+
*
|
|
925
|
+
* @default [] // no execution arguments are passed
|
|
926
|
+
*/
|
|
927
|
+
execArgv?: string[];
|
|
928
|
+
}
|
|
929
|
+
interface VmOptions {
|
|
930
|
+
/**
|
|
931
|
+
* Specifies the memory limit for `worker_thread` or `child_process` before they are recycled.
|
|
932
|
+
* If you see memory leaks, try to tinker this value.
|
|
933
|
+
*/
|
|
934
|
+
memoryLimit?: string | number;
|
|
935
|
+
/** Isolation is always enabled */
|
|
936
|
+
isolate?: true;
|
|
937
|
+
/**
|
|
938
|
+
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
939
|
+
*
|
|
940
|
+
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
941
|
+
*
|
|
942
|
+
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
943
|
+
*
|
|
944
|
+
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
945
|
+
*
|
|
946
|
+
* @default [] // no execution arguments are passed
|
|
947
|
+
*/
|
|
948
|
+
execArgv?: string[];
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
declare class TestSpecification {
|
|
952
|
+
/**
|
|
953
|
+
* @deprecated use `project` instead
|
|
954
|
+
*/
|
|
955
|
+
readonly 0: TestProject;
|
|
956
|
+
/**
|
|
957
|
+
* @deprecated use `moduleId` instead
|
|
958
|
+
*/
|
|
959
|
+
readonly 1: string;
|
|
960
|
+
/**
|
|
961
|
+
* @deprecated use `pool` instead
|
|
962
|
+
*/
|
|
963
|
+
readonly 2: {
|
|
964
|
+
pool: Pool;
|
|
965
|
+
};
|
|
966
|
+
/**
|
|
967
|
+
* The test project that the module belongs to.
|
|
968
|
+
*/
|
|
969
|
+
readonly project: TestProject;
|
|
970
|
+
/**
|
|
971
|
+
* The ID of the module in the Vite module graph. It is usually an absolute file path.
|
|
972
|
+
*/
|
|
973
|
+
readonly moduleId: string;
|
|
974
|
+
/**
|
|
975
|
+
* The current test pool. It's possible to have multiple pools in a single test project with `poolMatchGlob` and `typecheck.enabled`.
|
|
976
|
+
* @experimental In Vitest 4, the project will only support a single pool and this property will be removed.
|
|
977
|
+
*/
|
|
978
|
+
readonly pool: Pool;
|
|
979
|
+
/**
|
|
980
|
+
* Line numbers of the test locations to run.
|
|
981
|
+
*/
|
|
982
|
+
readonly testLines: number[] | undefined;
|
|
983
|
+
constructor(project: TestProject, moduleId: string, pool: Pool, testLines?: number[] | undefined);
|
|
984
|
+
toJSON(): SerializedTestSpecification;
|
|
985
|
+
/**
|
|
986
|
+
* for backwards compatibility
|
|
987
|
+
* @deprecated
|
|
988
|
+
*/
|
|
989
|
+
[Symbol.iterator](): Generator<string | TestProject, void, unknown>;
|
|
990
|
+
}
|
|
991
|
+
|
|
923
992
|
interface TestSequencer {
|
|
924
993
|
/**
|
|
925
994
|
* Slicing tests into shards. Will be run before `sort`.
|
|
926
995
|
* Only run, if `shard` is defined.
|
|
927
996
|
*/
|
|
928
|
-
shard: (files:
|
|
929
|
-
sort: (files:
|
|
997
|
+
shard: (files: TestSpecification[]) => Awaitable<TestSpecification[]>;
|
|
998
|
+
sort: (files: TestSpecification[]) => Awaitable<TestSpecification[]>;
|
|
930
999
|
}
|
|
931
1000
|
interface TestSequencerConstructor {
|
|
932
1001
|
new (ctx: Vitest): TestSequencer;
|
|
@@ -1087,7 +1156,9 @@ interface CoverageProviderModule {
|
|
|
1087
1156
|
/**
|
|
1088
1157
|
* Executed before tests are run in the worker thread.
|
|
1089
1158
|
*/
|
|
1090
|
-
startCoverage?: (
|
|
1159
|
+
startCoverage?: (runtimeOptions: {
|
|
1160
|
+
isolate: boolean;
|
|
1161
|
+
}) => unknown | Promise<unknown>;
|
|
1091
1162
|
/**
|
|
1092
1163
|
* Executed on after each run in the worker thread. Possible to return a payload passed to the provider
|
|
1093
1164
|
*/
|
|
@@ -1095,7 +1166,9 @@ interface CoverageProviderModule {
|
|
|
1095
1166
|
/**
|
|
1096
1167
|
* Executed after all tests have been run in the worker thread.
|
|
1097
1168
|
*/
|
|
1098
|
-
stopCoverage?: (
|
|
1169
|
+
stopCoverage?: (runtimeOptions: {
|
|
1170
|
+
isolate: boolean;
|
|
1171
|
+
}) => unknown | Promise<unknown>;
|
|
1099
1172
|
}
|
|
1100
1173
|
type CoverageReporter = keyof ReportOptions | (string & {});
|
|
1101
1174
|
type CoverageReporterWithOptions<ReporterName extends CoverageReporter = CoverageReporter> = ReporterName extends keyof ReportOptions ? ReportOptions[ReporterName] extends never ? [ReporterName, object] : [ReporterName, Partial<ReportOptions[ReporterName]>] : [ReporterName, Record<string, unknown>];
|
|
@@ -1201,208 +1274,87 @@ interface BaseCoverageOptions {
|
|
|
1201
1274
|
* }
|
|
1202
1275
|
* }
|
|
1203
1276
|
* ```
|
|
1204
|
-
*/
|
|
1205
|
-
thresholds?: Thresholds | ({
|
|
1206
|
-
[glob: string]: Pick<Thresholds, 100 | 'statements' | 'functions' | 'branches' | 'lines'>;
|
|
1207
|
-
} & Thresholds);
|
|
1208
|
-
/**
|
|
1209
|
-
* Watermarks for statements, lines, branches and functions.
|
|
1210
|
-
*
|
|
1211
|
-
* Default value is `[50,80]` for each property.
|
|
1212
|
-
*/
|
|
1213
|
-
watermarks?: {
|
|
1214
|
-
statements?: [number, number];
|
|
1215
|
-
functions?: [number, number];
|
|
1216
|
-
branches?: [number, number];
|
|
1217
|
-
lines?: [number, number];
|
|
1218
|
-
};
|
|
1219
|
-
/**
|
|
1220
|
-
* Generate coverage report even when tests fail.
|
|
1221
|
-
*
|
|
1222
|
-
* @default false
|
|
1223
|
-
*/
|
|
1224
|
-
reportOnFailure?: boolean;
|
|
1225
|
-
/**
|
|
1226
|
-
* Collect coverage of files outside the project `root`.
|
|
1227
|
-
*
|
|
1228
|
-
* @default false
|
|
1229
|
-
*/
|
|
1230
|
-
allowExternal?: boolean;
|
|
1231
|
-
/**
|
|
1232
|
-
* Apply exclusions again after coverage has been remapped to original sources.
|
|
1233
|
-
* This is useful when your source files are transpiled and may contain source maps
|
|
1234
|
-
* of non-source files.
|
|
1235
|
-
*
|
|
1236
|
-
* Use this option when you are seeing files that show up in report even if they
|
|
1237
|
-
* match your `coverage.exclude` patterns.
|
|
1238
|
-
*
|
|
1239
|
-
* @default false
|
|
1240
|
-
*/
|
|
1241
|
-
excludeAfterRemap?: boolean;
|
|
1242
|
-
/**
|
|
1243
|
-
* Concurrency limit used when processing the coverage results.
|
|
1244
|
-
* Defaults to `Math.min(20, os.availableParallelism?.() ?? os.cpus().length)`
|
|
1245
|
-
*/
|
|
1246
|
-
processingConcurrency?: number;
|
|
1247
|
-
}
|
|
1248
|
-
interface CoverageIstanbulOptions extends BaseCoverageOptions {
|
|
1249
|
-
/**
|
|
1250
|
-
* Set to array of class method names to ignore for coverage
|
|
1251
|
-
*
|
|
1252
|
-
* @default []
|
|
1253
|
-
*/
|
|
1254
|
-
ignoreClassMethods?: string[];
|
|
1255
|
-
}
|
|
1256
|
-
interface CoverageV8Options extends BaseCoverageOptions {
|
|
1257
|
-
/**
|
|
1258
|
-
* Ignore empty lines, comments and other non-runtime code, e.g. Typescript types
|
|
1259
|
-
*/
|
|
1260
|
-
ignoreEmptyLines?: boolean;
|
|
1261
|
-
}
|
|
1262
|
-
interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues> {
|
|
1263
|
-
/** Name of the module or path to a file to load the custom provider from */
|
|
1264
|
-
customProviderModule: string;
|
|
1265
|
-
}
|
|
1266
|
-
interface Thresholds {
|
|
1267
|
-
/** Set global thresholds to `100` */
|
|
1268
|
-
100?: boolean;
|
|
1269
|
-
/** Check thresholds per file. */
|
|
1270
|
-
perFile?: boolean;
|
|
1271
|
-
/**
|
|
1272
|
-
* Update threshold values automatically when current coverage is higher than earlier thresholds
|
|
1273
|
-
*
|
|
1274
|
-
* @default false
|
|
1275
|
-
*/
|
|
1276
|
-
autoUpdate?: boolean;
|
|
1277
|
-
/** Thresholds for statements */
|
|
1278
|
-
statements?: number;
|
|
1279
|
-
/** Thresholds for functions */
|
|
1280
|
-
functions?: number;
|
|
1281
|
-
/** Thresholds for branches */
|
|
1282
|
-
branches?: number;
|
|
1283
|
-
/** Thresholds for lines */
|
|
1284
|
-
lines?: number;
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
type BuiltinPool = 'browser' | 'threads' | 'forks' | 'vmThreads' | 'vmForks' | 'typescript';
|
|
1288
|
-
type Pool = BuiltinPool | (string & {});
|
|
1289
|
-
interface PoolOptions extends Record<string, unknown> {
|
|
1290
|
-
/**
|
|
1291
|
-
* Run tests in `node:worker_threads`.
|
|
1292
|
-
*
|
|
1293
|
-
* Test isolation (when enabled) is done by spawning a new thread for each test file.
|
|
1294
|
-
*
|
|
1295
|
-
* This pool is used by default.
|
|
1296
|
-
*/
|
|
1297
|
-
threads?: ThreadsOptions & WorkerContextOptions;
|
|
1298
|
-
/**
|
|
1299
|
-
* Run tests in `node:child_process` using [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
1300
|
-
*
|
|
1301
|
-
* Test isolation (when enabled) is done by spawning a new child process for each test file.
|
|
1302
|
-
*/
|
|
1303
|
-
forks?: ForksOptions & WorkerContextOptions;
|
|
1304
|
-
/**
|
|
1305
|
-
* Run tests in isolated `node:vm`.
|
|
1306
|
-
* Test files are run parallel using `node:worker_threads`.
|
|
1307
|
-
*
|
|
1308
|
-
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
1309
|
-
*/
|
|
1310
|
-
vmThreads?: ThreadsOptions & VmOptions;
|
|
1311
|
-
/**
|
|
1312
|
-
* Run tests in isolated `node:vm`.
|
|
1313
|
-
*
|
|
1314
|
-
* Test files are run parallel using `node:child_process` [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
1315
|
-
*
|
|
1316
|
-
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
1317
|
-
*/
|
|
1318
|
-
vmForks?: ForksOptions & VmOptions;
|
|
1319
|
-
}
|
|
1320
|
-
interface ResolvedPoolOptions extends PoolOptions {
|
|
1321
|
-
threads?: ResolvedThreadsOptions & WorkerContextOptions;
|
|
1322
|
-
forks?: ResolvedForksOptions & WorkerContextOptions;
|
|
1323
|
-
vmThreads?: ResolvedThreadsOptions & VmOptions;
|
|
1324
|
-
vmForks?: ResolvedForksOptions & VmOptions;
|
|
1325
|
-
}
|
|
1326
|
-
interface ThreadsOptions {
|
|
1327
|
-
/** Minimum amount of threads to use */
|
|
1328
|
-
minThreads?: number | string;
|
|
1329
|
-
/** Maximum amount of threads to use */
|
|
1330
|
-
maxThreads?: number | string;
|
|
1277
|
+
*/
|
|
1278
|
+
thresholds?: Thresholds | ({
|
|
1279
|
+
[glob: string]: Pick<Thresholds, 100 | 'statements' | 'functions' | 'branches' | 'lines'>;
|
|
1280
|
+
} & Thresholds);
|
|
1331
1281
|
/**
|
|
1332
|
-
*
|
|
1282
|
+
* Watermarks for statements, lines, branches and functions.
|
|
1333
1283
|
*
|
|
1334
|
-
*
|
|
1284
|
+
* Default value is `[50,80]` for each property.
|
|
1335
1285
|
*/
|
|
1336
|
-
|
|
1286
|
+
watermarks?: {
|
|
1287
|
+
statements?: [number, number];
|
|
1288
|
+
functions?: [number, number];
|
|
1289
|
+
branches?: [number, number];
|
|
1290
|
+
lines?: [number, number];
|
|
1291
|
+
};
|
|
1337
1292
|
/**
|
|
1338
|
-
*
|
|
1339
|
-
*
|
|
1340
|
-
* This can improve performance in some cases, but might cause segfault in older Node versions.
|
|
1293
|
+
* Generate coverage report even when tests fail.
|
|
1341
1294
|
*
|
|
1342
1295
|
* @default false
|
|
1343
1296
|
*/
|
|
1344
|
-
|
|
1345
|
-
}
|
|
1346
|
-
interface ResolvedThreadsOptions extends ThreadsOptions {
|
|
1347
|
-
minThreads?: number;
|
|
1348
|
-
maxThreads?: number;
|
|
1349
|
-
}
|
|
1350
|
-
interface ForksOptions {
|
|
1351
|
-
/** Minimum amount of child processes to use */
|
|
1352
|
-
minForks?: number | string;
|
|
1353
|
-
/** Maximum amount of child processes to use */
|
|
1354
|
-
maxForks?: number | string;
|
|
1297
|
+
reportOnFailure?: boolean;
|
|
1355
1298
|
/**
|
|
1356
|
-
*
|
|
1299
|
+
* Collect coverage of files outside the project `root`.
|
|
1357
1300
|
*
|
|
1358
1301
|
* @default false
|
|
1359
1302
|
*/
|
|
1360
|
-
|
|
1361
|
-
}
|
|
1362
|
-
interface ResolvedForksOptions extends ForksOptions {
|
|
1363
|
-
minForks?: number;
|
|
1364
|
-
maxForks?: number;
|
|
1365
|
-
}
|
|
1366
|
-
interface WorkerContextOptions {
|
|
1303
|
+
allowExternal?: boolean;
|
|
1367
1304
|
/**
|
|
1368
|
-
*
|
|
1305
|
+
* Apply exclusions again after coverage has been remapped to original sources.
|
|
1306
|
+
* This is useful when your source files are transpiled and may contain source maps
|
|
1307
|
+
* of non-source files.
|
|
1369
1308
|
*
|
|
1370
|
-
*
|
|
1309
|
+
* Use this option when you are seeing files that show up in report even if they
|
|
1310
|
+
* match your `coverage.exclude` patterns.
|
|
1311
|
+
*
|
|
1312
|
+
* @default false
|
|
1371
1313
|
*/
|
|
1372
|
-
|
|
1314
|
+
excludeAfterRemap?: boolean;
|
|
1373
1315
|
/**
|
|
1374
|
-
*
|
|
1375
|
-
*
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1316
|
+
* Concurrency limit used when processing the coverage results.
|
|
1317
|
+
* Defaults to `Math.min(20, os.availableParallelism?.() ?? os.cpus().length)`
|
|
1318
|
+
*/
|
|
1319
|
+
processingConcurrency?: number;
|
|
1320
|
+
}
|
|
1321
|
+
interface CoverageIstanbulOptions extends BaseCoverageOptions {
|
|
1322
|
+
/**
|
|
1323
|
+
* Set to array of class method names to ignore for coverage
|
|
1381
1324
|
*
|
|
1382
|
-
* @default []
|
|
1325
|
+
* @default []
|
|
1383
1326
|
*/
|
|
1384
|
-
|
|
1327
|
+
ignoreClassMethods?: string[];
|
|
1385
1328
|
}
|
|
1386
|
-
interface
|
|
1329
|
+
interface CoverageV8Options extends BaseCoverageOptions {
|
|
1387
1330
|
/**
|
|
1388
|
-
*
|
|
1389
|
-
* If you see memory leaks, try to tinker this value.
|
|
1331
|
+
* Ignore empty lines, comments and other non-runtime code, e.g. Typescript types
|
|
1390
1332
|
*/
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1333
|
+
ignoreEmptyLines?: boolean;
|
|
1334
|
+
}
|
|
1335
|
+
interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues> {
|
|
1336
|
+
/** Name of the module or path to a file to load the custom provider from */
|
|
1337
|
+
customProviderModule: string;
|
|
1338
|
+
}
|
|
1339
|
+
interface Thresholds {
|
|
1340
|
+
/** Set global thresholds to `100` */
|
|
1341
|
+
100?: boolean;
|
|
1342
|
+
/** Check thresholds per file. */
|
|
1343
|
+
perFile?: boolean;
|
|
1394
1344
|
/**
|
|
1395
|
-
*
|
|
1396
|
-
*
|
|
1397
|
-
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
1398
|
-
*
|
|
1399
|
-
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
1400
|
-
*
|
|
1401
|
-
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
1345
|
+
* Update threshold values automatically when current coverage is higher than earlier thresholds
|
|
1402
1346
|
*
|
|
1403
|
-
* @default
|
|
1347
|
+
* @default false
|
|
1404
1348
|
*/
|
|
1405
|
-
|
|
1349
|
+
autoUpdate?: boolean;
|
|
1350
|
+
/** Thresholds for statements */
|
|
1351
|
+
statements?: number;
|
|
1352
|
+
/** Thresholds for functions */
|
|
1353
|
+
functions?: number;
|
|
1354
|
+
/** Thresholds for branches */
|
|
1355
|
+
branches?: number;
|
|
1356
|
+
/** Thresholds for lines */
|
|
1357
|
+
lines?: number;
|
|
1406
1358
|
}
|
|
1407
1359
|
|
|
1408
1360
|
type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
|
|
@@ -2245,8 +2197,9 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
|
|
|
2245
2197
|
maxWorkers: number;
|
|
2246
2198
|
minWorkers: number;
|
|
2247
2199
|
}
|
|
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<
|
|
2200
|
+
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' | 'workspace';
|
|
2201
|
+
type ProjectConfig = Omit<InlineConfig, NonProjectOptions | 'sequencer' | 'deps' | 'poolOptions'> & {
|
|
2202
|
+
mode?: string;
|
|
2250
2203
|
sequencer?: Omit<SequenceOptions, 'sequencer' | 'seed'>;
|
|
2251
2204
|
deps?: Omit<DepsOptions, 'moduleDirectories'>;
|
|
2252
2205
|
poolOptions?: {
|
|
@@ -2291,9 +2244,9 @@ interface BrowserProvider {
|
|
|
2291
2244
|
getSupportedBrowsers: () => readonly string[];
|
|
2292
2245
|
beforeCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
|
|
2293
2246
|
afterCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
|
|
2294
|
-
getCommandsContext: (
|
|
2295
|
-
openPage: (
|
|
2296
|
-
getCDPSession?: (
|
|
2247
|
+
getCommandsContext: (sessionId: string) => Record<string, unknown>;
|
|
2248
|
+
openPage: (sessionId: string, url: string, beforeNavigate?: () => Promise<void>) => Promise<void>;
|
|
2249
|
+
getCDPSession?: (sessionId: string) => Promise<CDPSession>;
|
|
2297
2250
|
close: () => Awaitable$1<void>;
|
|
2298
2251
|
initialize(ctx: TestProject, options: BrowserProviderInitializationOptions): Awaitable$1<void>;
|
|
2299
2252
|
}
|
|
@@ -2303,6 +2256,13 @@ interface BrowserProviderModule {
|
|
|
2303
2256
|
interface BrowserProviderOptions {
|
|
2304
2257
|
}
|
|
2305
2258
|
type BrowserBuiltinProvider = 'webdriverio' | 'playwright' | 'preview';
|
|
2259
|
+
type UnsupportedProperties = 'browser' | 'typecheck' | 'alias' | 'sequence' | 'root' | 'pool' | 'poolOptions' | 'runner' | 'api' | 'deps' | 'testTransformMode' | 'poolMatchGlobs' | 'environmentMatchGlobs' | 'environment' | 'environmentOptions' | 'server' | 'benchmark';
|
|
2260
|
+
interface BrowserInstanceOption extends BrowserProviderOptions, Omit<ProjectConfig, UnsupportedProperties>, Pick<BrowserConfigOptions, 'headless' | 'locators' | 'viewport' | 'testerHtmlPath' | 'screenshotDirectory' | 'screenshotFailures'> {
|
|
2261
|
+
/**
|
|
2262
|
+
* Name of the browser
|
|
2263
|
+
*/
|
|
2264
|
+
browser: string;
|
|
2265
|
+
}
|
|
2306
2266
|
interface BrowserConfigOptions {
|
|
2307
2267
|
/**
|
|
2308
2268
|
* if running tests in the browser should be the default
|
|
@@ -2312,8 +2272,13 @@ interface BrowserConfigOptions {
|
|
|
2312
2272
|
enabled?: boolean;
|
|
2313
2273
|
/**
|
|
2314
2274
|
* Name of the browser
|
|
2275
|
+
* @deprecated use `configs` instead. if both are defined, this will filter `configs` by name.
|
|
2315
2276
|
*/
|
|
2316
|
-
name
|
|
2277
|
+
name?: string;
|
|
2278
|
+
/**
|
|
2279
|
+
* Configurations for different browser setups
|
|
2280
|
+
*/
|
|
2281
|
+
instances?: BrowserInstanceOption[];
|
|
2317
2282
|
/**
|
|
2318
2283
|
* Browser provider
|
|
2319
2284
|
*
|
|
@@ -2329,6 +2294,7 @@ interface BrowserConfigOptions {
|
|
|
2329
2294
|
*
|
|
2330
2295
|
* @example
|
|
2331
2296
|
* { playwright: { launch: { devtools: true } }
|
|
2297
|
+
* @deprecated use `configs` instead
|
|
2332
2298
|
*/
|
|
2333
2299
|
providerOptions?: BrowserProviderOptions;
|
|
2334
2300
|
/**
|
|
@@ -2418,16 +2384,25 @@ interface BrowserConfigOptions {
|
|
|
2418
2384
|
* @see {@link https://vitest.dev/guide/browser/commands}
|
|
2419
2385
|
*/
|
|
2420
2386
|
commands?: Record<string, BrowserCommand<any>>;
|
|
2387
|
+
/**
|
|
2388
|
+
* Timeout for connecting to the browser
|
|
2389
|
+
* @default 30000
|
|
2390
|
+
*/
|
|
2391
|
+
connectTimeout?: number;
|
|
2421
2392
|
}
|
|
2422
2393
|
interface BrowserCommandContext {
|
|
2423
2394
|
testPath: string | undefined;
|
|
2424
2395
|
provider: BrowserProvider;
|
|
2425
2396
|
project: TestProject;
|
|
2397
|
+
/** @deprecated use `sessionId` instead */
|
|
2426
2398
|
contextId: string;
|
|
2399
|
+
sessionId: string;
|
|
2427
2400
|
}
|
|
2428
|
-
interface
|
|
2401
|
+
interface BrowserServerStateSession {
|
|
2429
2402
|
files: string[];
|
|
2430
2403
|
method: 'run' | 'collect';
|
|
2404
|
+
project: TestProject;
|
|
2405
|
+
connected: () => void;
|
|
2431
2406
|
resolve: () => void;
|
|
2432
2407
|
reject: (v: unknown) => void;
|
|
2433
2408
|
}
|
|
@@ -2438,15 +2413,16 @@ interface BrowserOrchestrator {
|
|
|
2438
2413
|
}
|
|
2439
2414
|
interface BrowserServerState {
|
|
2440
2415
|
orchestrators: Map<string, BrowserOrchestrator>;
|
|
2441
|
-
getContext: (contextId: string) => BrowserServerStateContext | undefined;
|
|
2442
|
-
createAsyncContext: (method: 'collect' | 'run', contextId: string, files: string[]) => Promise<void>;
|
|
2443
2416
|
}
|
|
2444
|
-
interface
|
|
2417
|
+
interface ParentProjectBrowser {
|
|
2418
|
+
spawn: (project: TestProject) => ProjectBrowser;
|
|
2419
|
+
}
|
|
2420
|
+
interface ProjectBrowser {
|
|
2445
2421
|
vite: ViteDevServer;
|
|
2446
2422
|
state: BrowserServerState;
|
|
2447
2423
|
provider: BrowserProvider;
|
|
2448
2424
|
close: () => Promise<void>;
|
|
2449
|
-
initBrowserProvider: () => Promise<void>;
|
|
2425
|
+
initBrowserProvider: (project: TestProject) => Promise<void>;
|
|
2450
2426
|
parseStacktrace: (stack: string) => ParsedStack[];
|
|
2451
2427
|
parseErrorStacktrace: (error: ErrorWithDiff, options?: StackTraceParserOptions) => ParsedStack[];
|
|
2452
2428
|
}
|
|
@@ -2482,6 +2458,8 @@ interface BrowserScript {
|
|
|
2482
2458
|
type?: string;
|
|
2483
2459
|
}
|
|
2484
2460
|
interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
2461
|
+
name: string;
|
|
2462
|
+
providerOptions?: BrowserProviderOptions;
|
|
2485
2463
|
enabled: boolean;
|
|
2486
2464
|
headless: boolean;
|
|
2487
2465
|
isolate: boolean;
|
|
@@ -2498,39 +2476,9 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
|
2498
2476
|
};
|
|
2499
2477
|
}
|
|
2500
2478
|
|
|
2501
|
-
declare class TestSpecification {
|
|
2502
|
-
/**
|
|
2503
|
-
* @deprecated use `project` instead
|
|
2504
|
-
*/
|
|
2505
|
-
readonly 0: TestProject;
|
|
2506
|
-
/**
|
|
2507
|
-
* @deprecated use `moduleId` instead
|
|
2508
|
-
*/
|
|
2509
|
-
readonly 1: string;
|
|
2510
|
-
/**
|
|
2511
|
-
* @deprecated use `pool` instead
|
|
2512
|
-
*/
|
|
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;
|
|
2523
|
-
/**
|
|
2524
|
-
* for backwards compatibility
|
|
2525
|
-
* @deprecated
|
|
2526
|
-
*/
|
|
2527
|
-
[Symbol.iterator](): Generator<string | TestProject, void, unknown>;
|
|
2528
|
-
}
|
|
2529
|
-
|
|
2530
2479
|
declare class TestProject {
|
|
2531
2480
|
/** @deprecated */
|
|
2532
2481
|
path: string | number;
|
|
2533
|
-
/** @deprecated */
|
|
2534
2482
|
options?: InitializeProjectOptions | undefined;
|
|
2535
2483
|
/**
|
|
2536
2484
|
* The global Vitest instance.
|
|
@@ -2544,28 +2492,23 @@ declare class TestProject {
|
|
|
2544
2492
|
/**
|
|
2545
2493
|
* Browser instance if the browser is enabled. This is initialized when the tests run for the first time.
|
|
2546
2494
|
*/
|
|
2547
|
-
browser?:
|
|
2495
|
+
browser?: ProjectBrowser;
|
|
2548
2496
|
/** @deprecated use `vitest` instead */
|
|
2549
2497
|
ctx: Vitest;
|
|
2550
2498
|
/**
|
|
2551
2499
|
* Temporary directory for the project. This is unique for each project. Vitest stores transformed content here.
|
|
2552
2500
|
*/
|
|
2553
2501
|
readonly tmpDir: string;
|
|
2554
|
-
|
|
2555
|
-
runner: ViteNodeRunner;
|
|
2556
|
-
typechecker?: Typechecker;
|
|
2502
|
+
private runner;
|
|
2557
2503
|
private closingPromise;
|
|
2558
2504
|
private testFilesList;
|
|
2559
2505
|
private typecheckFilesList;
|
|
2560
2506
|
private _globalSetups?;
|
|
2561
2507
|
private _provided;
|
|
2562
|
-
private _config?;
|
|
2563
2508
|
private _vite?;
|
|
2564
2509
|
constructor(
|
|
2565
2510
|
/** @deprecated */
|
|
2566
|
-
path: string | number, vitest: Vitest,
|
|
2567
|
-
/** @deprecated */
|
|
2568
|
-
options?: InitializeProjectOptions | undefined);
|
|
2511
|
+
path: string | number, vitest: Vitest, options?: InitializeProjectOptions | undefined);
|
|
2569
2512
|
/**
|
|
2570
2513
|
* Provide a value to the test context. This value will be available to all tests with `inject`.
|
|
2571
2514
|
*/
|
|
@@ -2578,7 +2521,9 @@ declare class TestProject {
|
|
|
2578
2521
|
* Creates a new test specification. Specifications describe how to run tests.
|
|
2579
2522
|
* @param moduleId The file path
|
|
2580
2523
|
*/
|
|
2581
|
-
createSpecification(moduleId: string,
|
|
2524
|
+
createSpecification(moduleId: string, locations?: number[] | undefined,
|
|
2525
|
+
/** @internal */
|
|
2526
|
+
pool?: string): TestSpecification;
|
|
2582
2527
|
toJSON(): SerializedTestProject;
|
|
2583
2528
|
/**
|
|
2584
2529
|
* Vite's dev server instance. Every workspace project has its own server.
|
|
@@ -2637,12 +2582,13 @@ declare class TestProject {
|
|
|
2637
2582
|
}>;
|
|
2638
2583
|
private globAllTestFiles;
|
|
2639
2584
|
isBrowserEnabled(): boolean;
|
|
2585
|
+
private markTestFile;
|
|
2640
2586
|
/** @deprecated use `serializedConfig` instead */
|
|
2641
2587
|
getSerializableConfig(): SerializedConfig;
|
|
2642
2588
|
/**
|
|
2643
|
-
* Test if a file matches the test globs. This does the actual glob matching unlike `
|
|
2589
|
+
* Test if a file matches the test globs. This does the actual glob matching if the test is not cached, unlike `isCachedTestFile`.
|
|
2644
2590
|
*/
|
|
2645
|
-
matchesTestGlob(
|
|
2591
|
+
matchesTestGlob(moduleId: string, source?: () => string): boolean;
|
|
2646
2592
|
/** @deprecated use `matchesTestGlob` instead */
|
|
2647
2593
|
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
2648
2594
|
private isInSourceTestCode;
|
|
@@ -2652,6 +2598,11 @@ declare class TestProject {
|
|
|
2652
2598
|
* If the resources are needed again, create a new project.
|
|
2653
2599
|
*/
|
|
2654
2600
|
close(): Promise<void>;
|
|
2601
|
+
/**
|
|
2602
|
+
* Import a file using Vite module runner.
|
|
2603
|
+
* @param moduleId The ID of the module in Vite module graph
|
|
2604
|
+
*/
|
|
2605
|
+
import<T>(moduleId: string): Promise<T>;
|
|
2655
2606
|
/** @deprecated use `name` instead */
|
|
2656
2607
|
getName(): string;
|
|
2657
2608
|
/** @deprecated internal */
|
|
@@ -2691,7 +2642,7 @@ type WorkspaceSpec = TestSpecification & [
|
|
|
2691
2642
|
pool: Pool;
|
|
2692
2643
|
}
|
|
2693
2644
|
];
|
|
2694
|
-
type RunWithFiles = (files:
|
|
2645
|
+
type RunWithFiles = (files: TestSpecification[], invalidates?: string[]) => Awaitable$1<void>;
|
|
2695
2646
|
interface ProcessPool {
|
|
2696
2647
|
name: string;
|
|
2697
2648
|
runTests: RunWithFiles;
|
|
@@ -2700,6 +2651,11 @@ interface ProcessPool {
|
|
|
2700
2651
|
}
|
|
2701
2652
|
declare function getFilePoolName(project: TestProject, file: string): Pool;
|
|
2702
2653
|
|
|
2654
|
+
interface TestRunResult {
|
|
2655
|
+
testModules: TestModule[];
|
|
2656
|
+
unhandledErrors: unknown[];
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2703
2659
|
interface SuiteResultCache {
|
|
2704
2660
|
failed: boolean;
|
|
2705
2661
|
duration: number;
|
|
@@ -2724,7 +2680,7 @@ type FileStatsCache = Pick<Stats, 'size'>;
|
|
|
2724
2680
|
declare class FilesStatsCache {
|
|
2725
2681
|
cache: Map<string, FileStatsCache>;
|
|
2726
2682
|
getStats(key: string): FileStatsCache | undefined;
|
|
2727
|
-
populateStats(root: string, specs:
|
|
2683
|
+
populateStats(root: string, specs: TestSpecification[]): Promise<void>;
|
|
2728
2684
|
updateStats(fsPath: string, key: string): Promise<void>;
|
|
2729
2685
|
removeStats(fsPath: string): void;
|
|
2730
2686
|
}
|
|
@@ -2754,7 +2710,7 @@ declare class StateManager {
|
|
|
2754
2710
|
taskFileMap: WeakMap<Task, File>;
|
|
2755
2711
|
errorsSet: Set<unknown>;
|
|
2756
2712
|
processTimeoutCauses: Set<string>;
|
|
2757
|
-
reportedTasksMap: WeakMap<Task,
|
|
2713
|
+
reportedTasksMap: WeakMap<Task, TestModule | TestCase | TestSuite>;
|
|
2758
2714
|
catchError(err: unknown, type: string): void;
|
|
2759
2715
|
clearErrors(): void;
|
|
2760
2716
|
getUnhandledErrors(): unknown[];
|
|
@@ -2772,7 +2728,7 @@ declare class StateManager {
|
|
|
2772
2728
|
collectFiles(project: TestProject, files?: File[]): void;
|
|
2773
2729
|
clearFiles(project: TestProject, paths?: string[]): void;
|
|
2774
2730
|
updateId(task: Task, project: TestProject): void;
|
|
2775
|
-
getReportedEntity(task: Task):
|
|
2731
|
+
getReportedEntity(task: Task): TestModule | TestCase | TestSuite | undefined;
|
|
2776
2732
|
updateTasks(packs: TaskResultPack[]): void;
|
|
2777
2733
|
updateUserLog(log: UserConsoleLog): void;
|
|
2778
2734
|
getCountOfFailedTests(): number;
|
|
@@ -2787,120 +2743,266 @@ interface VitestOptions {
|
|
|
2787
2743
|
}
|
|
2788
2744
|
declare class Vitest {
|
|
2789
2745
|
readonly mode: VitestRunMode;
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2746
|
+
/**
|
|
2747
|
+
* Current Vitest version.
|
|
2748
|
+
* @example '2.0.0'
|
|
2749
|
+
*/
|
|
2750
|
+
readonly version: string;
|
|
2751
|
+
static readonly version: string;
|
|
2752
|
+
/**
|
|
2753
|
+
* The logger instance used to log messages. It's recommended to use this logger instead of `console`.
|
|
2754
|
+
* It's possible to override stdout and stderr streams when initiating Vitest.
|
|
2755
|
+
* @example
|
|
2756
|
+
* new Vitest('test', {
|
|
2757
|
+
* stdout: new Writable(),
|
|
2758
|
+
* })
|
|
2759
|
+
*/
|
|
2760
|
+
readonly logger: Logger;
|
|
2761
|
+
/**
|
|
2762
|
+
* The package installer instance used to install Vitest packages.
|
|
2763
|
+
* @example
|
|
2764
|
+
* await vitest.packageInstaller.ensureInstalled('@vitest/browser', process.cwd())
|
|
2765
|
+
*/
|
|
2766
|
+
readonly packageInstaller: VitestPackageInstaller;
|
|
2767
|
+
/**
|
|
2768
|
+
* A path to the built Vitest directory. This is usually a folder in `node_modules`.
|
|
2769
|
+
*/
|
|
2770
|
+
readonly distPath: string;
|
|
2771
|
+
/**
|
|
2772
|
+
* A list of projects that are currently running.
|
|
2773
|
+
* If projects were filtered with `--project` flag, they won't appear here.
|
|
2774
|
+
*/
|
|
2815
2775
|
projects: TestProject[];
|
|
2816
|
-
|
|
2817
|
-
private
|
|
2776
|
+
private isFirstRun;
|
|
2777
|
+
private restartsCount;
|
|
2778
|
+
private readonly specifications;
|
|
2779
|
+
private readonly watcher;
|
|
2780
|
+
private pool;
|
|
2781
|
+
private _config?;
|
|
2782
|
+
private _vite?;
|
|
2783
|
+
private _state?;
|
|
2784
|
+
private _cache?;
|
|
2785
|
+
private _snapshot?;
|
|
2818
2786
|
private _workspaceConfigPath?;
|
|
2819
|
-
/** @deprecated use `_cachedSpecs` */
|
|
2820
|
-
projectTestFiles: Map<string, TestSpecification[]>;
|
|
2821
2787
|
constructor(mode: VitestRunMode, options?: VitestOptions);
|
|
2822
2788
|
private _onRestartListeners;
|
|
2823
2789
|
private _onClose;
|
|
2824
2790
|
private _onSetServer;
|
|
2825
2791
|
private _onCancelListeners;
|
|
2826
2792
|
private _onUserTestsRerun;
|
|
2793
|
+
private _onFilterWatchedSpecification;
|
|
2794
|
+
/** @deprecated will be removed in 4.0, use `onFilterWatchedSpecification` instead */
|
|
2795
|
+
get invalidates(): Set<string>;
|
|
2796
|
+
/** @deprecated will be removed in 4.0, use `onFilterWatchedSpecification` instead */
|
|
2797
|
+
get changedTests(): Set<string>;
|
|
2798
|
+
/**
|
|
2799
|
+
* The global config.
|
|
2800
|
+
*/
|
|
2801
|
+
get config(): ResolvedConfig;
|
|
2802
|
+
/** @deprecated use `vitest.vite` instead */
|
|
2803
|
+
get server(): ViteDevServer;
|
|
2804
|
+
/**
|
|
2805
|
+
* Global Vite's dev server instance.
|
|
2806
|
+
*/
|
|
2807
|
+
get vite(): ViteDevServer;
|
|
2808
|
+
/**
|
|
2809
|
+
* The global test state manager.
|
|
2810
|
+
* @experimental The State API is experimental and not subject to semver.
|
|
2811
|
+
*/
|
|
2812
|
+
get state(): StateManager;
|
|
2813
|
+
/**
|
|
2814
|
+
* The global snapshot manager. You can access the current state on `snapshot.summary`.
|
|
2815
|
+
*/
|
|
2816
|
+
get snapshot(): SnapshotManager;
|
|
2817
|
+
/**
|
|
2818
|
+
* Test results and test file stats cache. Primarily used by the sequencer to sort tests.
|
|
2819
|
+
*/
|
|
2820
|
+
get cache(): VitestCache;
|
|
2821
|
+
/** @deprecated internal */
|
|
2827
2822
|
setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
|
|
2828
|
-
|
|
2829
|
-
|
|
2823
|
+
/**
|
|
2824
|
+
* Provide a value to the test context. This value will be available to all tests with `inject`.
|
|
2825
|
+
*/
|
|
2826
|
+
provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
|
|
2827
|
+
/**
|
|
2828
|
+
* Get global provided context.
|
|
2829
|
+
*/
|
|
2830
|
+
getProvidedContext(): ProvidedContext;
|
|
2831
|
+
/** @deprecated use `getRootProject` instead */
|
|
2832
|
+
getCoreWorkspaceProject(): TestProject;
|
|
2833
|
+
/**
|
|
2834
|
+
* Return project that has the root (or "global") config.
|
|
2835
|
+
*/
|
|
2836
|
+
getRootProject(): TestProject;
|
|
2830
2837
|
/**
|
|
2831
2838
|
* @deprecated use Reported Task API instead
|
|
2832
2839
|
*/
|
|
2833
2840
|
getProjectByTaskId(taskId: string): TestProject;
|
|
2834
|
-
getProjectByName(name
|
|
2841
|
+
getProjectByName(name: string): TestProject;
|
|
2842
|
+
/**
|
|
2843
|
+
* Import a file using Vite module runner. The file will be transformed by Vite and executed in a separate context.
|
|
2844
|
+
* @param moduleId The ID of the module in Vite module graph
|
|
2845
|
+
*/
|
|
2846
|
+
import<T>(moduleId: string): Promise<T>;
|
|
2835
2847
|
private resolveWorkspaceConfigPath;
|
|
2836
2848
|
private resolveWorkspace;
|
|
2849
|
+
/**
|
|
2850
|
+
* Glob test files in every project and create a TestSpecification for each file and pool.
|
|
2851
|
+
* @param filters String filters to match the test files.
|
|
2852
|
+
*/
|
|
2853
|
+
globTestSpecifications(filters?: string[]): Promise<TestSpecification[]>;
|
|
2837
2854
|
private initCoverageProvider;
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2855
|
+
/**
|
|
2856
|
+
* Merge reports from multiple runs located in the specified directory (value from `--merge-reports` if not specified).
|
|
2857
|
+
*/
|
|
2858
|
+
mergeReports(directory?: string): Promise<TestRunResult>;
|
|
2859
|
+
collect(filters?: string[]): Promise<TestRunResult>;
|
|
2860
|
+
/** @deprecated use `getRelevantTestSpecifications` instead */
|
|
2861
|
+
listFiles(filters?: string[]): Promise<TestSpecification[]>;
|
|
2862
|
+
/**
|
|
2863
|
+
* Returns the list of test files that match the config and filters.
|
|
2864
|
+
* @param filters String filters to match the test files
|
|
2865
|
+
*/
|
|
2866
|
+
getRelevantTestSpecifications(filters?: string[]): Promise<TestSpecification[]>;
|
|
2867
|
+
/**
|
|
2868
|
+
* Initialize reporters, the coverage provider, and run tests.
|
|
2869
|
+
* This method can throw an error:
|
|
2870
|
+
* - `FilesNotFoundError` if no tests are found
|
|
2871
|
+
* - `GitNotFoundError` if `--related` flag is used, but git repository is not initialized
|
|
2872
|
+
* - `Error` from the user reporters
|
|
2873
|
+
* @param filters String filters to match the test files
|
|
2874
|
+
*/
|
|
2875
|
+
start(filters?: string[]): Promise<TestRunResult>;
|
|
2876
|
+
/**
|
|
2877
|
+
* Initialize reporters and the coverage provider. This method doesn't run any tests.
|
|
2878
|
+
* If the `--watch` flag is provided, Vitest will still run changed tests even if this method was not called.
|
|
2879
|
+
*/
|
|
2845
2880
|
init(): Promise<void>;
|
|
2846
|
-
private getTestDependencies;
|
|
2847
|
-
filterTestsBySource(specs: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
|
|
2848
2881
|
/**
|
|
2849
|
-
* @deprecated remove when vscode extension supports "
|
|
2882
|
+
* @deprecated remove when vscode extension supports "getModuleSpecifications"
|
|
2850
2883
|
*/
|
|
2851
2884
|
getProjectsByTestFile(file: string): WorkspaceSpec[];
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2885
|
+
/** @deprecated */
|
|
2886
|
+
getFileWorkspaceSpecs(file: string): WorkspaceSpec[];
|
|
2887
|
+
/**
|
|
2888
|
+
* Get test specifications assosiated with the given module. If module is not a test file, an empty array is returned.
|
|
2889
|
+
*
|
|
2890
|
+
* **Note:** this method relies on a cache generated by `globTestSpecifications`. If the file was not processed yet, use `project.matchesGlobPattern` instead.
|
|
2891
|
+
* @param moduleId The module ID to get test specifications for.
|
|
2892
|
+
*/
|
|
2893
|
+
getModuleSpecifications(moduleId: string): TestSpecification[];
|
|
2894
|
+
/**
|
|
2895
|
+
* Vitest automatically caches test specifications for each file. This method clears the cache for the given file or the whole cache alltogether.
|
|
2896
|
+
*/
|
|
2897
|
+
clearSpecificationsCache(moduleId?: string): void;
|
|
2898
|
+
/**
|
|
2899
|
+
* Run tests for the given test specifications. This does not trigger `onWatcher*` events.
|
|
2900
|
+
* @param specifications A list of specifications to run.
|
|
2901
|
+
* @param allTestsRun Indicates whether all tests were run. This only matters for coverage.
|
|
2902
|
+
*/
|
|
2903
|
+
runTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
|
|
2904
|
+
/**
|
|
2905
|
+
* Rerun files and trigger `onWatcherRerun`, `onWatcherStart` and `onTestsRerun` events.
|
|
2906
|
+
* @param specifications A list of specifications to run.
|
|
2907
|
+
* @param allTestsRun Indicates whether all tests were run. This only matters for coverage.
|
|
2908
|
+
*/
|
|
2909
|
+
rerunTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
|
|
2910
|
+
private runFiles;
|
|
2911
|
+
/**
|
|
2912
|
+
* Collect tests in specified modules. Vitest will run the files to collect tests.
|
|
2913
|
+
* @param specifications A list of specifications to run.
|
|
2914
|
+
*/
|
|
2915
|
+
collectTests(specifications: TestSpecification[]): Promise<TestRunResult>;
|
|
2916
|
+
/**
|
|
2917
|
+
* Gracefully cancel the current test run. Vitest will wait until all running tests are finished before cancelling.
|
|
2918
|
+
*/
|
|
2856
2919
|
cancelCurrentRun(reason: CancelReason): Promise<void>;
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2920
|
+
private initializeGlobalSetup;
|
|
2921
|
+
/**
|
|
2922
|
+
* Update snapshots in specified files. If no files are provided, it will update files with failed tests and obsolete snapshots.
|
|
2923
|
+
* @param files The list of files on the file system
|
|
2924
|
+
*/
|
|
2925
|
+
updateSnapshot(files?: string[]): Promise<TestRunResult>;
|
|
2926
|
+
/**
|
|
2927
|
+
* Enable the mode that allows updating snapshots when running tests.
|
|
2928
|
+
* This method doesn't run any tests.
|
|
2929
|
+
*
|
|
2930
|
+
* Every test that runs after this method is called will update snapshots.
|
|
2931
|
+
* To disable the mode, call `resetSnapshotUpdate`.
|
|
2932
|
+
*/
|
|
2933
|
+
enableSnapshotUpdate(): void;
|
|
2934
|
+
/**
|
|
2935
|
+
* Disable the mode that allows updating snapshots when running tests.
|
|
2936
|
+
*/
|
|
2937
|
+
resetSnapshotUpdate(): void;
|
|
2938
|
+
/**
|
|
2939
|
+
* Set the global test name pattern to a regexp.
|
|
2940
|
+
* This method doesn't run any tests.
|
|
2941
|
+
*/
|
|
2942
|
+
setGlobalTestNamePattern(pattern: string | RegExp): void;
|
|
2943
|
+
/**
|
|
2944
|
+
* Resets the global test name pattern. This method doesn't run any tests.
|
|
2945
|
+
*/
|
|
2946
|
+
resetGlobalTestNamePattern(): void;
|
|
2866
2947
|
private _rerunTimer;
|
|
2867
2948
|
private scheduleRerun;
|
|
2868
|
-
getModuleProjects(filepath: string): TestProject[];
|
|
2869
2949
|
/**
|
|
2870
|
-
*
|
|
2950
|
+
* Invalidate a file in all projects.
|
|
2871
2951
|
*/
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
onAdd: (id: string) => Promise<void>;
|
|
2877
|
-
checkUnhandledErrors(errors: unknown[]): void;
|
|
2878
|
-
private unregisterWatcher;
|
|
2879
|
-
private registerWatcher;
|
|
2952
|
+
invalidateFile(filepath: string): void;
|
|
2953
|
+
/** @deprecated use `invalidateFile` */
|
|
2954
|
+
updateLastChanged(filepath: string): void;
|
|
2955
|
+
private reportCoverage;
|
|
2880
2956
|
/**
|
|
2881
|
-
*
|
|
2957
|
+
* Closes all projects and their associated resources.
|
|
2958
|
+
* This can only be called once; the closing promise is cached until the server restarts.
|
|
2882
2959
|
*/
|
|
2883
|
-
private handleFileChanged;
|
|
2884
|
-
private reportCoverage;
|
|
2885
2960
|
close(): Promise<void>;
|
|
2886
2961
|
/**
|
|
2887
|
-
*
|
|
2962
|
+
* Closes all projects and exit the process
|
|
2963
|
+
* @param force If true, the process will exit immediately after closing the projects.
|
|
2888
2964
|
*/
|
|
2889
2965
|
exit(force?: boolean): Promise<void>;
|
|
2890
|
-
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
|
|
2891
|
-
getTestFilepaths(): Promise<string[]>;
|
|
2892
|
-
globTestSpecs(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
2893
2966
|
/**
|
|
2894
|
-
* @deprecated use `
|
|
2967
|
+
* @deprecated use `globTestSpecifications` instead
|
|
2968
|
+
*/
|
|
2969
|
+
globTestSpecs(filters?: string[]): Promise<TestSpecification[]>;
|
|
2970
|
+
/**
|
|
2971
|
+
* @deprecated use `globTestSpecifications` instead
|
|
2972
|
+
*/
|
|
2973
|
+
globTestFiles(filters?: string[]): Promise<TestSpecification[]>;
|
|
2974
|
+
/** @deprecated filter by `this.projects` yourself */
|
|
2975
|
+
getModuleProjects(filepath: string): TestProject[];
|
|
2976
|
+
/**
|
|
2977
|
+
* Should the server be kept running after the tests are done.
|
|
2895
2978
|
*/
|
|
2896
|
-
globTestFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
2897
|
-
private ensureSpecCached;
|
|
2898
2979
|
shouldKeepServer(): boolean;
|
|
2980
|
+
/**
|
|
2981
|
+
* Register a handler that will be called when the server is restarted due to a config change.
|
|
2982
|
+
*/
|
|
2899
2983
|
onServerRestart(fn: OnServerRestartHandler): void;
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2984
|
+
/**
|
|
2985
|
+
* Register a handler that will be called when the test run is cancelled with `vitest.cancelCurrentRun`.
|
|
2986
|
+
*/
|
|
2987
|
+
onCancel(fn: (reason: CancelReason) => Awaitable$1<void>): void;
|
|
2988
|
+
/**
|
|
2989
|
+
* Register a handler that will be called when the server is closed.
|
|
2990
|
+
*/
|
|
2991
|
+
onClose(fn: () => Awaitable$1<void>): void;
|
|
2992
|
+
/**
|
|
2993
|
+
* Register a handler that will be called when the tests are rerunning.
|
|
2994
|
+
*/
|
|
2903
2995
|
onTestsRerun(fn: OnTestsRerunHandler): void;
|
|
2996
|
+
/**
|
|
2997
|
+
* Register a handler that will be called when a file is changed.
|
|
2998
|
+
* This callback should return `true` of `false` indicating whether the test file needs to be rerun.
|
|
2999
|
+
* @example
|
|
3000
|
+
* const testsToRun = [resolve('./test.spec.ts')]
|
|
3001
|
+
* vitest.onFilterWatchedSpecification(specification => testsToRun.includes(specification.moduleId))
|
|
3002
|
+
*/
|
|
3003
|
+
onFilterWatchedSpecification(fn: (specification: TestSpecification) => boolean): void;
|
|
2904
3004
|
}
|
|
3005
|
+
type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
|
|
3006
|
+
type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
|
|
2905
3007
|
|
|
2906
|
-
export { type
|
|
3008
|
+
export { type JUnitOptions as $, type ApiConfig as A, type BaseCoverageOptions as B, CoverageMap as C, type DepsOptimizationOptions as D, TestProject as E, type TestSequencer as F, TestSpecification as G, TestModule as H, type InlineConfig as I, type OnTestsRerunHandler as J, VitestPackageInstaller as K, Logger as L, type ModuleDiagnostic as M, type ProcessPool as N, type OnServerRestartHandler as O, type Pool as P, type WorkspaceSpec 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, getFilePoolName as X, type SerializedTestProject as Y, type HTMLOptions as Z, type JsonOptions$1 as _, type ReportContext as a, type TaskOptions as a0, TestCase as a1, TestCollection as a2, type TestDiagnostic as a3, type TestResult as a4, type TestResultFailed as a5, type TestResultPassed as a6, type TestResultSkipped as a7, TestSuite as a8, type TestSequencerConstructor as a9, TapFlatReporter as aA, TapReporter as aB, VerboseReporter as aC, BaseReporter as aD, TestFile as aE, type FileDiagnostic as aF, ReportersMap as aG, type BuiltinReporters as aH, type BuiltinReporterOptions as aI, type JsonAssertionResult as aJ, type JsonTestResult as aK, type JsonTestResults as aL, BenchmarkReportsMap as aM, type BenchmarkBuiltinReporters as aN, type BrowserBuiltinProvider as aa, type BrowserCommand as ab, type BrowserCommandContext as ac, type BrowserInstanceOption as ad, type BrowserOrchestrator as ae, type BrowserProvider as af, type BrowserProviderInitializationOptions as ag, type BrowserProviderModule as ah, type BrowserProviderOptions as ai, type BrowserServerState as aj, type BrowserServerStateSession as ak, type CDPSession as al, type ParentProjectBrowser as am, type ProjectBrowser as an, type ResolvedBrowserOptions as ao, type ResolvedProjectConfig as ap, type ResolveSnapshotPathHandler as aq, type ResolveSnapshotPathHandlerContext as ar, type TestRunResult as as, BasicReporter as at, DefaultReporter as au, DotReporter as av, GithubActionsReporter as aw, HangingProcessReporter as ax, JsonReporter as ay, JUnitReporter as az, type CoverageProvider as b, type CoverageProviderModule as c, type CoverageV8Options as d, type UserProjectConfigFn as e, type UserProjectConfigExport as f, type CoverageReporter as g, type CoverageProviderName as h, type CoverageOptions as i, type CoverageIstanbulOptions as j, type CustomProviderOptions as k, type Reporter as l, type BrowserScript as m, type BrowserConfigOptions as n, type BuiltinEnvironment as o, type VitestEnvironment as p, type PoolOptions as q, type CSSModuleScopeStrategy as r, type VitestRunMode as s, type TransformModePatterns as t, type TypecheckConfig as u, type UserConfig as v, type ResolvedConfig as w, type ProjectConfig as x, type BenchmarkUserOptions as y, type VitestOptions as z };
|