vitest 2.2.0-beta.2 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +75 -0
- package/dist/browser.d.ts +13 -10
- package/dist/browser.js +2 -2
- package/dist/chunks/{RandomSequencer.BPedXEug.js → RandomSequencer.gisBJ77r.js} +11 -4
- package/dist/chunks/{base.BS0HhLXd.js → base.CUgXReRN.js} +8 -3
- package/dist/chunks/{cac.Cs06pOqp.js → cac.Xzv7eNWw.js} +22 -17
- package/dist/chunks/{cli-api.CB-jIbYQ.js → cli-api.CETCDGgZ.js} +985 -498
- package/dist/chunks/{config.CPguQ7J1.d.ts → config.BTPBhmK5.d.ts} +1 -1
- package/dist/chunks/{coverage.BoMDb1ip.js → coverage.BWeNbfBa.js} +4 -4
- package/dist/chunks/{creator.IIqd8RWT.js → creator.DcAcUhMD.js} +1 -4
- package/dist/chunks/{environment.CT0jpO-1.d.ts → environment.d8YfPkTm.d.ts} +1 -3
- package/dist/chunks/{globals.BCGEw6ON.js → globals.BFncSRNA.js} +2 -2
- package/dist/chunks/{index.bzFpKeaq.js → index.9ZEBV_TJ.js} +992 -577
- package/dist/chunks/{index.DD5eTY2y.js → index.CkWmZCXU.js} +1 -1
- package/dist/chunks/{index.CqYx2Nsr.js → index.DQboAxJm.js} +23 -14
- package/dist/chunks/{index.BjjsHdBb.js → index.DoV7W5gc.js} +2 -2
- package/dist/chunks/{inspector.70d6emsh.js → inspector.DKLceBVD.js} +1 -1
- package/dist/chunks/{reporters.F9D2idOT.d.ts → reporters.DTtxC3KQ.d.ts} +588 -524
- package/dist/chunks/{resolveConfig.CLnvCvEs.js → resolveConfig.BA-_OKEx.js} +5599 -5570
- package/dist/chunks/{runBaseTests.B7hcVT-s.js → runBaseTests.D0dWpzZV.js} +13 -12
- package/dist/chunks/{setup-common.BfGt8K-K.js → setup-common.Cp_bu5q3.js} +1 -1
- package/dist/chunks/types.BOjykUpq.d.ts +27 -0
- package/dist/chunks/{utils.DJONn5B5.js → utils.CMUTX-p8.js} +5 -2
- package/dist/chunks/{vi.BlPttogV.js → vi.S4Fq8wSo.js} +20 -14
- package/dist/chunks/{vite.DonA4fvH.d.ts → vite.CXaetSK3.d.ts} +1 -1
- package/dist/chunks/{vm.Zr4qWzDJ.js → vm.DGhTouO3.js} +10 -1
- package/dist/chunks/{worker.Qz1UB4Fv.d.ts → worker.ClntunZp.d.ts} +1 -1
- package/dist/chunks/{worker.9VY11NZs.d.ts → worker.o1PBoDdo.d.ts} +4 -4
- package/dist/cli.js +1 -1
- package/dist/config.cjs +1 -10
- package/dist/config.d.ts +7 -10
- package/dist/config.js +1 -10
- package/dist/coverage.d.ts +5 -7
- package/dist/coverage.js +4 -4
- package/dist/environments.d.ts +2 -2
- package/dist/execute.d.ts +4 -4
- package/dist/index.d.ts +27 -22
- package/dist/index.js +2 -2
- package/dist/node.d.ts +25 -33
- package/dist/node.js +66 -32
- package/dist/reporters.d.ts +5 -7
- package/dist/reporters.js +5 -4
- package/dist/runners.d.ts +3 -4
- package/dist/runners.js +9 -14
- package/dist/suite.d.ts +1 -1
- package/dist/worker.js +1 -1
- package/dist/workers/forks.js +1 -1
- package/dist/workers/runVmTests.js +9 -9
- 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 +4 -4
- package/dist/workers.js +3 -3
- package/package.json +23 -24
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import * as _vitest_runner from '@vitest/runner';
|
|
2
|
-
import { File, TaskResultPack, Task,
|
|
3
|
-
import { b as Awaitable, U as UserConsoleLog, A as AfterSuiteRunMeta, c as Arrayable$1, f as EnvironmentOptions, P as ProvidedContext
|
|
2
|
+
import { File, TaskResultPack, Task, 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 } 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
|
-
import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.
|
|
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,6 +23,7 @@ type SerializedTestSpecification = [
|
|
|
25
23
|
file: string,
|
|
26
24
|
options: {
|
|
27
25
|
pool: string;
|
|
26
|
+
testLines?: number[] | undefined;
|
|
28
27
|
}
|
|
29
28
|
];
|
|
30
29
|
|
|
@@ -109,11 +108,6 @@ interface HTMLOptions {
|
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
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
111
|
/**
|
|
118
112
|
* The project assosiacted with the test or suite.
|
|
119
113
|
*/
|
|
@@ -121,7 +115,7 @@ declare class ReportedTaskImplementation {
|
|
|
121
115
|
/**
|
|
122
116
|
* Unique identifier.
|
|
123
117
|
* 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
|
|
118
|
+
* The ID is based on the project name, module url and test order.
|
|
125
119
|
*/
|
|
126
120
|
readonly id: string;
|
|
127
121
|
/**
|
|
@@ -131,15 +125,14 @@ declare class ReportedTaskImplementation {
|
|
|
131
125
|
line: number;
|
|
132
126
|
column: number;
|
|
133
127
|
} | undefined;
|
|
134
|
-
protected constructor(task: Task, project: TestProject);
|
|
135
128
|
/**
|
|
136
|
-
*
|
|
129
|
+
* Checks if the test did not fail the suite.
|
|
130
|
+
* If the test is not finished yet or was skipped, it will return `true`.
|
|
137
131
|
*/
|
|
138
|
-
|
|
132
|
+
ok(): boolean;
|
|
139
133
|
}
|
|
140
134
|
declare class TestCase extends ReportedTaskImplementation {
|
|
141
135
|
#private;
|
|
142
|
-
readonly task: Test | Custom;
|
|
143
136
|
readonly type = "test";
|
|
144
137
|
/**
|
|
145
138
|
* Direct reference to the test module where the test or suite is defined.
|
|
@@ -157,20 +150,18 @@ declare class TestCase extends ReportedTaskImplementation {
|
|
|
157
150
|
* Parent suite. If the test was called directly inside the module, the parent will be the module itself.
|
|
158
151
|
*/
|
|
159
152
|
readonly parent: TestSuite | TestModule;
|
|
160
|
-
protected constructor(task: Test | Custom, project: TestProject);
|
|
161
153
|
/**
|
|
162
154
|
* Full name of the test including all parent suites separated with `>`.
|
|
163
155
|
*/
|
|
164
156
|
get fullName(): string;
|
|
165
157
|
/**
|
|
166
|
-
* Test results. Will be `undefined` if test is not finished yet or was just collected.
|
|
158
|
+
* Test results. Will be `undefined` if test is skipped, not finished yet or was just collected.
|
|
167
159
|
*/
|
|
168
160
|
result(): TestResult | undefined;
|
|
169
161
|
/**
|
|
170
|
-
* Checks if the test
|
|
171
|
-
* If the test is not finished yet or was skipped, it will return `true`.
|
|
162
|
+
* Checks if the test was skipped during collection or dynamically with `ctx.skip()`.
|
|
172
163
|
*/
|
|
173
|
-
|
|
164
|
+
skipped(): boolean;
|
|
174
165
|
/**
|
|
175
166
|
* Custom metadata that was attached to the test during its execution.
|
|
176
167
|
*/
|
|
@@ -185,7 +176,7 @@ declare class TestCollection {
|
|
|
185
176
|
#private;
|
|
186
177
|
constructor(task: Suite | File, project: TestProject);
|
|
187
178
|
/**
|
|
188
|
-
* Returns the test or suite at a specific index
|
|
179
|
+
* Returns the test or suite at a specific index.
|
|
189
180
|
*/
|
|
190
181
|
at(index: number): TestCase | TestSuite | undefined;
|
|
191
182
|
/**
|
|
@@ -216,16 +207,21 @@ declare class TestCollection {
|
|
|
216
207
|
}
|
|
217
208
|
|
|
218
209
|
declare abstract class SuiteImplementation extends ReportedTaskImplementation {
|
|
219
|
-
readonly task: Suite | File;
|
|
220
210
|
/**
|
|
221
211
|
* Collection of suites and tests that are part of this suite.
|
|
222
212
|
*/
|
|
223
213
|
readonly children: TestCollection;
|
|
224
|
-
|
|
214
|
+
/**
|
|
215
|
+
* Checks if the suite was skipped during collection.
|
|
216
|
+
*/
|
|
217
|
+
skipped(): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Errors that happened outside of the test run during collection, like syntax errors.
|
|
220
|
+
*/
|
|
221
|
+
errors(): TestError[];
|
|
225
222
|
}
|
|
226
223
|
declare class TestSuite extends SuiteImplementation {
|
|
227
224
|
#private;
|
|
228
|
-
readonly task: Suite;
|
|
229
225
|
readonly type = "suite";
|
|
230
226
|
/**
|
|
231
227
|
* Name of the test or the suite.
|
|
@@ -243,14 +239,17 @@ declare class TestSuite extends SuiteImplementation {
|
|
|
243
239
|
* Options that suite was initiated with.
|
|
244
240
|
*/
|
|
245
241
|
readonly options: TaskOptions;
|
|
246
|
-
|
|
242
|
+
/**
|
|
243
|
+
* Checks if the suite has any failed tests.
|
|
244
|
+
* This will also return `false` if suite failed during collection.
|
|
245
|
+
*/
|
|
246
|
+
ok: () => boolean;
|
|
247
247
|
/**
|
|
248
248
|
* Full name of the suite including all parent suites separated with `>`.
|
|
249
249
|
*/
|
|
250
250
|
get fullName(): string;
|
|
251
251
|
}
|
|
252
252
|
declare class TestModule extends SuiteImplementation {
|
|
253
|
-
readonly task: File;
|
|
254
253
|
readonly location: undefined;
|
|
255
254
|
readonly type = "module";
|
|
256
255
|
/**
|
|
@@ -259,7 +258,15 @@ declare class TestModule extends SuiteImplementation {
|
|
|
259
258
|
* This value corresponds to Vite's `ModuleGraph` id.
|
|
260
259
|
*/
|
|
261
260
|
readonly moduleId: string;
|
|
262
|
-
|
|
261
|
+
/**
|
|
262
|
+
* Checks if the module has any failed tests.
|
|
263
|
+
* This will also return `false` if module failed during collection.
|
|
264
|
+
*/
|
|
265
|
+
ok: () => boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Checks if the module was skipped and didn't run.
|
|
268
|
+
*/
|
|
269
|
+
skipped: () => boolean;
|
|
263
270
|
/**
|
|
264
271
|
* Useful information about the module like duration, memory usage, etc.
|
|
265
272
|
* If the module was not executed yet, all diagnostic values will return `0`.
|
|
@@ -299,8 +306,8 @@ interface TestResultFailed {
|
|
|
299
306
|
}
|
|
300
307
|
interface TestResultSkipped {
|
|
301
308
|
/**
|
|
302
|
-
* The test was skipped with `only
|
|
303
|
-
* You can see which one was used in the `mode` option.
|
|
309
|
+
* The test was skipped with `only` (on another test), `skip` or `todo` flag.
|
|
310
|
+
* You can see which one was used in the `options.mode` option.
|
|
304
311
|
*/
|
|
305
312
|
state: 'skipped';
|
|
306
313
|
/**
|
|
@@ -308,7 +315,7 @@ interface TestResultSkipped {
|
|
|
308
315
|
*/
|
|
309
316
|
errors: undefined;
|
|
310
317
|
/**
|
|
311
|
-
* A custom note.
|
|
318
|
+
* A custom note passed down to `ctx.skip(note)`.
|
|
312
319
|
*/
|
|
313
320
|
note: string | undefined;
|
|
314
321
|
}
|
|
@@ -374,248 +381,12 @@ declare class BasicReporter extends BaseReporter {
|
|
|
374
381
|
reportSummary(files: File[], errors: unknown[]): void;
|
|
375
382
|
}
|
|
376
383
|
|
|
377
|
-
interface ParsedFile extends File {
|
|
378
|
-
start: number;
|
|
379
|
-
end: number;
|
|
380
|
-
}
|
|
381
|
-
interface ParsedTest extends Test {
|
|
382
|
-
start: number;
|
|
383
|
-
end: number;
|
|
384
|
-
}
|
|
385
|
-
interface ParsedSuite extends Suite {
|
|
386
|
-
start: number;
|
|
387
|
-
end: number;
|
|
388
|
-
}
|
|
389
|
-
interface LocalCallDefinition {
|
|
390
|
-
start: number;
|
|
391
|
-
end: number;
|
|
392
|
-
name: string;
|
|
393
|
-
type: 'suite' | 'test';
|
|
394
|
-
mode: 'run' | 'skip' | 'only' | 'todo';
|
|
395
|
-
task: ParsedSuite | ParsedFile | ParsedTest;
|
|
396
|
-
}
|
|
397
|
-
interface FileInformation {
|
|
398
|
-
file: File;
|
|
399
|
-
filepath: string;
|
|
400
|
-
parsed: string;
|
|
401
|
-
map: RawSourceMap | null;
|
|
402
|
-
definitions: LocalCallDefinition[];
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
type RawErrsMap = Map<string, TscErrorInfo[]>;
|
|
406
|
-
interface TscErrorInfo {
|
|
407
|
-
filePath: string;
|
|
408
|
-
errCode: number;
|
|
409
|
-
errMsg: string;
|
|
410
|
-
line: number;
|
|
411
|
-
column: number;
|
|
412
|
-
}
|
|
413
|
-
interface CollectLineNumbers {
|
|
414
|
-
target: number;
|
|
415
|
-
next: number;
|
|
416
|
-
prev?: number;
|
|
417
|
-
}
|
|
418
|
-
type CollectLines = {
|
|
419
|
-
[key in keyof CollectLineNumbers]: string;
|
|
420
|
-
};
|
|
421
|
-
interface RootAndTarget {
|
|
422
|
-
root: string;
|
|
423
|
-
targetAbsPath: string;
|
|
424
|
-
}
|
|
425
|
-
type Context = RootAndTarget & {
|
|
426
|
-
rawErrsMap: RawErrsMap;
|
|
427
|
-
openedDirs: Set<string>;
|
|
428
|
-
lastActivePath?: string;
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
declare class TypeCheckError extends Error {
|
|
432
|
-
message: string;
|
|
433
|
-
stacks: ParsedStack[];
|
|
434
|
-
name: string;
|
|
435
|
-
constructor(message: string, stacks: ParsedStack[]);
|
|
436
|
-
}
|
|
437
|
-
interface TypecheckResults {
|
|
438
|
-
files: File[];
|
|
439
|
-
sourceErrors: TypeCheckError[];
|
|
440
|
-
time: number;
|
|
441
|
-
}
|
|
442
|
-
type Callback<Args extends Array<any> = []> = (...args: Args) => Awaitable<void>;
|
|
443
|
-
declare class Typechecker {
|
|
444
|
-
protected ctx: TestProject;
|
|
445
|
-
private _onParseStart?;
|
|
446
|
-
private _onParseEnd?;
|
|
447
|
-
private _onWatcherRerun?;
|
|
448
|
-
private _result;
|
|
449
|
-
private _startTime;
|
|
450
|
-
private _output;
|
|
451
|
-
private _tests;
|
|
452
|
-
private tempConfigPath?;
|
|
453
|
-
private allowJs?;
|
|
454
|
-
private process?;
|
|
455
|
-
protected files: string[];
|
|
456
|
-
constructor(ctx: TestProject);
|
|
457
|
-
setFiles(files: string[]): void;
|
|
458
|
-
onParseStart(fn: Callback): void;
|
|
459
|
-
onParseEnd(fn: Callback<[TypecheckResults]>): void;
|
|
460
|
-
onWatcherRerun(fn: Callback): void;
|
|
461
|
-
protected collectFileTests(filepath: string): Promise<FileInformation | null>;
|
|
462
|
-
protected getFiles(): string[];
|
|
463
|
-
collectTests(): Promise<Record<string, FileInformation>>;
|
|
464
|
-
protected markPassed(file: File): void;
|
|
465
|
-
protected prepareResults(output: string): Promise<{
|
|
466
|
-
files: File[];
|
|
467
|
-
sourceErrors: TypeCheckError[];
|
|
468
|
-
time: number;
|
|
469
|
-
}>;
|
|
470
|
-
protected parseTscLikeOutput(output: string): Promise<Map<string, {
|
|
471
|
-
error: TypeCheckError;
|
|
472
|
-
originalError: TscErrorInfo;
|
|
473
|
-
}[]>>;
|
|
474
|
-
clear(): Promise<void>;
|
|
475
|
-
stop(): Promise<void>;
|
|
476
|
-
protected ensurePackageInstalled(ctx: Vitest, checker: string): Promise<void>;
|
|
477
|
-
prepare(): Promise<void>;
|
|
478
|
-
getExitCode(): number | false;
|
|
479
|
-
getOutput(): string;
|
|
480
|
-
start(): Promise<void>;
|
|
481
|
-
getResult(): TypecheckResults;
|
|
482
|
-
getTestFiles(): File[];
|
|
483
|
-
getTestPacks(): TaskResultPack[];
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
interface PrintErrorResult {
|
|
487
|
-
nearest?: ParsedStack;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
interface Options {
|
|
491
|
-
/**
|
|
492
|
-
Show the cursor. This can be useful when a CLI accepts input from a user.
|
|
493
|
-
|
|
494
|
-
@example
|
|
495
|
-
```
|
|
496
|
-
import {createLogUpdate} from 'log-update';
|
|
497
|
-
|
|
498
|
-
// Write output but don't hide the cursor
|
|
499
|
-
const log = createLogUpdate(process.stdout, {
|
|
500
|
-
showCursor: true
|
|
501
|
-
});
|
|
502
|
-
```
|
|
503
|
-
*/
|
|
504
|
-
readonly showCursor?: boolean;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
type LogUpdateMethods = {
|
|
508
|
-
/**
|
|
509
|
-
Clear the logged output.
|
|
510
|
-
*/
|
|
511
|
-
clear(): void;
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
Persist the logged output. Useful if you want to start a new log session below the current one.
|
|
515
|
-
*/
|
|
516
|
-
done(): void;
|
|
517
|
-
};
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
Log to `stdout` by overwriting the previous output in the terminal.
|
|
521
|
-
|
|
522
|
-
@param text - The text to log to `stdout`.
|
|
523
|
-
|
|
524
|
-
@example
|
|
525
|
-
```
|
|
526
|
-
import logUpdate from 'log-update';
|
|
527
|
-
|
|
528
|
-
const frames = ['-', '\\', '|', '/'];
|
|
529
|
-
let index = 0;
|
|
530
|
-
|
|
531
|
-
setInterval(() => {
|
|
532
|
-
const frame = frames[index = ++index % frames.length];
|
|
533
|
-
|
|
534
|
-
logUpdate(
|
|
535
|
-
`
|
|
536
|
-
♥♥
|
|
537
|
-
${frame} unicorns ${frame}
|
|
538
|
-
♥♥
|
|
539
|
-
`
|
|
540
|
-
);
|
|
541
|
-
}, 80);
|
|
542
|
-
```
|
|
543
|
-
*/
|
|
544
|
-
declare const logUpdate: ((...text: string[]) => void) & LogUpdateMethods;
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
Get a `logUpdate` method that logs to the specified stream.
|
|
549
|
-
|
|
550
|
-
@param stream - The stream to log to.
|
|
551
|
-
|
|
552
|
-
@example
|
|
553
|
-
```
|
|
554
|
-
import {createLogUpdate} from 'log-update';
|
|
555
|
-
|
|
556
|
-
// Write output but don't hide the cursor
|
|
557
|
-
const log = createLogUpdate(process.stdout);
|
|
558
|
-
```
|
|
559
|
-
*/
|
|
560
|
-
declare function createLogUpdate(
|
|
561
|
-
stream: NodeJS.WritableStream,
|
|
562
|
-
options?: Options
|
|
563
|
-
): typeof logUpdate;
|
|
564
|
-
|
|
565
|
-
interface ErrorOptions {
|
|
566
|
-
type?: string;
|
|
567
|
-
fullStack?: boolean;
|
|
568
|
-
project?: TestProject;
|
|
569
|
-
verbose?: boolean;
|
|
570
|
-
screenshotPaths?: string[];
|
|
571
|
-
task?: Task;
|
|
572
|
-
showCodeFrame?: boolean;
|
|
573
|
-
}
|
|
574
|
-
declare class Logger {
|
|
575
|
-
ctx: Vitest;
|
|
576
|
-
outputStream: NodeJS.WriteStream | Writable;
|
|
577
|
-
errorStream: NodeJS.WriteStream | Writable;
|
|
578
|
-
logUpdate: ReturnType<typeof createLogUpdate>;
|
|
579
|
-
private _clearScreenPending;
|
|
580
|
-
private _highlights;
|
|
581
|
-
console: Console;
|
|
582
|
-
constructor(ctx: Vitest, outputStream?: NodeJS.WriteStream | Writable, errorStream?: NodeJS.WriteStream | Writable);
|
|
583
|
-
log(...args: any[]): void;
|
|
584
|
-
error(...args: any[]): void;
|
|
585
|
-
warn(...args: any[]): void;
|
|
586
|
-
clearFullScreen(message?: string): void;
|
|
587
|
-
clearScreen(message: string, force?: boolean): void;
|
|
588
|
-
private _clearScreen;
|
|
589
|
-
printError(err: unknown, options?: ErrorOptions): PrintErrorResult | undefined;
|
|
590
|
-
clearHighlightCache(filename?: string): void;
|
|
591
|
-
highlight(filename: string, source: string): string;
|
|
592
|
-
printNoTestFound(filters?: string[]): void;
|
|
593
|
-
printBanner(): void;
|
|
594
|
-
printBrowserBanner(project: TestProject): void;
|
|
595
|
-
printUnhandledErrors(errors: unknown[]): void;
|
|
596
|
-
printSourceTypeErrors(errors: TypeCheckError[]): void;
|
|
597
|
-
private registerUnhandledRejection;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
interface DotRendererOptions {
|
|
601
|
-
logger: Logger;
|
|
602
|
-
}
|
|
603
|
-
declare function createDotRenderer(_tasks: Task[], options: DotRendererOptions): {
|
|
604
|
-
start(): any;
|
|
605
|
-
update(_tasks: Task[]): any;
|
|
606
|
-
stop(): Promise<any>;
|
|
607
|
-
clear(): void;
|
|
608
|
-
};
|
|
609
|
-
|
|
610
384
|
declare class DotReporter extends BaseReporter {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
stopListRender(): Promise<void>;
|
|
617
|
-
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
618
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
385
|
+
private summary?;
|
|
386
|
+
onInit(ctx: Vitest): void;
|
|
387
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
388
|
+
onWatcherRerun(files: string[], trigger?: string): void;
|
|
389
|
+
onFinished(files?: File[], errors?: unknown[]): void;
|
|
619
390
|
}
|
|
620
391
|
|
|
621
392
|
declare class GithubActionsReporter implements Reporter {
|
|
@@ -854,6 +625,127 @@ declare class VerboseReporter extends DefaultReporter {
|
|
|
854
625
|
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
855
626
|
}
|
|
856
627
|
|
|
628
|
+
declare class TypeCheckError extends Error {
|
|
629
|
+
message: string;
|
|
630
|
+
stacks: ParsedStack[];
|
|
631
|
+
name: string;
|
|
632
|
+
constructor(message: string, stacks: ParsedStack[]);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
interface PrintErrorResult {
|
|
636
|
+
nearest?: ParsedStack;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
interface Options {
|
|
640
|
+
/**
|
|
641
|
+
Show the cursor. This can be useful when a CLI accepts input from a user.
|
|
642
|
+
|
|
643
|
+
@example
|
|
644
|
+
```
|
|
645
|
+
import {createLogUpdate} from 'log-update';
|
|
646
|
+
|
|
647
|
+
// Write output but don't hide the cursor
|
|
648
|
+
const log = createLogUpdate(process.stdout, {
|
|
649
|
+
showCursor: true
|
|
650
|
+
});
|
|
651
|
+
```
|
|
652
|
+
*/
|
|
653
|
+
readonly showCursor?: boolean;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
type LogUpdateMethods = {
|
|
657
|
+
/**
|
|
658
|
+
Clear the logged output.
|
|
659
|
+
*/
|
|
660
|
+
clear(): void;
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
Persist the logged output. Useful if you want to start a new log session below the current one.
|
|
664
|
+
*/
|
|
665
|
+
done(): void;
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
Log to `stdout` by overwriting the previous output in the terminal.
|
|
670
|
+
|
|
671
|
+
@param text - The text to log to `stdout`.
|
|
672
|
+
|
|
673
|
+
@example
|
|
674
|
+
```
|
|
675
|
+
import logUpdate from 'log-update';
|
|
676
|
+
|
|
677
|
+
const frames = ['-', '\\', '|', '/'];
|
|
678
|
+
let index = 0;
|
|
679
|
+
|
|
680
|
+
setInterval(() => {
|
|
681
|
+
const frame = frames[index = ++index % frames.length];
|
|
682
|
+
|
|
683
|
+
logUpdate(
|
|
684
|
+
`
|
|
685
|
+
♥♥
|
|
686
|
+
${frame} unicorns ${frame}
|
|
687
|
+
♥♥
|
|
688
|
+
`
|
|
689
|
+
);
|
|
690
|
+
}, 80);
|
|
691
|
+
```
|
|
692
|
+
*/
|
|
693
|
+
declare const logUpdate: ((...text: string[]) => void) & LogUpdateMethods;
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
Get a `logUpdate` method that logs to the specified stream.
|
|
698
|
+
|
|
699
|
+
@param stream - The stream to log to.
|
|
700
|
+
|
|
701
|
+
@example
|
|
702
|
+
```
|
|
703
|
+
import {createLogUpdate} from 'log-update';
|
|
704
|
+
|
|
705
|
+
// Write output but don't hide the cursor
|
|
706
|
+
const log = createLogUpdate(process.stdout);
|
|
707
|
+
```
|
|
708
|
+
*/
|
|
709
|
+
declare function createLogUpdate(
|
|
710
|
+
stream: NodeJS.WritableStream,
|
|
711
|
+
options?: Options
|
|
712
|
+
): typeof logUpdate;
|
|
713
|
+
|
|
714
|
+
interface ErrorOptions {
|
|
715
|
+
type?: string;
|
|
716
|
+
fullStack?: boolean;
|
|
717
|
+
project?: TestProject;
|
|
718
|
+
verbose?: boolean;
|
|
719
|
+
screenshotPaths?: string[];
|
|
720
|
+
task?: Task;
|
|
721
|
+
showCodeFrame?: boolean;
|
|
722
|
+
}
|
|
723
|
+
declare class Logger {
|
|
724
|
+
ctx: Vitest;
|
|
725
|
+
outputStream: NodeJS.WriteStream | Writable;
|
|
726
|
+
errorStream: NodeJS.WriteStream | Writable;
|
|
727
|
+
logUpdate: ReturnType<typeof createLogUpdate>;
|
|
728
|
+
private _clearScreenPending;
|
|
729
|
+
private _highlights;
|
|
730
|
+
console: Console;
|
|
731
|
+
constructor(ctx: Vitest, outputStream?: NodeJS.WriteStream | Writable, errorStream?: NodeJS.WriteStream | Writable);
|
|
732
|
+
log(...args: any[]): void;
|
|
733
|
+
error(...args: any[]): void;
|
|
734
|
+
warn(...args: any[]): void;
|
|
735
|
+
clearFullScreen(message?: string): void;
|
|
736
|
+
clearScreen(message: string, force?: boolean): void;
|
|
737
|
+
private _clearScreen;
|
|
738
|
+
printError(err: unknown, options?: ErrorOptions): PrintErrorResult | undefined;
|
|
739
|
+
clearHighlightCache(filename?: string): void;
|
|
740
|
+
highlight(filename: string, source: string): string;
|
|
741
|
+
printNoTestFound(filters?: string[]): void;
|
|
742
|
+
printBanner(): void;
|
|
743
|
+
printBrowserBanner(project: TestProject): void;
|
|
744
|
+
printUnhandledErrors(errors: unknown[]): void;
|
|
745
|
+
printSourceTypeErrors(errors: TypeCheckError[]): void;
|
|
746
|
+
private registerUnhandledRejection;
|
|
747
|
+
}
|
|
748
|
+
|
|
857
749
|
interface TableRendererOptions {
|
|
858
750
|
renderSucceed?: boolean;
|
|
859
751
|
logger: Logger;
|
|
@@ -862,9 +754,9 @@ interface TableRendererOptions {
|
|
|
862
754
|
compare?: FlatBenchmarkReport;
|
|
863
755
|
}
|
|
864
756
|
declare function createTableRenderer(_tasks: Task[], options: TableRendererOptions): {
|
|
865
|
-
start(): any;
|
|
866
|
-
update(_tasks: Task[]): any;
|
|
867
|
-
stop(): any;
|
|
757
|
+
start(): /*elided*/ any;
|
|
758
|
+
update(_tasks: Task[]): /*elided*/ any;
|
|
759
|
+
stop(): /*elided*/ any;
|
|
868
760
|
clear(): void;
|
|
869
761
|
};
|
|
870
762
|
|
|
@@ -931,15 +823,177 @@ interface BuiltinReporterOptions {
|
|
|
931
823
|
'html': HTMLOptions;
|
|
932
824
|
}
|
|
933
825
|
|
|
934
|
-
type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
|
|
935
|
-
|
|
826
|
+
type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
|
|
827
|
+
|
|
828
|
+
type BuiltinPool = 'browser' | 'threads' | 'forks' | 'vmThreads' | 'vmForks' | 'typescript';
|
|
829
|
+
type Pool = BuiltinPool | (string & {});
|
|
830
|
+
interface PoolOptions extends Record<string, unknown> {
|
|
831
|
+
/**
|
|
832
|
+
* Run tests in `node:worker_threads`.
|
|
833
|
+
*
|
|
834
|
+
* Test isolation (when enabled) is done by spawning a new thread for each test file.
|
|
835
|
+
*
|
|
836
|
+
* This pool is used by default.
|
|
837
|
+
*/
|
|
838
|
+
threads?: ThreadsOptions & WorkerContextOptions;
|
|
839
|
+
/**
|
|
840
|
+
* Run tests in `node:child_process` using [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
841
|
+
*
|
|
842
|
+
* Test isolation (when enabled) is done by spawning a new child process for each test file.
|
|
843
|
+
*/
|
|
844
|
+
forks?: ForksOptions & WorkerContextOptions;
|
|
845
|
+
/**
|
|
846
|
+
* Run tests in isolated `node:vm`.
|
|
847
|
+
* Test files are run parallel using `node:worker_threads`.
|
|
848
|
+
*
|
|
849
|
+
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
850
|
+
*/
|
|
851
|
+
vmThreads?: ThreadsOptions & VmOptions;
|
|
852
|
+
/**
|
|
853
|
+
* Run tests in isolated `node:vm`.
|
|
854
|
+
*
|
|
855
|
+
* Test files are run parallel using `node:child_process` [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
856
|
+
*
|
|
857
|
+
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
858
|
+
*/
|
|
859
|
+
vmForks?: ForksOptions & VmOptions;
|
|
860
|
+
}
|
|
861
|
+
interface ResolvedPoolOptions extends PoolOptions {
|
|
862
|
+
threads?: ResolvedThreadsOptions & WorkerContextOptions;
|
|
863
|
+
forks?: ResolvedForksOptions & WorkerContextOptions;
|
|
864
|
+
vmThreads?: ResolvedThreadsOptions & VmOptions;
|
|
865
|
+
vmForks?: ResolvedForksOptions & VmOptions;
|
|
866
|
+
}
|
|
867
|
+
interface ThreadsOptions {
|
|
868
|
+
/** Minimum amount of threads to use */
|
|
869
|
+
minThreads?: number | string;
|
|
870
|
+
/** Maximum amount of threads to use */
|
|
871
|
+
maxThreads?: number | string;
|
|
872
|
+
/**
|
|
873
|
+
* Run tests inside a single thread.
|
|
874
|
+
*
|
|
875
|
+
* @default false
|
|
876
|
+
*/
|
|
877
|
+
singleThread?: boolean;
|
|
878
|
+
/**
|
|
879
|
+
* Use Atomics to synchronize threads
|
|
880
|
+
*
|
|
881
|
+
* This can improve performance in some cases, but might cause segfault in older Node versions.
|
|
882
|
+
*
|
|
883
|
+
* @default false
|
|
884
|
+
*/
|
|
885
|
+
useAtomics?: boolean;
|
|
886
|
+
}
|
|
887
|
+
interface ResolvedThreadsOptions extends ThreadsOptions {
|
|
888
|
+
minThreads?: number;
|
|
889
|
+
maxThreads?: number;
|
|
890
|
+
}
|
|
891
|
+
interface ForksOptions {
|
|
892
|
+
/** Minimum amount of child processes to use */
|
|
893
|
+
minForks?: number | string;
|
|
894
|
+
/** Maximum amount of child processes to use */
|
|
895
|
+
maxForks?: number | string;
|
|
896
|
+
/**
|
|
897
|
+
* Run tests inside a single fork.
|
|
898
|
+
*
|
|
899
|
+
* @default false
|
|
900
|
+
*/
|
|
901
|
+
singleFork?: boolean;
|
|
902
|
+
}
|
|
903
|
+
interface ResolvedForksOptions extends ForksOptions {
|
|
904
|
+
minForks?: number;
|
|
905
|
+
maxForks?: number;
|
|
906
|
+
}
|
|
907
|
+
interface WorkerContextOptions {
|
|
908
|
+
/**
|
|
909
|
+
* Isolate test environment by recycling `worker_threads` or `child_process` after each test
|
|
910
|
+
*
|
|
911
|
+
* @default true
|
|
912
|
+
*/
|
|
913
|
+
isolate?: boolean;
|
|
914
|
+
/**
|
|
915
|
+
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
916
|
+
*
|
|
917
|
+
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
918
|
+
*
|
|
919
|
+
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
920
|
+
*
|
|
921
|
+
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
922
|
+
*
|
|
923
|
+
* @default [] // no execution arguments are passed
|
|
924
|
+
*/
|
|
925
|
+
execArgv?: string[];
|
|
926
|
+
}
|
|
927
|
+
interface VmOptions {
|
|
928
|
+
/**
|
|
929
|
+
* Specifies the memory limit for `worker_thread` or `child_process` before they are recycled.
|
|
930
|
+
* If you see memory leaks, try to tinker this value.
|
|
931
|
+
*/
|
|
932
|
+
memoryLimit?: string | number;
|
|
933
|
+
/** Isolation is always enabled */
|
|
934
|
+
isolate?: true;
|
|
935
|
+
/**
|
|
936
|
+
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
937
|
+
*
|
|
938
|
+
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
939
|
+
*
|
|
940
|
+
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
941
|
+
*
|
|
942
|
+
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
943
|
+
*
|
|
944
|
+
* @default [] // no execution arguments are passed
|
|
945
|
+
*/
|
|
946
|
+
execArgv?: string[];
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
declare class TestSpecification {
|
|
950
|
+
/**
|
|
951
|
+
* @deprecated use `project` instead
|
|
952
|
+
*/
|
|
953
|
+
readonly 0: TestProject;
|
|
954
|
+
/**
|
|
955
|
+
* @deprecated use `moduleId` instead
|
|
956
|
+
*/
|
|
957
|
+
readonly 1: string;
|
|
958
|
+
/**
|
|
959
|
+
* @deprecated use `pool` instead
|
|
960
|
+
*/
|
|
961
|
+
readonly 2: {
|
|
962
|
+
pool: Pool;
|
|
963
|
+
};
|
|
964
|
+
/**
|
|
965
|
+
* The test project that the module belongs to.
|
|
966
|
+
*/
|
|
967
|
+
readonly project: TestProject;
|
|
968
|
+
/**
|
|
969
|
+
* The ID of the module in the Vite module graph. It is usually an absolute file path.
|
|
970
|
+
*/
|
|
971
|
+
readonly moduleId: string;
|
|
972
|
+
/**
|
|
973
|
+
* The current test pool. It's possible to have multiple pools in a single test project with `poolMatchGlob` and `typecheck.enabled`.
|
|
974
|
+
* @experimental In Vitest 4, the project will only support a single pool and this property will be removed.
|
|
975
|
+
*/
|
|
976
|
+
readonly pool: Pool;
|
|
977
|
+
/**
|
|
978
|
+
* Line numbers of the test locations to run.
|
|
979
|
+
*/
|
|
980
|
+
readonly testLines: number[] | undefined;
|
|
981
|
+
constructor(project: TestProject, moduleId: string, pool: Pool, testLines?: number[] | undefined);
|
|
982
|
+
toJSON(): SerializedTestSpecification;
|
|
983
|
+
/**
|
|
984
|
+
* for backwards compatibility
|
|
985
|
+
* @deprecated
|
|
986
|
+
*/
|
|
987
|
+
[Symbol.iterator](): Generator<string | TestProject, void, unknown>;
|
|
988
|
+
}
|
|
989
|
+
|
|
936
990
|
interface TestSequencer {
|
|
937
991
|
/**
|
|
938
992
|
* Slicing tests into shards. Will be run before `sort`.
|
|
939
993
|
* Only run, if `shard` is defined.
|
|
940
994
|
*/
|
|
941
|
-
shard: (files:
|
|
942
|
-
sort: (files:
|
|
995
|
+
shard: (files: TestSpecification[]) => Awaitable<TestSpecification[]>;
|
|
996
|
+
sort: (files: TestSpecification[]) => Awaitable<TestSpecification[]>;
|
|
943
997
|
}
|
|
944
998
|
interface TestSequencerConstructor {
|
|
945
999
|
new (ctx: Vitest): TestSequencer;
|
|
@@ -1100,7 +1154,9 @@ interface CoverageProviderModule {
|
|
|
1100
1154
|
/**
|
|
1101
1155
|
* Executed before tests are run in the worker thread.
|
|
1102
1156
|
*/
|
|
1103
|
-
startCoverage?: (
|
|
1157
|
+
startCoverage?: (runtimeOptions: {
|
|
1158
|
+
isolate: boolean;
|
|
1159
|
+
}) => unknown | Promise<unknown>;
|
|
1104
1160
|
/**
|
|
1105
1161
|
* Executed on after each run in the worker thread. Possible to return a payload passed to the provider
|
|
1106
1162
|
*/
|
|
@@ -1108,7 +1164,9 @@ interface CoverageProviderModule {
|
|
|
1108
1164
|
/**
|
|
1109
1165
|
* Executed after all tests have been run in the worker thread.
|
|
1110
1166
|
*/
|
|
1111
|
-
stopCoverage?: (
|
|
1167
|
+
stopCoverage?: (runtimeOptions: {
|
|
1168
|
+
isolate: boolean;
|
|
1169
|
+
}) => unknown | Promise<unknown>;
|
|
1112
1170
|
}
|
|
1113
1171
|
type CoverageReporter = keyof ReportOptions | (string & {});
|
|
1114
1172
|
type CoverageReporterWithOptions<ReporterName extends CoverageReporter = CoverageReporter> = ReporterName extends keyof ReportOptions ? ReportOptions[ReporterName] extends never ? [ReporterName, object] : [ReporterName, Partial<ReportOptions[ReporterName]>] : [ReporterName, Record<string, unknown>];
|
|
@@ -1297,127 +1355,6 @@ interface Thresholds {
|
|
|
1297
1355
|
lines?: number;
|
|
1298
1356
|
}
|
|
1299
1357
|
|
|
1300
|
-
type BuiltinPool = 'browser' | 'threads' | 'forks' | 'vmThreads' | 'vmForks' | 'typescript';
|
|
1301
|
-
type Pool = BuiltinPool | (string & {});
|
|
1302
|
-
interface PoolOptions extends Record<string, unknown> {
|
|
1303
|
-
/**
|
|
1304
|
-
* Run tests in `node:worker_threads`.
|
|
1305
|
-
*
|
|
1306
|
-
* Test isolation (when enabled) is done by spawning a new thread for each test file.
|
|
1307
|
-
*
|
|
1308
|
-
* This pool is used by default.
|
|
1309
|
-
*/
|
|
1310
|
-
threads?: ThreadsOptions & WorkerContextOptions;
|
|
1311
|
-
/**
|
|
1312
|
-
* Run tests in `node:child_process` using [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
1313
|
-
*
|
|
1314
|
-
* Test isolation (when enabled) is done by spawning a new child process for each test file.
|
|
1315
|
-
*/
|
|
1316
|
-
forks?: ForksOptions & WorkerContextOptions;
|
|
1317
|
-
/**
|
|
1318
|
-
* Run tests in isolated `node:vm`.
|
|
1319
|
-
* Test files are run parallel using `node:worker_threads`.
|
|
1320
|
-
*
|
|
1321
|
-
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
1322
|
-
*/
|
|
1323
|
-
vmThreads?: ThreadsOptions & VmOptions;
|
|
1324
|
-
/**
|
|
1325
|
-
* Run tests in isolated `node:vm`.
|
|
1326
|
-
*
|
|
1327
|
-
* Test files are run parallel using `node:child_process` [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
1328
|
-
*
|
|
1329
|
-
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
1330
|
-
*/
|
|
1331
|
-
vmForks?: ForksOptions & VmOptions;
|
|
1332
|
-
}
|
|
1333
|
-
interface ResolvedPoolOptions extends PoolOptions {
|
|
1334
|
-
threads?: ResolvedThreadsOptions & WorkerContextOptions;
|
|
1335
|
-
forks?: ResolvedForksOptions & WorkerContextOptions;
|
|
1336
|
-
vmThreads?: ResolvedThreadsOptions & VmOptions;
|
|
1337
|
-
vmForks?: ResolvedForksOptions & VmOptions;
|
|
1338
|
-
}
|
|
1339
|
-
interface ThreadsOptions {
|
|
1340
|
-
/** Minimum amount of threads to use */
|
|
1341
|
-
minThreads?: number | string;
|
|
1342
|
-
/** Maximum amount of threads to use */
|
|
1343
|
-
maxThreads?: number | string;
|
|
1344
|
-
/**
|
|
1345
|
-
* Run tests inside a single thread.
|
|
1346
|
-
*
|
|
1347
|
-
* @default false
|
|
1348
|
-
*/
|
|
1349
|
-
singleThread?: boolean;
|
|
1350
|
-
/**
|
|
1351
|
-
* Use Atomics to synchronize threads
|
|
1352
|
-
*
|
|
1353
|
-
* This can improve performance in some cases, but might cause segfault in older Node versions.
|
|
1354
|
-
*
|
|
1355
|
-
* @default false
|
|
1356
|
-
*/
|
|
1357
|
-
useAtomics?: boolean;
|
|
1358
|
-
}
|
|
1359
|
-
interface ResolvedThreadsOptions extends ThreadsOptions {
|
|
1360
|
-
minThreads?: number;
|
|
1361
|
-
maxThreads?: number;
|
|
1362
|
-
}
|
|
1363
|
-
interface ForksOptions {
|
|
1364
|
-
/** Minimum amount of child processes to use */
|
|
1365
|
-
minForks?: number | string;
|
|
1366
|
-
/** Maximum amount of child processes to use */
|
|
1367
|
-
maxForks?: number | string;
|
|
1368
|
-
/**
|
|
1369
|
-
* Run tests inside a single fork.
|
|
1370
|
-
*
|
|
1371
|
-
* @default false
|
|
1372
|
-
*/
|
|
1373
|
-
singleFork?: boolean;
|
|
1374
|
-
}
|
|
1375
|
-
interface ResolvedForksOptions extends ForksOptions {
|
|
1376
|
-
minForks?: number;
|
|
1377
|
-
maxForks?: number;
|
|
1378
|
-
}
|
|
1379
|
-
interface WorkerContextOptions {
|
|
1380
|
-
/**
|
|
1381
|
-
* Isolate test environment by recycling `worker_threads` or `child_process` after each test
|
|
1382
|
-
*
|
|
1383
|
-
* @default true
|
|
1384
|
-
*/
|
|
1385
|
-
isolate?: boolean;
|
|
1386
|
-
/**
|
|
1387
|
-
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
1388
|
-
*
|
|
1389
|
-
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
1390
|
-
*
|
|
1391
|
-
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
1392
|
-
*
|
|
1393
|
-
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
1394
|
-
*
|
|
1395
|
-
* @default [] // no execution arguments are passed
|
|
1396
|
-
*/
|
|
1397
|
-
execArgv?: string[];
|
|
1398
|
-
}
|
|
1399
|
-
interface VmOptions {
|
|
1400
|
-
/**
|
|
1401
|
-
* Specifies the memory limit for `worker_thread` or `child_process` before they are recycled.
|
|
1402
|
-
* If you see memory leaks, try to tinker this value.
|
|
1403
|
-
*/
|
|
1404
|
-
memoryLimit?: string | number;
|
|
1405
|
-
/** Isolation is always enabled */
|
|
1406
|
-
isolate?: true;
|
|
1407
|
-
/**
|
|
1408
|
-
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
1409
|
-
*
|
|
1410
|
-
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
1411
|
-
*
|
|
1412
|
-
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
1413
|
-
*
|
|
1414
|
-
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
1415
|
-
*
|
|
1416
|
-
* @default [] // no execution arguments are passed
|
|
1417
|
-
*/
|
|
1418
|
-
execArgv?: string[];
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
1358
|
type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
|
|
1422
1359
|
type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
|
|
1423
1360
|
|
|
@@ -1656,6 +1593,7 @@ interface InlineConfig {
|
|
|
1656
1593
|
*
|
|
1657
1594
|
* Format: [glob, environment-name]
|
|
1658
1595
|
*
|
|
1596
|
+
* @deprecated use [`workspace`](https://vitest.dev/config/#environmentmatchglobs) instead
|
|
1659
1597
|
* @default []
|
|
1660
1598
|
* @example [
|
|
1661
1599
|
* // all tests in tests/dom will run in jsdom
|
|
@@ -1706,6 +1644,7 @@ interface InlineConfig {
|
|
|
1706
1644
|
*
|
|
1707
1645
|
* Format: [glob, pool-name]
|
|
1708
1646
|
*
|
|
1647
|
+
* @deprecated use [`workspace`](https://vitest.dev/config/#poolmatchglobs) instead
|
|
1709
1648
|
* @default []
|
|
1710
1649
|
* @example [
|
|
1711
1650
|
* // all tests in "forks" directory will run using "poolOptions.forks" API
|
|
@@ -1718,7 +1657,7 @@ interface InlineConfig {
|
|
|
1718
1657
|
/**
|
|
1719
1658
|
* Path to a workspace configuration file
|
|
1720
1659
|
*/
|
|
1721
|
-
workspace?: string;
|
|
1660
|
+
workspace?: string | TestProjectConfiguration[];
|
|
1722
1661
|
/**
|
|
1723
1662
|
* Update snapshot
|
|
1724
1663
|
*
|
|
@@ -2275,9 +2214,10 @@ type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig
|
|
|
2275
2214
|
type TestProjectConfiguration = string | (UserProjectConfigExport & {
|
|
2276
2215
|
/**
|
|
2277
2216
|
* Relative path to the extendable config. All other options will be merged with this config.
|
|
2217
|
+
* If `true`, the project will inherit all options from the root config.
|
|
2278
2218
|
* @example '../vite.config.ts'
|
|
2279
2219
|
*/
|
|
2280
|
-
extends?: string;
|
|
2220
|
+
extends?: string | true;
|
|
2281
2221
|
});
|
|
2282
2222
|
/** @deprecated use `TestProjectConfiguration` instead */
|
|
2283
2223
|
type WorkspaceProjectConfiguration = TestProjectConfiguration;
|
|
@@ -2508,33 +2448,6 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
|
2508
2448
|
};
|
|
2509
2449
|
}
|
|
2510
2450
|
|
|
2511
|
-
declare class TestSpecification {
|
|
2512
|
-
/**
|
|
2513
|
-
* @deprecated use `project` instead
|
|
2514
|
-
*/
|
|
2515
|
-
readonly 0: TestProject;
|
|
2516
|
-
/**
|
|
2517
|
-
* @deprecated use `moduleId` instead
|
|
2518
|
-
*/
|
|
2519
|
-
readonly 1: string;
|
|
2520
|
-
/**
|
|
2521
|
-
* @deprecated use `pool` instead
|
|
2522
|
-
*/
|
|
2523
|
-
readonly 2: {
|
|
2524
|
-
pool: Pool;
|
|
2525
|
-
};
|
|
2526
|
-
readonly project: TestProject;
|
|
2527
|
-
readonly moduleId: string;
|
|
2528
|
-
readonly pool: Pool;
|
|
2529
|
-
constructor(project: TestProject, moduleId: string, pool: Pool);
|
|
2530
|
-
toJSON(): SerializedTestSpecification;
|
|
2531
|
-
/**
|
|
2532
|
-
* for backwards compatibility
|
|
2533
|
-
* @deprecated
|
|
2534
|
-
*/
|
|
2535
|
-
[Symbol.iterator](): Generator<string | TestProject, void, unknown>;
|
|
2536
|
-
}
|
|
2537
|
-
|
|
2538
2451
|
declare class TestProject {
|
|
2539
2452
|
/** @deprecated */
|
|
2540
2453
|
path: string | number;
|
|
@@ -2559,9 +2472,7 @@ declare class TestProject {
|
|
|
2559
2472
|
* Temporary directory for the project. This is unique for each project. Vitest stores transformed content here.
|
|
2560
2473
|
*/
|
|
2561
2474
|
readonly tmpDir: string;
|
|
2562
|
-
|
|
2563
|
-
runner: ViteNodeRunner;
|
|
2564
|
-
typechecker?: Typechecker;
|
|
2475
|
+
private runner;
|
|
2565
2476
|
private closingPromise;
|
|
2566
2477
|
private testFilesList;
|
|
2567
2478
|
private typecheckFilesList;
|
|
@@ -2577,7 +2488,7 @@ declare class TestProject {
|
|
|
2577
2488
|
/**
|
|
2578
2489
|
* Provide a value to the test context. This value will be available to all tests with `inject`.
|
|
2579
2490
|
*/
|
|
2580
|
-
provide<T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T])
|
|
2491
|
+
provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
|
|
2581
2492
|
/**
|
|
2582
2493
|
* Get the provided context. The project context is merged with the global context.
|
|
2583
2494
|
*/
|
|
@@ -2586,7 +2497,9 @@ declare class TestProject {
|
|
|
2586
2497
|
* Creates a new test specification. Specifications describe how to run tests.
|
|
2587
2498
|
* @param moduleId The file path
|
|
2588
2499
|
*/
|
|
2589
|
-
createSpecification(moduleId: string,
|
|
2500
|
+
createSpecification(moduleId: string, locations?: number[] | undefined,
|
|
2501
|
+
/** @internal */
|
|
2502
|
+
pool?: string): TestSpecification;
|
|
2590
2503
|
toJSON(): SerializedTestProject;
|
|
2591
2504
|
/**
|
|
2592
2505
|
* Vite's dev server instance. Every workspace project has its own server.
|
|
@@ -2616,6 +2529,7 @@ declare class TestProject {
|
|
|
2616
2529
|
createSpec(moduleId: string, pool: string): WorkspaceSpec;
|
|
2617
2530
|
/** @deprecated */
|
|
2618
2531
|
initializeGlobalSetup(): Promise<void>;
|
|
2532
|
+
onTestsRerun(cb: OnTestsRerunHandler): void;
|
|
2619
2533
|
/** @deprecated */
|
|
2620
2534
|
teardownGlobalSetup(): Promise<void>;
|
|
2621
2535
|
/** @deprecated use `vitest.logger` instead */
|
|
@@ -2644,12 +2558,13 @@ declare class TestProject {
|
|
|
2644
2558
|
}>;
|
|
2645
2559
|
private globAllTestFiles;
|
|
2646
2560
|
isBrowserEnabled(): boolean;
|
|
2561
|
+
private markTestFile;
|
|
2647
2562
|
/** @deprecated use `serializedConfig` instead */
|
|
2648
2563
|
getSerializableConfig(): SerializedConfig;
|
|
2649
2564
|
/**
|
|
2650
|
-
* Test if a file matches the test globs. This does the actual glob matching unlike `
|
|
2565
|
+
* Test if a file matches the test globs. This does the actual glob matching if the test is not cached, unlike `isCachedTestFile`.
|
|
2651
2566
|
*/
|
|
2652
|
-
matchesTestGlob(
|
|
2567
|
+
matchesTestGlob(moduleId: string, source?: () => string): boolean;
|
|
2653
2568
|
/** @deprecated use `matchesTestGlob` instead */
|
|
2654
2569
|
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
2655
2570
|
private isInSourceTestCode;
|
|
@@ -2659,6 +2574,11 @@ declare class TestProject {
|
|
|
2659
2574
|
* If the resources are needed again, create a new project.
|
|
2660
2575
|
*/
|
|
2661
2576
|
close(): Promise<void>;
|
|
2577
|
+
/**
|
|
2578
|
+
* Import a file using Vite module runner.
|
|
2579
|
+
* @param moduleId The ID of the module in Vite module graph
|
|
2580
|
+
*/
|
|
2581
|
+
import<T>(moduleId: string): Promise<T>;
|
|
2662
2582
|
/** @deprecated use `name` instead */
|
|
2663
2583
|
getName(): string;
|
|
2664
2584
|
/** @deprecated internal */
|
|
@@ -2675,7 +2595,7 @@ interface SerializedTestProject {
|
|
|
2675
2595
|
context: ProvidedContext;
|
|
2676
2596
|
}
|
|
2677
2597
|
interface InitializeProjectOptions extends UserWorkspaceConfig {
|
|
2678
|
-
|
|
2598
|
+
configFile: string | false;
|
|
2679
2599
|
extends?: string;
|
|
2680
2600
|
}
|
|
2681
2601
|
|
|
@@ -2698,7 +2618,7 @@ type WorkspaceSpec = TestSpecification & [
|
|
|
2698
2618
|
pool: Pool;
|
|
2699
2619
|
}
|
|
2700
2620
|
];
|
|
2701
|
-
type RunWithFiles = (files:
|
|
2621
|
+
type RunWithFiles = (files: TestSpecification[], invalidates?: string[]) => Awaitable$1<void>;
|
|
2702
2622
|
interface ProcessPool {
|
|
2703
2623
|
name: string;
|
|
2704
2624
|
runTests: RunWithFiles;
|
|
@@ -2707,6 +2627,11 @@ interface ProcessPool {
|
|
|
2707
2627
|
}
|
|
2708
2628
|
declare function getFilePoolName(project: TestProject, file: string): Pool;
|
|
2709
2629
|
|
|
2630
|
+
interface TestRunResult {
|
|
2631
|
+
testModules: TestModule[];
|
|
2632
|
+
unhandledErrors: unknown[];
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2710
2635
|
interface SuiteResultCache {
|
|
2711
2636
|
failed: boolean;
|
|
2712
2637
|
duration: number;
|
|
@@ -2731,7 +2656,7 @@ type FileStatsCache = Pick<Stats, 'size'>;
|
|
|
2731
2656
|
declare class FilesStatsCache {
|
|
2732
2657
|
cache: Map<string, FileStatsCache>;
|
|
2733
2658
|
getStats(key: string): FileStatsCache | undefined;
|
|
2734
|
-
populateStats(root: string, specs:
|
|
2659
|
+
populateStats(root: string, specs: TestSpecification[]): Promise<void>;
|
|
2735
2660
|
updateStats(fsPath: string, key: string): Promise<void>;
|
|
2736
2661
|
removeStats(fsPath: string): void;
|
|
2737
2662
|
}
|
|
@@ -2794,122 +2719,261 @@ interface VitestOptions {
|
|
|
2794
2719
|
}
|
|
2795
2720
|
declare class Vitest {
|
|
2796
2721
|
readonly mode: VitestRunMode;
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2722
|
+
/**
|
|
2723
|
+
* Current Vitest version.
|
|
2724
|
+
* @example '2.0.0'
|
|
2725
|
+
*/
|
|
2726
|
+
readonly version: string;
|
|
2727
|
+
static readonly version: string;
|
|
2728
|
+
/**
|
|
2729
|
+
* The logger instance used to log messages. It's recommended to use this logger instead of `console`.
|
|
2730
|
+
* It's possible to override stdout and stderr streams when initiating Vitest.
|
|
2731
|
+
* @example
|
|
2732
|
+
* new Vitest('test', {
|
|
2733
|
+
* stdout: new Writable(),
|
|
2734
|
+
* })
|
|
2735
|
+
*/
|
|
2736
|
+
readonly logger: Logger;
|
|
2737
|
+
/**
|
|
2738
|
+
* The package installer instance used to install Vitest packages.
|
|
2739
|
+
* @example
|
|
2740
|
+
* await vitest.packageInstaller.ensureInstalled('@vitest/browser', process.cwd())
|
|
2741
|
+
*/
|
|
2742
|
+
readonly packageInstaller: VitestPackageInstaller;
|
|
2743
|
+
/**
|
|
2744
|
+
* A path to the built Vitest directory. This is usually a folder in `node_modules`.
|
|
2745
|
+
*/
|
|
2746
|
+
readonly distPath: string;
|
|
2747
|
+
/**
|
|
2748
|
+
* A list of projects that are currently running.
|
|
2749
|
+
* If projects were filtered with `--project` flag, they won't appear here.
|
|
2750
|
+
*/
|
|
2822
2751
|
projects: TestProject[];
|
|
2823
|
-
|
|
2824
|
-
private
|
|
2752
|
+
private isFirstRun;
|
|
2753
|
+
private restartsCount;
|
|
2754
|
+
private readonly specifications;
|
|
2755
|
+
private readonly watcher;
|
|
2756
|
+
private pool;
|
|
2757
|
+
private _config?;
|
|
2758
|
+
private _vite?;
|
|
2759
|
+
private _state?;
|
|
2760
|
+
private _cache?;
|
|
2761
|
+
private _snapshot?;
|
|
2825
2762
|
private _workspaceConfigPath?;
|
|
2826
|
-
/** @deprecated use `_cachedSpecs` */
|
|
2827
|
-
projectTestFiles: Map<string, TestSpecification[]>;
|
|
2828
|
-
/** @private */
|
|
2829
|
-
_browserLastPort: number;
|
|
2830
2763
|
constructor(mode: VitestRunMode, options?: VitestOptions);
|
|
2831
2764
|
private _onRestartListeners;
|
|
2832
2765
|
private _onClose;
|
|
2833
2766
|
private _onSetServer;
|
|
2834
2767
|
private _onCancelListeners;
|
|
2835
2768
|
private _onUserTestsRerun;
|
|
2769
|
+
private _onFilterWatchedSpecification;
|
|
2770
|
+
/** @deprecated will be removed in 4.0, use `onFilterWatchedSpecification` instead */
|
|
2771
|
+
get invalidates(): Set<string>;
|
|
2772
|
+
/** @deprecated will be removed in 4.0, use `onFilterWatchedSpecification` instead */
|
|
2773
|
+
get changedTests(): Set<string>;
|
|
2774
|
+
/**
|
|
2775
|
+
* The global config.
|
|
2776
|
+
*/
|
|
2777
|
+
get config(): ResolvedConfig;
|
|
2778
|
+
/** @deprecated use `vitest.vite` instead */
|
|
2779
|
+
get server(): ViteDevServer;
|
|
2780
|
+
/**
|
|
2781
|
+
* Global Vite's dev server instance.
|
|
2782
|
+
*/
|
|
2783
|
+
get vite(): ViteDevServer;
|
|
2784
|
+
/**
|
|
2785
|
+
* The global test state manager.
|
|
2786
|
+
* @experimental The State API is experimental and not subject to semver.
|
|
2787
|
+
*/
|
|
2788
|
+
get state(): StateManager;
|
|
2789
|
+
/**
|
|
2790
|
+
* The global snapshot manager. You can access the current state on `snapshot.summary`.
|
|
2791
|
+
*/
|
|
2792
|
+
get snapshot(): SnapshotManager;
|
|
2793
|
+
/**
|
|
2794
|
+
* Test results and test file stats cache. Primarily used by the sequencer to sort tests.
|
|
2795
|
+
*/
|
|
2796
|
+
get cache(): VitestCache;
|
|
2797
|
+
/** @deprecated internal */
|
|
2836
2798
|
setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
|
|
2837
|
-
|
|
2838
|
-
|
|
2799
|
+
/**
|
|
2800
|
+
* Provide a value to the test context. This value will be available to all tests with `inject`.
|
|
2801
|
+
*/
|
|
2802
|
+
provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
|
|
2803
|
+
/**
|
|
2804
|
+
* Get global provided context.
|
|
2805
|
+
*/
|
|
2806
|
+
getProvidedContext(): ProvidedContext;
|
|
2807
|
+
/** @deprecated use `getRootProject` instead */
|
|
2808
|
+
getCoreWorkspaceProject(): TestProject;
|
|
2809
|
+
/**
|
|
2810
|
+
* Return project that has the root (or "global") config.
|
|
2811
|
+
*/
|
|
2812
|
+
getRootProject(): TestProject;
|
|
2839
2813
|
/**
|
|
2840
2814
|
* @deprecated use Reported Task API instead
|
|
2841
2815
|
*/
|
|
2842
2816
|
getProjectByTaskId(taskId: string): TestProject;
|
|
2843
|
-
getProjectByName(name
|
|
2844
|
-
|
|
2817
|
+
getProjectByName(name: string): TestProject;
|
|
2818
|
+
/**
|
|
2819
|
+
* Import a file using Vite module runner. The file will be transformed by Vite and executed in a separate context.
|
|
2820
|
+
* @param moduleId The ID of the module in Vite module graph
|
|
2821
|
+
*/
|
|
2822
|
+
import<T>(moduleId: string): Promise<T>;
|
|
2823
|
+
private resolveWorkspaceConfigPath;
|
|
2845
2824
|
private resolveWorkspace;
|
|
2825
|
+
/**
|
|
2826
|
+
* Glob test files in every project and create a TestSpecification for each file and pool.
|
|
2827
|
+
* @param filters String filters to match the test files.
|
|
2828
|
+
*/
|
|
2829
|
+
globTestSpecifications(filters?: string[]): Promise<TestSpecification[]>;
|
|
2846
2830
|
private initCoverageProvider;
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2831
|
+
/**
|
|
2832
|
+
* Merge reports from multiple runs located in the specified directory (value from `--merge-reports` if not specified).
|
|
2833
|
+
*/
|
|
2834
|
+
mergeReports(directory?: string): Promise<TestRunResult>;
|
|
2835
|
+
collect(filters?: string[]): Promise<TestRunResult>;
|
|
2836
|
+
/** @deprecated use `getRelevantTestSpecifications` instead */
|
|
2837
|
+
listFiles(filters?: string[]): Promise<TestSpecification[]>;
|
|
2838
|
+
/**
|
|
2839
|
+
* Returns the list of test files that match the config and filters.
|
|
2840
|
+
* @param filters String filters to match the test files
|
|
2841
|
+
*/
|
|
2842
|
+
getRelevantTestSpecifications(filters?: string[]): Promise<TestSpecification[]>;
|
|
2843
|
+
/**
|
|
2844
|
+
* Initialize reporters, the coverage provider, and run tests.
|
|
2845
|
+
* This method can throw an error:
|
|
2846
|
+
* - `FilesNotFoundError` if no tests are found
|
|
2847
|
+
* - `GitNotFoundError` if `--related` flag is used, but git repository is not initialized
|
|
2848
|
+
* - `Error` from the user reporters
|
|
2849
|
+
* @param filters String filters to match the test files
|
|
2850
|
+
*/
|
|
2851
|
+
start(filters?: string[]): Promise<TestRunResult>;
|
|
2852
|
+
/**
|
|
2853
|
+
* Initialize reporters and the coverage provider. This method doesn't run any tests.
|
|
2854
|
+
* If the `--watch` flag is provided, Vitest will still run changed tests even if this method was not called.
|
|
2855
|
+
*/
|
|
2854
2856
|
init(): Promise<void>;
|
|
2855
|
-
private getTestDependencies;
|
|
2856
|
-
filterTestsBySource(specs: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
|
|
2857
2857
|
/**
|
|
2858
|
-
* @deprecated remove when vscode extension supports "
|
|
2858
|
+
* @deprecated remove when vscode extension supports "getModuleSpecifications"
|
|
2859
2859
|
*/
|
|
2860
2860
|
getProjectsByTestFile(file: string): WorkspaceSpec[];
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2861
|
+
/** @deprecated */
|
|
2862
|
+
getFileWorkspaceSpecs(file: string): WorkspaceSpec[];
|
|
2863
|
+
/**
|
|
2864
|
+
* Get test specifications assosiated with the given module. If module is not a test file, an empty array is returned.
|
|
2865
|
+
*
|
|
2866
|
+
* **Note:** this method relies on a cache generated by `globTestSpecifications`. If the file was not processed yet, use `project.matchesGlobPattern` instead.
|
|
2867
|
+
* @param moduleId The module ID to get test specifications for.
|
|
2868
|
+
*/
|
|
2869
|
+
getModuleSpecifications(moduleId: string): TestSpecification[];
|
|
2870
|
+
/**
|
|
2871
|
+
* Vitest automatically caches test specifications for each file. This method clears the cache for the given file or the whole cache alltogether.
|
|
2872
|
+
*/
|
|
2873
|
+
clearSpecificationsCache(moduleId?: string): void;
|
|
2874
|
+
/**
|
|
2875
|
+
* Run tests for the given test specifications. This does not trigger `onWatcher*` events.
|
|
2876
|
+
* @param specifications A list of specifications to run.
|
|
2877
|
+
* @param allTestsRun Indicates whether all tests were run. This only matters for coverage.
|
|
2878
|
+
*/
|
|
2879
|
+
runTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
|
|
2880
|
+
/**
|
|
2881
|
+
* Rerun files and trigger `onWatcherRerun`, `onWatcherStart` and `onTestsRerun` events.
|
|
2882
|
+
* @param specifications A list of specifications to run.
|
|
2883
|
+
* @param allTestsRun Indicates whether all tests were run. This only matters for coverage.
|
|
2884
|
+
*/
|
|
2885
|
+
rerunTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
|
|
2886
|
+
private runFiles;
|
|
2887
|
+
/**
|
|
2888
|
+
* Collect tests in specified modules. Vitest will run the files to collect tests.
|
|
2889
|
+
* @param specifications A list of specifications to run.
|
|
2890
|
+
*/
|
|
2891
|
+
collectTests(specifications: TestSpecification[]): Promise<TestRunResult>;
|
|
2892
|
+
/**
|
|
2893
|
+
* Gracefully cancel the current test run. Vitest will wait until all running tests are finished before cancelling.
|
|
2894
|
+
*/
|
|
2865
2895
|
cancelCurrentRun(reason: CancelReason): Promise<void>;
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2896
|
+
private initializeGlobalSetup;
|
|
2897
|
+
/**
|
|
2898
|
+
* Enable the mode that allows updating snapshots when running tests.
|
|
2899
|
+
* This method doesn't run any tests.
|
|
2900
|
+
*
|
|
2901
|
+
* Every test that runs after this method is called will update snapshots.
|
|
2902
|
+
* To disable the mode, call `resetSnapshotUpdate`.
|
|
2903
|
+
*/
|
|
2904
|
+
enableSnapshotUpdate(): void;
|
|
2905
|
+
/**
|
|
2906
|
+
* Disable the mode that allows updating snapshots when running tests.
|
|
2907
|
+
*/
|
|
2908
|
+
resetSnapshotUpdate(): void;
|
|
2909
|
+
/**
|
|
2910
|
+
* Set the global test name pattern to a regexp.
|
|
2911
|
+
* This method doesn't run any tests.
|
|
2912
|
+
*/
|
|
2913
|
+
setGlobalTestNamePattern(pattern: string | RegExp): void;
|
|
2914
|
+
/**
|
|
2915
|
+
* Resets the global test name pattern. This method doesn't run any tests.
|
|
2916
|
+
*/
|
|
2917
|
+
resetGlobalTestNamePattern(): void;
|
|
2875
2918
|
private _rerunTimer;
|
|
2876
2919
|
private scheduleRerun;
|
|
2877
|
-
getModuleProjects(filepath: string): TestProject[];
|
|
2878
2920
|
/**
|
|
2879
|
-
*
|
|
2921
|
+
* Invalidate a file in all projects.
|
|
2880
2922
|
*/
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
onAdd: (id: string) => Promise<void>;
|
|
2886
|
-
checkUnhandledErrors(errors: unknown[]): void;
|
|
2887
|
-
private unregisterWatcher;
|
|
2888
|
-
private registerWatcher;
|
|
2923
|
+
invalidateFile(filepath: string): void;
|
|
2924
|
+
/** @deprecated use `invalidateFile` */
|
|
2925
|
+
updateLastChanged(filepath: string): void;
|
|
2926
|
+
private reportCoverage;
|
|
2889
2927
|
/**
|
|
2890
|
-
*
|
|
2928
|
+
* Closes all projects and their associated resources.
|
|
2929
|
+
* This can only be called once; the closing promise is cached until the server restarts.
|
|
2891
2930
|
*/
|
|
2892
|
-
private handleFileChanged;
|
|
2893
|
-
private reportCoverage;
|
|
2894
2931
|
close(): Promise<void>;
|
|
2895
2932
|
/**
|
|
2896
|
-
*
|
|
2933
|
+
* Closes all projects and exit the process
|
|
2934
|
+
* @param force If true, the process will exit immediately after closing the projects.
|
|
2897
2935
|
*/
|
|
2898
2936
|
exit(force?: boolean): Promise<void>;
|
|
2899
|
-
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
|
|
2900
|
-
getTestFilepaths(): Promise<string[]>;
|
|
2901
|
-
globTestSpecs(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
2902
2937
|
/**
|
|
2903
|
-
* @deprecated use `
|
|
2938
|
+
* @deprecated use `globTestSpecifications` instead
|
|
2939
|
+
*/
|
|
2940
|
+
globTestSpecs(filters?: string[]): Promise<TestSpecification[]>;
|
|
2941
|
+
/**
|
|
2942
|
+
* @deprecated use `globTestSpecifications` instead
|
|
2943
|
+
*/
|
|
2944
|
+
globTestFiles(filters?: string[]): Promise<TestSpecification[]>;
|
|
2945
|
+
/** @deprecated filter by `this.projects` yourself */
|
|
2946
|
+
getModuleProjects(filepath: string): TestProject[];
|
|
2947
|
+
/**
|
|
2948
|
+
* Should the server be kept running after the tests are done.
|
|
2904
2949
|
*/
|
|
2905
|
-
globTestFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
2906
|
-
private ensureSpecCached;
|
|
2907
2950
|
shouldKeepServer(): boolean;
|
|
2951
|
+
/**
|
|
2952
|
+
* Register a handler that will be called when the server is restarted due to a config change.
|
|
2953
|
+
*/
|
|
2908
2954
|
onServerRestart(fn: OnServerRestartHandler): void;
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2955
|
+
/**
|
|
2956
|
+
* Register a handler that will be called when the test run is cancelled with `vitest.cancelCurrentRun`.
|
|
2957
|
+
*/
|
|
2958
|
+
onCancel(fn: (reason: CancelReason) => Awaitable$1<void>): void;
|
|
2959
|
+
/**
|
|
2960
|
+
* Register a handler that will be called when the server is closed.
|
|
2961
|
+
*/
|
|
2962
|
+
onClose(fn: () => Awaitable$1<void>): void;
|
|
2963
|
+
/**
|
|
2964
|
+
* Register a handler that will be called when the tests are rerunning.
|
|
2965
|
+
*/
|
|
2912
2966
|
onTestsRerun(fn: OnTestsRerunHandler): void;
|
|
2967
|
+
/**
|
|
2968
|
+
* Register a handler that will be called when a file is changed.
|
|
2969
|
+
* This callback should return `true` of `false` indicating whether the test file needs to be rerun.
|
|
2970
|
+
* @example
|
|
2971
|
+
* const testsToRun = [resolve('./test.spec.ts')]
|
|
2972
|
+
* vitest.onFilterWatchedSpecification(specification => testsToRun.includes(specification.moduleId))
|
|
2973
|
+
*/
|
|
2974
|
+
onFilterWatchedSpecification(fn: (specification: TestSpecification) => boolean): void;
|
|
2913
2975
|
}
|
|
2976
|
+
type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
|
|
2977
|
+
type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
|
|
2914
2978
|
|
|
2915
|
-
export { type
|
|
2979
|
+
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, VerboseReporter as aA, BaseReporter as aB, TestFile as aC, type FileDiagnostic as aD, ReportersMap as aE, type BuiltinReporters as aF, type BuiltinReporterOptions as aG, type JsonAssertionResult as aH, type JsonTestResult as aI, type JsonTestResults as aJ, BenchmarkReportsMap as aK, type BenchmarkBuiltinReporters as aL, type BrowserBuiltinProvider as aa, type BrowserCommand as ab, type BrowserCommandContext as ac, type BrowserOrchestrator as ad, type BrowserProvider as ae, type BrowserProviderInitializationOptions as af, type BrowserProviderModule as ag, type BrowserProviderOptions as ah, type BrowserServer as ai, type BrowserServerState as aj, type BrowserServerStateContext as ak, type CDPSession as al, type ResolvedBrowserOptions as am, type ResolvedProjectConfig as an, type ResolveSnapshotPathHandler as ao, type ResolveSnapshotPathHandlerContext as ap, type TestRunResult as aq, BasicReporter as ar, DefaultReporter as as, DotReporter as at, GithubActionsReporter as au, HangingProcessReporter as av, JsonReporter as aw, JUnitReporter as ax, TapFlatReporter as ay, TapReporter as az, type 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 };
|