vitest 3.0.0-beta.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -315
- package/config.d.ts +2 -0
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +1 -1
- package/dist/chunks/{base.CQ2VEtuH.js → base.CUDzyU2J.js} +2 -2
- package/dist/chunks/{cac.e7qW4xLT.js → cac.DZC9WjGM.js} +8 -8
- package/dist/chunks/{cli-api.CWDlED-m.js → cli-api.CmJw5Cd_.js} +920 -84
- package/dist/chunks/{config.BTPBhmK5.d.ts → config.BRtC-JeT.d.ts} +6 -0
- package/dist/chunks/{console.BYGVloWk.js → console.CN7AiMGV.js} +16 -7
- package/dist/chunks/{creator.Ot9GlSGw.js → creator.DztqrnyH.js} +1 -1
- package/dist/chunks/{execute.2pr0rHgK.js → execute.BMOaRArH.js} +27 -16
- package/dist/chunks/global.CnI8_G5V.d.ts +133 -0
- package/dist/chunks/{globals.BFncSRNA.js → globals.C5RQxaV3.js} +2 -2
- package/dist/chunks/{index.CkWmZCXU.js → index.BQbxGbG9.js} +1 -1
- package/dist/chunks/{index.BBoOXW-l.js → index.CUcwvygK.js} +5 -5
- package/dist/chunks/{index.DQboAxJm.js → index.D9C26wCk.js} +1 -0
- package/dist/chunks/index.TKSL1HjN.js +2460 -0
- package/dist/chunks/{reporters.DCiyjXOg.d.ts → reporters.Y8BYiXBN.d.ts} +412 -386
- package/dist/chunks/{resolveConfig.C1d7TK-U.js → resolveConfig.CSLLD33d.js} +140 -55
- package/dist/chunks/{rpc.C3q9uwRX.js → rpc.TVf73xOu.js} +0 -1
- package/dist/chunks/{runBaseTests.qNWRkgHj.js → runBaseTests.C0T_TQwH.js} +9 -7
- package/dist/chunks/{setup-common.Cp_bu5q3.js → setup-common.D0zLenuv.js} +1 -1
- package/dist/chunks/{RandomSequencer.C6x84bNN.js → typechecker.BJMkWMXo.js} +84 -108
- package/dist/chunks/{utils.Coei4Wlj.js → utils.DJWL04yX.js} +9 -20
- package/dist/chunks/{vi.S4Fq8wSo.js → vi.Da_PT3Vw.js} +554 -272
- package/dist/chunks/{vite.CRSMFy31.d.ts → vite.CQ0dHgkN.d.ts} +1 -1
- package/dist/chunks/{vm.DGhTouO3.js → vm.DrFVeTXo.js} +4 -4
- package/dist/chunks/{worker.R-PA7DpW.d.ts → worker.B1y96qmv.d.ts} +1 -1
- package/dist/chunks/{worker.XbtCXEXv.d.ts → worker.CIpff8Eg.d.ts} +3 -5
- package/dist/cli.js +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/coverage.d.ts +2 -2
- package/dist/coverage.js +5 -4
- package/dist/execute.d.ts +3 -3
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +18 -119
- package/dist/index.js +2 -2
- package/dist/node.d.ts +12 -9
- package/dist/node.js +25 -24
- package/dist/reporters.d.ts +2 -2
- package/dist/reporters.js +4 -10
- package/dist/runners.d.ts +2 -1
- package/dist/runners.js +9 -16
- package/dist/worker.js +1 -1
- package/dist/workers/forks.js +2 -2
- package/dist/workers/runVmTests.js +8 -6
- package/dist/workers/threads.js +2 -2
- package/dist/workers/vmForks.js +3 -3
- package/dist/workers/vmThreads.js +3 -3
- package/dist/workers.d.ts +3 -3
- package/dist/workers.js +5 -5
- package/package.json +17 -19
- package/dist/chunks/index.CzkCSFCy.js +0 -5455
- package/dist/chunks/types.BOjykUpq.d.ts +0 -27
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as _vitest_runner from '@vitest/runner';
|
|
2
2
|
import { TaskMeta, Suite, File, TaskResultPack, Task, SequenceHooks, SequenceSetupFiles, CancelReason } from '@vitest/runner';
|
|
3
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
|
+
import { TestError, SerializedError, ParsedStack, Arrayable, ErrorWithDiff, Awaitable as Awaitable$1 } from '@vitest/utils';
|
|
5
5
|
import { Writable } from 'node:stream';
|
|
6
6
|
import { TransformResult as TransformResult$1, ServerOptions, DepOptimizationConfig, AliasOptions, UserConfig as UserConfig$1, ConfigEnv, ViteDevServer, ModuleNode } from 'vite';
|
|
7
7
|
import { StackTraceParserOptions } from '@vitest/utils/source-map';
|
|
8
|
-
import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.
|
|
8
|
+
import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.BRtC-JeT.js';
|
|
9
9
|
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
|
10
10
|
import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
|
|
11
11
|
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
@@ -29,7 +29,7 @@ type SerializedTestSpecification = [
|
|
|
29
29
|
|
|
30
30
|
declare class ReportedTaskImplementation {
|
|
31
31
|
/**
|
|
32
|
-
* The project
|
|
32
|
+
* The project associated with the test or suite.
|
|
33
33
|
*/
|
|
34
34
|
readonly project: TestProject;
|
|
35
35
|
/**
|
|
@@ -75,13 +75,13 @@ declare class TestCase extends ReportedTaskImplementation {
|
|
|
75
75
|
*/
|
|
76
76
|
get fullName(): string;
|
|
77
77
|
/**
|
|
78
|
-
* Test results.
|
|
78
|
+
* Test results.
|
|
79
|
+
* - **pending**: Test was collected, but didn't finish running yet.
|
|
80
|
+
* - **passed**: Test passed successfully
|
|
81
|
+
* - **failed**: Test failed to execute
|
|
82
|
+
* - **skipped**: Test was skipped during collection or dynamically with `ctx.skip()`.
|
|
79
83
|
*/
|
|
80
|
-
result(): TestResult
|
|
81
|
-
/**
|
|
82
|
-
* Checks if the test was skipped during collection or dynamically with `ctx.skip()`.
|
|
83
|
-
*/
|
|
84
|
-
skipped(): boolean;
|
|
84
|
+
result(): TestResult;
|
|
85
85
|
/**
|
|
86
86
|
* Custom metadata that was attached to the test during its execution.
|
|
87
87
|
*/
|
|
@@ -110,11 +110,11 @@ declare class TestCollection {
|
|
|
110
110
|
/**
|
|
111
111
|
* Filters all tests that are part of this collection and its children.
|
|
112
112
|
*/
|
|
113
|
-
allTests(state?:
|
|
113
|
+
allTests(state?: TestState): Generator<TestCase, undefined, void>;
|
|
114
114
|
/**
|
|
115
115
|
* Filters only the tests that are part of this collection.
|
|
116
116
|
*/
|
|
117
|
-
tests(state?:
|
|
117
|
+
tests(state?: TestState): Generator<TestCase, undefined, void>;
|
|
118
118
|
/**
|
|
119
119
|
* Filters only the suites that are part of this collection.
|
|
120
120
|
*/
|
|
@@ -126,19 +126,22 @@ declare class TestCollection {
|
|
|
126
126
|
[Symbol.iterator](): Generator<TestSuite | TestCase, undefined, void>;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
type ReportedHookContext = {
|
|
130
|
+
readonly name: 'beforeAll' | 'afterAll';
|
|
131
|
+
readonly entity: TestSuite | TestModule;
|
|
132
|
+
} | {
|
|
133
|
+
readonly name: 'beforeEach' | 'afterEach';
|
|
134
|
+
readonly entity: TestCase;
|
|
135
|
+
};
|
|
129
136
|
declare abstract class SuiteImplementation extends ReportedTaskImplementation {
|
|
130
137
|
/**
|
|
131
138
|
* Collection of suites and tests that are part of this suite.
|
|
132
139
|
*/
|
|
133
140
|
readonly children: TestCollection;
|
|
134
|
-
/**
|
|
135
|
-
* Checks if the suite was skipped during collection.
|
|
136
|
-
*/
|
|
137
|
-
skipped(): boolean;
|
|
138
141
|
/**
|
|
139
142
|
* Errors that happened outside of the test run during collection, like syntax errors.
|
|
140
143
|
*/
|
|
141
|
-
errors():
|
|
144
|
+
errors(): SerializedError[];
|
|
142
145
|
}
|
|
143
146
|
declare class TestSuite extends SuiteImplementation {
|
|
144
147
|
#private;
|
|
@@ -164,6 +167,10 @@ declare class TestSuite extends SuiteImplementation {
|
|
|
164
167
|
* This will also return `false` if suite failed during collection.
|
|
165
168
|
*/
|
|
166
169
|
ok: () => boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Checks the running state of the suite.
|
|
172
|
+
*/
|
|
173
|
+
state(): TestSuiteState;
|
|
167
174
|
/**
|
|
168
175
|
* Full name of the suite including all parent suites separated with `>`.
|
|
169
176
|
*/
|
|
@@ -174,19 +181,19 @@ declare class TestModule extends SuiteImplementation {
|
|
|
174
181
|
readonly type = "module";
|
|
175
182
|
/**
|
|
176
183
|
* This is usually an absolute UNIX file path.
|
|
177
|
-
* It can be a virtual
|
|
178
|
-
* This value corresponds to Vite's
|
|
184
|
+
* It can be a virtual ID if the file is not on the disk.
|
|
185
|
+
* This value corresponds to the ID in the Vite's module graph.
|
|
179
186
|
*/
|
|
180
187
|
readonly moduleId: string;
|
|
188
|
+
/**
|
|
189
|
+
* Checks the running state of the test file.
|
|
190
|
+
*/
|
|
191
|
+
state(): TestModuleState;
|
|
181
192
|
/**
|
|
182
193
|
* Checks if the module has any failed tests.
|
|
183
194
|
* This will also return `false` if module failed during collection.
|
|
184
195
|
*/
|
|
185
196
|
ok: () => boolean;
|
|
186
|
-
/**
|
|
187
|
-
* Checks if the module was skipped and didn't run.
|
|
188
|
-
*/
|
|
189
|
-
skipped: () => boolean;
|
|
190
197
|
/**
|
|
191
198
|
* Useful information about the module like duration, memory usage, etc.
|
|
192
199
|
* If the module was not executed yet, all diagnostic values will return `0`.
|
|
@@ -194,114 +201,319 @@ declare class TestModule extends SuiteImplementation {
|
|
|
194
201
|
diagnostic(): ModuleDiagnostic;
|
|
195
202
|
}
|
|
196
203
|
interface TaskOptions {
|
|
197
|
-
each: boolean | undefined;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
readonly each: boolean | undefined;
|
|
205
|
+
readonly fails: boolean | undefined;
|
|
206
|
+
readonly concurrent: boolean | undefined;
|
|
207
|
+
readonly shuffle: boolean | undefined;
|
|
208
|
+
readonly retry: number | undefined;
|
|
209
|
+
readonly repeats: number | undefined;
|
|
210
|
+
readonly mode: 'run' | 'only' | 'skip' | 'todo';
|
|
211
|
+
}
|
|
212
|
+
type TestSuiteState = 'skipped' | 'pending' | 'failed' | 'passed';
|
|
213
|
+
type TestModuleState = TestSuiteState | 'queued';
|
|
214
|
+
type TestState = TestResult['state'];
|
|
215
|
+
type TestResult = TestResultPassed | TestResultFailed | TestResultSkipped | TestResultPending;
|
|
216
|
+
interface TestResultPending {
|
|
217
|
+
/**
|
|
218
|
+
* The test was collected, but didn't finish running yet.
|
|
219
|
+
*/
|
|
220
|
+
readonly state: 'pending';
|
|
221
|
+
/**
|
|
222
|
+
* Pending tests have no errors.
|
|
223
|
+
*/
|
|
224
|
+
readonly errors: undefined;
|
|
225
|
+
}
|
|
205
226
|
interface TestResultPassed {
|
|
206
227
|
/**
|
|
207
228
|
* The test passed successfully.
|
|
208
229
|
*/
|
|
209
|
-
state: 'passed';
|
|
230
|
+
readonly state: 'passed';
|
|
210
231
|
/**
|
|
211
232
|
* Errors that were thrown during the test execution.
|
|
212
233
|
*
|
|
213
234
|
* **Note**: If test was retried successfully, errors will still be reported.
|
|
214
235
|
*/
|
|
215
|
-
errors: TestError
|
|
236
|
+
readonly errors: ReadonlyArray<TestError> | undefined;
|
|
216
237
|
}
|
|
217
238
|
interface TestResultFailed {
|
|
218
239
|
/**
|
|
219
240
|
* The test failed to execute.
|
|
220
241
|
*/
|
|
221
|
-
state: 'failed';
|
|
242
|
+
readonly state: 'failed';
|
|
222
243
|
/**
|
|
223
244
|
* Errors that were thrown during the test execution.
|
|
224
245
|
*/
|
|
225
|
-
errors: TestError
|
|
246
|
+
readonly errors: ReadonlyArray<TestError>;
|
|
226
247
|
}
|
|
227
248
|
interface TestResultSkipped {
|
|
228
249
|
/**
|
|
229
250
|
* The test was skipped with `only` (on another test), `skip` or `todo` flag.
|
|
230
251
|
* You can see which one was used in the `options.mode` option.
|
|
231
252
|
*/
|
|
232
|
-
state: 'skipped';
|
|
253
|
+
readonly state: 'skipped';
|
|
233
254
|
/**
|
|
234
255
|
* Skipped tests have no errors.
|
|
235
256
|
*/
|
|
236
|
-
errors: undefined;
|
|
257
|
+
readonly errors: undefined;
|
|
237
258
|
/**
|
|
238
259
|
* A custom note passed down to `ctx.skip(note)`.
|
|
239
260
|
*/
|
|
240
|
-
note: string | undefined;
|
|
261
|
+
readonly note: string | undefined;
|
|
241
262
|
}
|
|
242
263
|
interface TestDiagnostic {
|
|
243
264
|
/**
|
|
244
265
|
* If the duration of the test is above `slowTestThreshold`.
|
|
245
266
|
*/
|
|
246
|
-
slow: boolean;
|
|
267
|
+
readonly slow: boolean;
|
|
247
268
|
/**
|
|
248
269
|
* The amount of memory used by the test in bytes.
|
|
249
270
|
* This value is only available if the test was executed with `logHeapUsage` flag.
|
|
250
271
|
*/
|
|
251
|
-
heap: number | undefined;
|
|
272
|
+
readonly heap: number | undefined;
|
|
252
273
|
/**
|
|
253
274
|
* The time it takes to execute the test in ms.
|
|
254
275
|
*/
|
|
255
|
-
duration: number;
|
|
276
|
+
readonly duration: number;
|
|
256
277
|
/**
|
|
257
278
|
* The time in ms when the test started.
|
|
258
279
|
*/
|
|
259
|
-
startTime: number;
|
|
280
|
+
readonly startTime: number;
|
|
260
281
|
/**
|
|
261
282
|
* The amount of times the test was retried.
|
|
262
283
|
*/
|
|
263
|
-
retryCount: number;
|
|
284
|
+
readonly retryCount: number;
|
|
264
285
|
/**
|
|
265
286
|
* The amount of times the test was repeated as configured by `repeats` option.
|
|
266
287
|
* This value can be lower if the test failed during the repeat and no `retry` is configured.
|
|
267
288
|
*/
|
|
268
|
-
repeatCount: number;
|
|
289
|
+
readonly repeatCount: number;
|
|
269
290
|
/**
|
|
270
291
|
* If test passed on a second retry.
|
|
271
292
|
*/
|
|
272
|
-
flaky: boolean;
|
|
293
|
+
readonly flaky: boolean;
|
|
273
294
|
}
|
|
274
295
|
interface ModuleDiagnostic {
|
|
275
296
|
/**
|
|
276
297
|
* The time it takes to import and initiate an environment.
|
|
277
298
|
*/
|
|
278
|
-
environmentSetupDuration: number;
|
|
299
|
+
readonly environmentSetupDuration: number;
|
|
279
300
|
/**
|
|
280
301
|
* The time it takes Vitest to setup test harness (runner, mocks, etc.).
|
|
281
302
|
*/
|
|
282
|
-
prepareDuration: number;
|
|
303
|
+
readonly prepareDuration: number;
|
|
283
304
|
/**
|
|
284
305
|
* The time it takes to import the test module.
|
|
285
306
|
* This includes importing everything in the module and executing suite callbacks.
|
|
286
307
|
*/
|
|
287
|
-
collectDuration: number;
|
|
308
|
+
readonly collectDuration: number;
|
|
288
309
|
/**
|
|
289
310
|
* The time it takes to import the setup module.
|
|
290
311
|
*/
|
|
291
|
-
setupDuration: number;
|
|
312
|
+
readonly setupDuration: number;
|
|
292
313
|
/**
|
|
293
314
|
* Accumulated duration of all tests and hooks in the module.
|
|
294
315
|
*/
|
|
295
|
-
duration: number;
|
|
316
|
+
readonly duration: number;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
type BuiltinPool = 'browser' | 'threads' | 'forks' | 'vmThreads' | 'vmForks' | 'typescript';
|
|
320
|
+
type Pool = BuiltinPool | (string & {});
|
|
321
|
+
interface PoolOptions extends Record<string, unknown> {
|
|
322
|
+
/**
|
|
323
|
+
* Run tests in `node:worker_threads`.
|
|
324
|
+
*
|
|
325
|
+
* Test isolation (when enabled) is done by spawning a new thread for each test file.
|
|
326
|
+
*
|
|
327
|
+
* This pool is used by default.
|
|
328
|
+
*/
|
|
329
|
+
threads?: ThreadsOptions & WorkerContextOptions;
|
|
330
|
+
/**
|
|
331
|
+
* Run tests in `node:child_process` using [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
332
|
+
*
|
|
333
|
+
* Test isolation (when enabled) is done by spawning a new child process for each test file.
|
|
334
|
+
*/
|
|
335
|
+
forks?: ForksOptions & WorkerContextOptions;
|
|
336
|
+
/**
|
|
337
|
+
* Run tests in isolated `node:vm`.
|
|
338
|
+
* Test files are run parallel using `node:worker_threads`.
|
|
339
|
+
*
|
|
340
|
+
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
341
|
+
*/
|
|
342
|
+
vmThreads?: ThreadsOptions & VmOptions;
|
|
343
|
+
/**
|
|
344
|
+
* Run tests in isolated `node:vm`.
|
|
345
|
+
*
|
|
346
|
+
* Test files are run parallel using `node:child_process` [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
|
|
347
|
+
*
|
|
348
|
+
* This makes tests run faster, but VM module is unstable. Your tests might leak memory.
|
|
349
|
+
*/
|
|
350
|
+
vmForks?: ForksOptions & VmOptions;
|
|
351
|
+
}
|
|
352
|
+
interface ResolvedPoolOptions extends PoolOptions {
|
|
353
|
+
threads?: ResolvedThreadsOptions & WorkerContextOptions;
|
|
354
|
+
forks?: ResolvedForksOptions & WorkerContextOptions;
|
|
355
|
+
vmThreads?: ResolvedThreadsOptions & VmOptions;
|
|
356
|
+
vmForks?: ResolvedForksOptions & VmOptions;
|
|
357
|
+
}
|
|
358
|
+
interface ThreadsOptions {
|
|
359
|
+
/** Minimum amount of threads to use */
|
|
360
|
+
minThreads?: number | string;
|
|
361
|
+
/** Maximum amount of threads to use */
|
|
362
|
+
maxThreads?: number | string;
|
|
363
|
+
/**
|
|
364
|
+
* Run tests inside a single thread.
|
|
365
|
+
*
|
|
366
|
+
* @default false
|
|
367
|
+
*/
|
|
368
|
+
singleThread?: boolean;
|
|
369
|
+
/**
|
|
370
|
+
* Use Atomics to synchronize threads
|
|
371
|
+
*
|
|
372
|
+
* This can improve performance in some cases, but might cause segfault in older Node versions.
|
|
373
|
+
*
|
|
374
|
+
* @default false
|
|
375
|
+
*/
|
|
376
|
+
useAtomics?: boolean;
|
|
377
|
+
}
|
|
378
|
+
interface ResolvedThreadsOptions extends ThreadsOptions {
|
|
379
|
+
minThreads?: number;
|
|
380
|
+
maxThreads?: number;
|
|
381
|
+
}
|
|
382
|
+
interface ForksOptions {
|
|
383
|
+
/** Minimum amount of child processes to use */
|
|
384
|
+
minForks?: number | string;
|
|
385
|
+
/** Maximum amount of child processes to use */
|
|
386
|
+
maxForks?: number | string;
|
|
387
|
+
/**
|
|
388
|
+
* Run tests inside a single fork.
|
|
389
|
+
*
|
|
390
|
+
* @default false
|
|
391
|
+
*/
|
|
392
|
+
singleFork?: boolean;
|
|
393
|
+
}
|
|
394
|
+
interface ResolvedForksOptions extends ForksOptions {
|
|
395
|
+
minForks?: number;
|
|
396
|
+
maxForks?: number;
|
|
397
|
+
}
|
|
398
|
+
interface WorkerContextOptions {
|
|
399
|
+
/**
|
|
400
|
+
* Isolate test environment by recycling `worker_threads` or `child_process` after each test
|
|
401
|
+
*
|
|
402
|
+
* @default true
|
|
403
|
+
*/
|
|
404
|
+
isolate?: boolean;
|
|
405
|
+
/**
|
|
406
|
+
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
407
|
+
*
|
|
408
|
+
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
409
|
+
*
|
|
410
|
+
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
411
|
+
*
|
|
412
|
+
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
413
|
+
*
|
|
414
|
+
* @default [] // no execution arguments are passed
|
|
415
|
+
*/
|
|
416
|
+
execArgv?: string[];
|
|
417
|
+
}
|
|
418
|
+
interface VmOptions {
|
|
419
|
+
/**
|
|
420
|
+
* Specifies the memory limit for `worker_thread` or `child_process` before they are recycled.
|
|
421
|
+
* If you see memory leaks, try to tinker this value.
|
|
422
|
+
*/
|
|
423
|
+
memoryLimit?: string | number;
|
|
424
|
+
/** Isolation is always enabled */
|
|
425
|
+
isolate?: true;
|
|
426
|
+
/**
|
|
427
|
+
* Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
|
|
428
|
+
*
|
|
429
|
+
* See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
430
|
+
*
|
|
431
|
+
* Set to `process.execArgv` to pass all arguments of the current process.
|
|
432
|
+
*
|
|
433
|
+
* Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
|
|
434
|
+
*
|
|
435
|
+
* @default [] // no execution arguments are passed
|
|
436
|
+
*/
|
|
437
|
+
execArgv?: string[];
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
declare class TestSpecification {
|
|
441
|
+
/**
|
|
442
|
+
* @deprecated use `project` instead
|
|
443
|
+
*/
|
|
444
|
+
readonly 0: TestProject;
|
|
445
|
+
/**
|
|
446
|
+
* @deprecated use `moduleId` instead
|
|
447
|
+
*/
|
|
448
|
+
readonly 1: string;
|
|
449
|
+
/**
|
|
450
|
+
* @deprecated use `pool` instead
|
|
451
|
+
*/
|
|
452
|
+
readonly 2: {
|
|
453
|
+
pool: Pool;
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* The task ID associated with the test module.
|
|
457
|
+
*/
|
|
458
|
+
readonly taskId: string;
|
|
459
|
+
/**
|
|
460
|
+
* The test project that the module belongs to.
|
|
461
|
+
*/
|
|
462
|
+
readonly project: TestProject;
|
|
463
|
+
/**
|
|
464
|
+
* The ID of the module in the Vite module graph. It is usually an absolute file path.
|
|
465
|
+
*/
|
|
466
|
+
readonly moduleId: string;
|
|
467
|
+
/**
|
|
468
|
+
* The current test pool. It's possible to have multiple pools in a single test project with `poolMatchGlob` and `typecheck.enabled`.
|
|
469
|
+
* @experimental In Vitest 4, the project will only support a single pool and this property will be removed.
|
|
470
|
+
*/
|
|
471
|
+
readonly pool: Pool;
|
|
472
|
+
/**
|
|
473
|
+
* Line numbers of the test locations to run.
|
|
474
|
+
*/
|
|
475
|
+
readonly testLines: number[] | undefined;
|
|
476
|
+
constructor(project: TestProject, moduleId: string, pool: Pool, testLines?: number[] | undefined);
|
|
477
|
+
/**
|
|
478
|
+
* Test module associated with the specification.
|
|
479
|
+
*/
|
|
480
|
+
get testModule(): TestModule | undefined;
|
|
481
|
+
toJSON(): SerializedTestSpecification;
|
|
482
|
+
/**
|
|
483
|
+
* for backwards compatibility
|
|
484
|
+
* @deprecated
|
|
485
|
+
*/
|
|
486
|
+
[Symbol.iterator](): Generator<string | TestProject, void, unknown>;
|
|
296
487
|
}
|
|
297
488
|
|
|
489
|
+
type TestRunEndReason = 'passed' | 'interrupted' | 'failed';
|
|
298
490
|
interface Reporter {
|
|
299
|
-
onInit?: (
|
|
491
|
+
onInit?: (vitest: Vitest) => void;
|
|
492
|
+
/**
|
|
493
|
+
* Called when the project initiated the browser instance.
|
|
494
|
+
* project.browser will always be defined.
|
|
495
|
+
* @experimental
|
|
496
|
+
*/
|
|
497
|
+
onBrowserInit?: (project: TestProject) => Awaitable<void>;
|
|
498
|
+
/**
|
|
499
|
+
* @deprecated use `onTestRunStart` instead
|
|
500
|
+
*/
|
|
300
501
|
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
502
|
+
/**
|
|
503
|
+
* @deprecated use `onTestRunStart` instead
|
|
504
|
+
*/
|
|
301
505
|
onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable<void>;
|
|
302
|
-
|
|
303
|
-
|
|
506
|
+
/**
|
|
507
|
+
* @deprecated use `onTestModuleCollected` instead
|
|
508
|
+
*/
|
|
509
|
+
onCollected?: (files: File[]) => Awaitable<void>;
|
|
510
|
+
/**
|
|
511
|
+
* @deprecated use `onTestRunEnd` instead
|
|
512
|
+
*/
|
|
304
513
|
onFinished?: (files: File[], errors: unknown[], coverage?: unknown) => Awaitable<void>;
|
|
514
|
+
/**
|
|
515
|
+
* @deprecated use `onTestModuleQueued`, `onTestModuleStart`, `onTestModuleEnd`, `onTestCaseReady`, `onTestCaseResult` instead
|
|
516
|
+
*/
|
|
305
517
|
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
306
518
|
onTestRemoved?: (trigger?: string) => Awaitable<void>;
|
|
307
519
|
onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
@@ -309,6 +521,59 @@ interface Reporter {
|
|
|
309
521
|
onServerRestart?: (reason?: string) => Awaitable<void>;
|
|
310
522
|
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
311
523
|
onProcessTimeout?: () => Awaitable<void>;
|
|
524
|
+
/**
|
|
525
|
+
* Called when the new test run starts.
|
|
526
|
+
*/
|
|
527
|
+
onTestRunStart?: (specifications: ReadonlyArray<TestSpecification>) => Awaitable<void>;
|
|
528
|
+
/**
|
|
529
|
+
* Called when the test run is finished.
|
|
530
|
+
*/
|
|
531
|
+
onTestRunEnd?: (testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason) => Awaitable<void>;
|
|
532
|
+
/**
|
|
533
|
+
* Called when the module is enqueued for testing. The file itself is not loaded yet.
|
|
534
|
+
*/
|
|
535
|
+
onTestModuleQueued?: (testModule: TestModule) => Awaitable<void>;
|
|
536
|
+
/**
|
|
537
|
+
* Called when the test file is loaded and the module is ready to run tests.
|
|
538
|
+
*/
|
|
539
|
+
onTestModuleCollected?: (testModule: TestModule) => Awaitable<void>;
|
|
540
|
+
/**
|
|
541
|
+
* Called when starting to run tests of the test file
|
|
542
|
+
*/
|
|
543
|
+
onTestModuleStart?: (testModule: TestModule) => Awaitable<void>;
|
|
544
|
+
/**
|
|
545
|
+
* Called when all tests of the test file have finished running.
|
|
546
|
+
*/
|
|
547
|
+
onTestModuleEnd?: (testModule: TestModule) => Awaitable<void>;
|
|
548
|
+
/**
|
|
549
|
+
* Called when test case is ready to run.
|
|
550
|
+
* Called before the `beforeEach` hooks for the test are run.
|
|
551
|
+
*/
|
|
552
|
+
onTestCaseReady?: (testCase: TestCase) => Awaitable<void>;
|
|
553
|
+
/**
|
|
554
|
+
* Called after the test and its hooks are finished running.
|
|
555
|
+
* The `result()` cannot be `pending`.
|
|
556
|
+
*/
|
|
557
|
+
onTestCaseResult?: (testCase: TestCase) => Awaitable<void>;
|
|
558
|
+
/**
|
|
559
|
+
* Called when test suite is ready to run.
|
|
560
|
+
* Called before the `beforeAll` hooks for the test are run.
|
|
561
|
+
*/
|
|
562
|
+
onTestSuiteReady?: (testSuite: TestSuite) => Awaitable<void>;
|
|
563
|
+
/**
|
|
564
|
+
* Called after the test suite and its hooks are finished running.
|
|
565
|
+
* The `state` cannot be `pending`.
|
|
566
|
+
*/
|
|
567
|
+
onTestSuiteResult?: (testSuite: TestSuite) => Awaitable<void>;
|
|
568
|
+
/**
|
|
569
|
+
* Called before the hook starts to run.
|
|
570
|
+
*/
|
|
571
|
+
onHookStart?: (hook: ReportedHookContext) => Awaitable<void>;
|
|
572
|
+
/**
|
|
573
|
+
* Called after the hook finished running.
|
|
574
|
+
*/
|
|
575
|
+
onHookEnd?: (hook: ReportedHookContext) => Awaitable<void>;
|
|
576
|
+
onCoverage?: (coverage: unknown) => Awaitable<void>;
|
|
312
577
|
}
|
|
313
578
|
|
|
314
579
|
interface BaseOptions {
|
|
@@ -332,6 +597,9 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
332
597
|
relative(path: string): string;
|
|
333
598
|
onFinished(files?: File[], errors?: unknown[]): void;
|
|
334
599
|
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
600
|
+
/**
|
|
601
|
+
* Callback invoked with a single `Task` from `onTaskUpdate`
|
|
602
|
+
*/
|
|
335
603
|
protected printTask(task: Task): void;
|
|
336
604
|
private getDurationPrefix;
|
|
337
605
|
onWatcherStart(files?: File[], errors?: unknown[]): void;
|
|
@@ -365,12 +633,17 @@ declare class DefaultReporter extends BaseReporter {
|
|
|
365
633
|
private options;
|
|
366
634
|
private summary?;
|
|
367
635
|
constructor(options?: DefaultReporterOptions);
|
|
636
|
+
onTestRunStart(specifications: ReadonlyArray<TestSpecification>): void;
|
|
368
637
|
onTestModuleQueued(file: TestModule): void;
|
|
638
|
+
onTestModuleCollected(module: TestModule): void;
|
|
639
|
+
onTestModuleEnd(module: TestModule): void;
|
|
640
|
+
onTestCaseReady(test: TestCase): void;
|
|
641
|
+
onTestCaseResult(test: TestCase): void;
|
|
642
|
+
onHookStart(hook: ReportedHookContext): void;
|
|
643
|
+
onHookEnd(hook: ReportedHookContext): void;
|
|
369
644
|
onInit(ctx: Vitest): void;
|
|
370
645
|
onPathsCollected(paths?: string[]): void;
|
|
371
|
-
|
|
372
|
-
onWatcherRerun(files: string[], trigger?: string): void;
|
|
373
|
-
onFinished(files?: File[], errors?: unknown[]): void;
|
|
646
|
+
onTestRunEnd(): void;
|
|
374
647
|
}
|
|
375
648
|
|
|
376
649
|
interface HTMLOptions {
|
|
@@ -384,11 +657,18 @@ declare class BasicReporter extends BaseReporter {
|
|
|
384
657
|
}
|
|
385
658
|
|
|
386
659
|
declare class DotReporter extends BaseReporter {
|
|
387
|
-
private
|
|
660
|
+
private renderer?;
|
|
661
|
+
private tests;
|
|
662
|
+
private finishedTests;
|
|
388
663
|
onInit(ctx: Vitest): void;
|
|
389
|
-
|
|
664
|
+
printTask(task: Task): void;
|
|
390
665
|
onWatcherRerun(files: string[], trigger?: string): void;
|
|
391
666
|
onFinished(files?: File[], errors?: unknown[]): void;
|
|
667
|
+
onTestModuleCollected(module: TestModule): void;
|
|
668
|
+
onTestCaseReady(test: TestCase): void;
|
|
669
|
+
onTestCaseResult(test: TestCase): void;
|
|
670
|
+
onTestModuleEnd(): void;
|
|
671
|
+
private createSummary;
|
|
392
672
|
}
|
|
393
673
|
|
|
394
674
|
declare class GithubActionsReporter implements Reporter {
|
|
@@ -624,179 +904,41 @@ declare class TapFlatReporter extends TapReporter {
|
|
|
624
904
|
declare class VerboseReporter extends DefaultReporter {
|
|
625
905
|
protected verbose: boolean;
|
|
626
906
|
renderSucceed: boolean;
|
|
627
|
-
|
|
907
|
+
printTask(task: Task): void;
|
|
628
908
|
}
|
|
629
909
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
stacks: ParsedStack[];
|
|
633
|
-
name: string;
|
|
634
|
-
constructor(message: string, stacks: ParsedStack[]);
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
interface PrintErrorResult {
|
|
638
|
-
nearest?: ParsedStack;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
interface Options {
|
|
642
|
-
/**
|
|
643
|
-
Show the cursor. This can be useful when a CLI accepts input from a user.
|
|
644
|
-
|
|
645
|
-
@example
|
|
646
|
-
```
|
|
647
|
-
import {createLogUpdate} from 'log-update';
|
|
648
|
-
|
|
649
|
-
// Write output but don't hide the cursor
|
|
650
|
-
const log = createLogUpdate(process.stdout, {
|
|
651
|
-
showCursor: true
|
|
652
|
-
});
|
|
653
|
-
```
|
|
654
|
-
*/
|
|
655
|
-
readonly showCursor?: boolean;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
type LogUpdateMethods = {
|
|
659
|
-
/**
|
|
660
|
-
Clear the logged output.
|
|
661
|
-
*/
|
|
662
|
-
clear(): void;
|
|
663
|
-
|
|
664
|
-
/**
|
|
665
|
-
Persist the logged output. Useful if you want to start a new log session below the current one.
|
|
666
|
-
*/
|
|
667
|
-
done(): void;
|
|
910
|
+
type FormattedBenchmarkResult = BenchmarkResult & {
|
|
911
|
+
id: string;
|
|
668
912
|
};
|
|
669
913
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
@example
|
|
676
|
-
```
|
|
677
|
-
import logUpdate from 'log-update';
|
|
678
|
-
|
|
679
|
-
const frames = ['-', '\\', '|', '/'];
|
|
680
|
-
let index = 0;
|
|
681
|
-
|
|
682
|
-
setInterval(() => {
|
|
683
|
-
const frame = frames[index = ++index % frames.length];
|
|
684
|
-
|
|
685
|
-
logUpdate(
|
|
686
|
-
`
|
|
687
|
-
♥♥
|
|
688
|
-
${frame} unicorns ${frame}
|
|
689
|
-
♥♥
|
|
690
|
-
`
|
|
691
|
-
);
|
|
692
|
-
}, 80);
|
|
693
|
-
```
|
|
694
|
-
*/
|
|
695
|
-
declare const logUpdate: ((...text: string[]) => void) & LogUpdateMethods;
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
/**
|
|
699
|
-
Get a `logUpdate` method that logs to the specified stream.
|
|
700
|
-
|
|
701
|
-
@param stream - The stream to log to.
|
|
702
|
-
|
|
703
|
-
@example
|
|
704
|
-
```
|
|
705
|
-
import {createLogUpdate} from 'log-update';
|
|
706
|
-
|
|
707
|
-
// Write output but don't hide the cursor
|
|
708
|
-
const log = createLogUpdate(process.stdout);
|
|
709
|
-
```
|
|
710
|
-
*/
|
|
711
|
-
declare function createLogUpdate(
|
|
712
|
-
stream: NodeJS.WritableStream,
|
|
713
|
-
options?: Options
|
|
714
|
-
): typeof logUpdate;
|
|
715
|
-
|
|
716
|
-
interface ErrorOptions {
|
|
717
|
-
type?: string;
|
|
718
|
-
fullStack?: boolean;
|
|
719
|
-
project?: TestProject;
|
|
720
|
-
verbose?: boolean;
|
|
721
|
-
screenshotPaths?: string[];
|
|
722
|
-
task?: Task;
|
|
723
|
-
showCodeFrame?: boolean;
|
|
724
|
-
}
|
|
725
|
-
declare class Logger {
|
|
726
|
-
ctx: Vitest;
|
|
727
|
-
outputStream: NodeJS.WriteStream | Writable;
|
|
728
|
-
errorStream: NodeJS.WriteStream | Writable;
|
|
729
|
-
logUpdate: ReturnType<typeof createLogUpdate>;
|
|
730
|
-
private _clearScreenPending;
|
|
731
|
-
private _highlights;
|
|
732
|
-
console: Console;
|
|
733
|
-
constructor(ctx: Vitest, outputStream?: NodeJS.WriteStream | Writable, errorStream?: NodeJS.WriteStream | Writable);
|
|
734
|
-
log(...args: any[]): void;
|
|
735
|
-
error(...args: any[]): void;
|
|
736
|
-
warn(...args: any[]): void;
|
|
737
|
-
clearFullScreen(message?: string): void;
|
|
738
|
-
clearScreen(message: string, force?: boolean): void;
|
|
739
|
-
private _clearScreen;
|
|
740
|
-
printError(err: unknown, options?: ErrorOptions): PrintErrorResult | undefined;
|
|
741
|
-
clearHighlightCache(filename?: string): void;
|
|
742
|
-
highlight(filename: string, source: string): string;
|
|
743
|
-
printNoTestFound(filters?: string[]): void;
|
|
744
|
-
printBanner(): void;
|
|
745
|
-
printBrowserBanner(project: TestProject): void;
|
|
746
|
-
printUnhandledErrors(errors: unknown[]): void;
|
|
747
|
-
printSourceTypeErrors(errors: TypeCheckError[]): void;
|
|
748
|
-
private registerUnhandledRejection;
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
interface TableRendererOptions {
|
|
752
|
-
renderSucceed?: boolean;
|
|
753
|
-
logger: Logger;
|
|
914
|
+
declare function renderTable(options: {
|
|
915
|
+
tasks: Task[];
|
|
916
|
+
level: number;
|
|
917
|
+
shallow?: boolean;
|
|
754
918
|
showHeap: boolean;
|
|
919
|
+
columns: number;
|
|
755
920
|
slowTestThreshold: number;
|
|
756
|
-
compare?:
|
|
757
|
-
}
|
|
758
|
-
declare function createTableRenderer(_tasks: Task[], options: TableRendererOptions): {
|
|
759
|
-
start(): /*elided*/ any;
|
|
760
|
-
update(_tasks: Task[]): /*elided*/ any;
|
|
761
|
-
stop(): /*elided*/ any;
|
|
762
|
-
clear(): void;
|
|
763
|
-
};
|
|
921
|
+
compare?: Record<Task['id'], FormattedBenchmarkResult>;
|
|
922
|
+
}): string;
|
|
764
923
|
|
|
765
|
-
declare class
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
onTestRemoved(trigger?: string): void;
|
|
769
|
-
onCollected(): Promise<void>;
|
|
924
|
+
declare class BenchmarkReporter extends DefaultReporter {
|
|
925
|
+
compare?: Parameters<typeof renderTable>[0]['compare'];
|
|
926
|
+
onInit(ctx: Vitest): Promise<void>;
|
|
770
927
|
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
stopListRender(): void;
|
|
774
|
-
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
775
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
928
|
+
printTask(task: Task): void;
|
|
929
|
+
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
776
930
|
}
|
|
777
|
-
|
|
778
|
-
|
|
931
|
+
|
|
932
|
+
declare class VerboseBenchmarkReporter extends BenchmarkReporter {
|
|
933
|
+
protected verbose: boolean;
|
|
779
934
|
}
|
|
780
|
-
type FormattedBenchmarkResult = BenchmarkResult & {
|
|
781
|
-
id: string;
|
|
782
|
-
};
|
|
783
935
|
|
|
784
936
|
declare const BenchmarkReportsMap: {
|
|
785
|
-
default: typeof
|
|
786
|
-
verbose: typeof
|
|
937
|
+
default: typeof BenchmarkReporter;
|
|
938
|
+
verbose: typeof VerboseBenchmarkReporter;
|
|
787
939
|
};
|
|
788
940
|
type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
|
|
789
941
|
|
|
790
|
-
/**
|
|
791
|
-
* @deprecated Use `TestModule` instead
|
|
792
|
-
*/
|
|
793
|
-
declare const TestFile: typeof TestModule;
|
|
794
|
-
|
|
795
|
-
/**
|
|
796
|
-
* @deprecated Use `ModuleDiagnostic` instead
|
|
797
|
-
*/
|
|
798
|
-
type FileDiagnostic = ModuleDiagnostic;
|
|
799
|
-
|
|
800
942
|
declare const ReportersMap: {
|
|
801
943
|
default: typeof DefaultReporter;
|
|
802
944
|
basic: typeof BasicReporter;
|
|
@@ -825,169 +967,53 @@ interface BuiltinReporterOptions {
|
|
|
825
967
|
'html': HTMLOptions;
|
|
826
968
|
}
|
|
827
969
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
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;
|
|
970
|
+
declare class TypeCheckError extends Error {
|
|
971
|
+
message: string;
|
|
972
|
+
stacks: ParsedStack[];
|
|
973
|
+
name: string;
|
|
974
|
+
constructor(message: string, stacks: ParsedStack[]);
|
|
908
975
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
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[];
|
|
976
|
+
|
|
977
|
+
interface ErrorOptions {
|
|
978
|
+
type?: string;
|
|
979
|
+
fullStack?: boolean;
|
|
980
|
+
project?: TestProject;
|
|
981
|
+
verbose?: boolean;
|
|
982
|
+
screenshotPaths?: string[];
|
|
983
|
+
task?: Task;
|
|
984
|
+
showCodeFrame?: boolean;
|
|
928
985
|
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
986
|
+
type Listener = () => void;
|
|
987
|
+
declare class Logger {
|
|
988
|
+
ctx: Vitest;
|
|
989
|
+
outputStream: NodeJS.WriteStream | Writable;
|
|
990
|
+
errorStream: NodeJS.WriteStream | Writable;
|
|
991
|
+
private _clearScreenPending;
|
|
992
|
+
private _highlights;
|
|
993
|
+
private cleanupListeners;
|
|
994
|
+
console: Console;
|
|
995
|
+
constructor(ctx: Vitest, outputStream?: NodeJS.WriteStream | Writable, errorStream?: NodeJS.WriteStream | Writable);
|
|
996
|
+
log(...args: any[]): void;
|
|
997
|
+
error(...args: any[]): void;
|
|
998
|
+
warn(...args: any[]): void;
|
|
999
|
+
clearFullScreen(message?: string): void;
|
|
1000
|
+
clearScreen(message: string, force?: boolean): void;
|
|
1001
|
+
private _clearScreen;
|
|
1002
|
+
printError(err: unknown, options?: ErrorOptions): void;
|
|
1003
|
+
clearHighlightCache(filename?: string): void;
|
|
1004
|
+
highlight(filename: string, source: string): string;
|
|
1005
|
+
printNoTestFound(filters?: string[]): void;
|
|
1006
|
+
printBanner(): void;
|
|
1007
|
+
printBrowserBanner(project: TestProject): void;
|
|
1008
|
+
printUnhandledErrors(errors: unknown[]): void;
|
|
1009
|
+
printSourceTypeErrors(errors: TypeCheckError[]): void;
|
|
1010
|
+
getColumns(): number;
|
|
1011
|
+
onTerminalCleanup(listener: Listener): void;
|
|
1012
|
+
private addCleanupListeners;
|
|
1013
|
+
private registerUnhandledRejection;
|
|
949
1014
|
}
|
|
950
1015
|
|
|
951
|
-
|
|
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
|
-
}
|
|
1016
|
+
type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
|
|
991
1017
|
|
|
992
1018
|
interface TestSequencer {
|
|
993
1019
|
/**
|
|
@@ -2021,7 +2047,7 @@ interface InlineConfig {
|
|
|
2021
2047
|
/**
|
|
2022
2048
|
* By default, Vitest automatically intercepts console logging during tests for extra formatting of test file, test title, etc...
|
|
2023
2049
|
* This is also required for console log preview on Vitest UI.
|
|
2024
|
-
* However, disabling such interception might help when you want to debug a code with normal
|
|
2050
|
+
* However, disabling such interception might help when you want to debug a code with normal synchronous terminal console logging.
|
|
2025
2051
|
*
|
|
2026
2052
|
* This option has no effect on browser pool since Vitest preserves original logging on browser devtools.
|
|
2027
2053
|
*
|
|
@@ -2043,7 +2069,7 @@ interface InlineConfig {
|
|
|
2043
2069
|
}
|
|
2044
2070
|
interface TypecheckConfig {
|
|
2045
2071
|
/**
|
|
2046
|
-
* Run typechecking tests
|
|
2072
|
+
* Run typechecking tests alongside regular tests.
|
|
2047
2073
|
*/
|
|
2048
2074
|
enabled?: boolean;
|
|
2049
2075
|
/**
|
|
@@ -2272,7 +2298,7 @@ interface BrowserConfigOptions {
|
|
|
2272
2298
|
enabled?: boolean;
|
|
2273
2299
|
/**
|
|
2274
2300
|
* Name of the browser
|
|
2275
|
-
* @deprecated use `
|
|
2301
|
+
* @deprecated use `instances` instead. if both are defined, this will filter `instances` by name.
|
|
2276
2302
|
*/
|
|
2277
2303
|
name?: string;
|
|
2278
2304
|
/**
|
|
@@ -2294,7 +2320,7 @@ interface BrowserConfigOptions {
|
|
|
2294
2320
|
*
|
|
2295
2321
|
* @example
|
|
2296
2322
|
* { playwright: { launch: { devtools: true } }
|
|
2297
|
-
* @deprecated use `
|
|
2323
|
+
* @deprecated use `instances` instead
|
|
2298
2324
|
*/
|
|
2299
2325
|
providerOptions?: BrowserProviderOptions;
|
|
2300
2326
|
/**
|
|
@@ -2505,7 +2531,6 @@ declare class TestProject {
|
|
|
2505
2531
|
private typecheckFilesList;
|
|
2506
2532
|
private _globalSetups?;
|
|
2507
2533
|
private _provided;
|
|
2508
|
-
private _vite?;
|
|
2509
2534
|
constructor(
|
|
2510
2535
|
/** @deprecated */
|
|
2511
2536
|
path: string | number, vitest: Vitest, options?: InitializeProjectOptions | undefined);
|
|
@@ -2593,6 +2618,8 @@ declare class TestProject {
|
|
|
2593
2618
|
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
2594
2619
|
private isInSourceTestCode;
|
|
2595
2620
|
private filterFiles;
|
|
2621
|
+
private _parentBrowser?;
|
|
2622
|
+
private _parent?;
|
|
2596
2623
|
/**
|
|
2597
2624
|
* Closes the project and all associated resources. This can only be called once; the closing promise is cached until the server restarts.
|
|
2598
2625
|
* If the resources are needed again, create a new project.
|
|
@@ -2607,7 +2634,7 @@ declare class TestProject {
|
|
|
2607
2634
|
getName(): string;
|
|
2608
2635
|
/** @deprecated internal */
|
|
2609
2636
|
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
2610
|
-
private
|
|
2637
|
+
private _serializeOverriddenConfig;
|
|
2611
2638
|
private clearTmpDir;
|
|
2612
2639
|
/** @deprecated */
|
|
2613
2640
|
initBrowserProvider(): Promise<void>;
|
|
@@ -2620,7 +2647,6 @@ interface SerializedTestProject {
|
|
|
2620
2647
|
}
|
|
2621
2648
|
interface InitializeProjectOptions extends UserWorkspaceConfig {
|
|
2622
2649
|
configFile: string | false;
|
|
2623
|
-
extends?: string;
|
|
2624
2650
|
}
|
|
2625
2651
|
|
|
2626
2652
|
/**
|
|
@@ -2710,7 +2736,7 @@ declare class StateManager {
|
|
|
2710
2736
|
taskFileMap: WeakMap<Task, File>;
|
|
2711
2737
|
errorsSet: Set<unknown>;
|
|
2712
2738
|
processTimeoutCauses: Set<string>;
|
|
2713
|
-
reportedTasksMap: WeakMap<Task,
|
|
2739
|
+
reportedTasksMap: WeakMap<Task, TestCase | TestSuite | TestModule>;
|
|
2714
2740
|
catchError(err: unknown, type: string): void;
|
|
2715
2741
|
clearErrors(): void;
|
|
2716
2742
|
getUnhandledErrors(): unknown[];
|
|
@@ -2728,7 +2754,7 @@ declare class StateManager {
|
|
|
2728
2754
|
collectFiles(project: TestProject, files?: File[]): void;
|
|
2729
2755
|
clearFiles(project: TestProject, paths?: string[]): void;
|
|
2730
2756
|
updateId(task: Task, project: TestProject): void;
|
|
2731
|
-
getReportedEntity(task: Task):
|
|
2757
|
+
getReportedEntity(task: Task): TestCase | TestSuite | TestModule | undefined;
|
|
2732
2758
|
updateTasks(packs: TaskResultPack[]): void;
|
|
2733
2759
|
updateUserLog(log: UserConsoleLog): void;
|
|
2734
2760
|
getCountOfFailedTests(): number;
|
|
@@ -2885,14 +2911,14 @@ declare class Vitest {
|
|
|
2885
2911
|
/** @deprecated */
|
|
2886
2912
|
getFileWorkspaceSpecs(file: string): WorkspaceSpec[];
|
|
2887
2913
|
/**
|
|
2888
|
-
* Get test specifications
|
|
2914
|
+
* Get test specifications associated with the given module. If module is not a test file, an empty array is returned.
|
|
2889
2915
|
*
|
|
2890
2916
|
* **Note:** this method relies on a cache generated by `globTestSpecifications`. If the file was not processed yet, use `project.matchesGlobPattern` instead.
|
|
2891
2917
|
* @param moduleId The module ID to get test specifications for.
|
|
2892
2918
|
*/
|
|
2893
2919
|
getModuleSpecifications(moduleId: string): TestSpecification[];
|
|
2894
2920
|
/**
|
|
2895
|
-
* Vitest automatically caches test specifications for each file. This method clears the cache for the given file or the whole cache
|
|
2921
|
+
* Vitest automatically caches test specifications for each file. This method clears the cache for the given file or the whole cache altogether.
|
|
2896
2922
|
*/
|
|
2897
2923
|
clearSpecificationsCache(moduleId?: string): void;
|
|
2898
2924
|
/**
|
|
@@ -3005,4 +3031,4 @@ declare class Vitest {
|
|
|
3005
3031
|
type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
|
|
3006
3032
|
type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
|
|
3007
3033
|
|
|
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
|
|
3034
|
+
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 TestModuleState as a4, type TestResult as a5, type TestResultFailed as a6, type TestResultPassed as a7, type TestResultSkipped as a8, type TestState as a9, BenchmarkReportsMap as aA, DefaultReporter as aB, DotReporter as aC, GithubActionsReporter as aD, HangingProcessReporter as aE, JsonReporter as aF, JUnitReporter as aG, ReportersMap as aH, TapFlatReporter as aI, TapReporter as aJ, VerboseBenchmarkReporter as aK, VerboseReporter as aL, BaseReporter as aM, type BenchmarkBuiltinReporters as aN, type BuiltinReporterOptions as aO, type BuiltinReporters as aP, type JsonAssertionResult as aQ, type JsonTestResult as aR, type JsonTestResults as aS, TestSuite as aa, type TestSuiteState as ab, type TestSequencerConstructor as ac, type BrowserBuiltinProvider as ad, type BrowserCommand as ae, type BrowserCommandContext as af, type BrowserInstanceOption as ag, type BrowserOrchestrator as ah, type BrowserProvider as ai, type BrowserProviderInitializationOptions as aj, type BrowserProviderModule as ak, type BrowserProviderOptions as al, type BrowserServerState as am, type BrowserServerStateSession as an, type CDPSession as ao, type ParentProjectBrowser as ap, type ProjectBrowser as aq, type ResolvedBrowserOptions as ar, type ResolvedProjectConfig as as, type ResolveSnapshotPathHandler as at, type ResolveSnapshotPathHandlerContext as au, type TestRunResult as av, type ReportedHookContext as aw, type TestRunEndReason as ax, BasicReporter as ay, BenchmarkReporter 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 };
|