vitest 4.1.12 → 5.1.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 +192 -10
- package/browser/context.d.ts +7 -1
- package/browser/context.js +5 -5
- package/config.d.ts +0 -2
- package/dist/browser.d.ts +52 -21
- package/dist/browser.js +12 -13
- package/dist/chunks/{acorn.B2iPLyUM.js → acorn.C1kjbUFw.js} +30 -30
- package/dist/chunks/{base.B6Opl8PE.js → base.Cof-UHJf.js} +81 -52
- package/dist/chunks/{browser.d.BcoexmFG.d.ts → browser.d.C7tWgUvw.d.ts} +17 -14
- package/dist/chunks/{cac.DzDtg8hz.js → cac.BYbt0aJp.js} +143 -87
- package/dist/chunks/{cli-api.B0Pz1_R7.js → cli-api.COfZo8lK.js} +7160 -7189
- package/dist/chunks/config.d.B3YV4t0O.d.ts +3873 -0
- package/dist/chunks/{console.3WNpx0tS.js → console.CQZ877Hi.js} +69 -63
- package/dist/chunks/{constants.CPYnjOGj.js → constants.DLYM6cZY.js} +2 -2
- package/dist/chunks/coverage.9iqXE2gN.js +26 -0
- package/dist/chunks/{coverage.CTzCuANN.js → coverage.jGCktcGP.js} +7 -2
- package/dist/chunks/{creator.DgVhQm5q.js → creator.DHWmytIK.js} +65 -28
- package/dist/chunks/{defaults.9aQKnqFk.js → defaults.B1FCaFfh.js} +16 -9
- package/dist/chunks/display.BlTmubjj.js +194 -0
- package/dist/chunks/doctor.B-oPbwps.js +465 -0
- package/dist/chunks/{env.D4Lgay0q.js → env.BKKtU2WC.js} +2 -1
- package/dist/chunks/{environment.d.CrsxCzP1.d.ts → environment.d.BFQtFKdZ.d.ts} +9 -1
- package/dist/chunks/globals.ZKtKSkEf.js +29 -0
- package/dist/chunks/index.Bi0NXYPf.js +1708 -0
- package/dist/chunks/{index.CMESou6r.js → index.BoyTG_B7.js} +82 -81
- package/dist/chunks/index.CZzC1gGg.js +8501 -0
- package/dist/chunks/index.D0heQG4v.js +1318 -0
- package/dist/chunks/index.Di8au7q4.js +15665 -0
- package/dist/chunks/{index.Chj8NDwU.js → index.DmDMHCg8.js} +6 -12
- package/dist/chunks/{index.DXx9Dtk7.js → index.w_oBZ9N8.js} +25 -12
- package/dist/chunks/{init-forks.H5ZuobOQ.js → init-forks.BaDXQSD8.js} +7 -10
- package/dist/chunks/{init-threads.6kl1khcL.js → init-threads.ZX_Vov0z.js} +1 -1
- package/dist/chunks/{init.k9zZ9sLh.js → init.CO4AB7HZ.js} +113 -38
- package/dist/chunks/module-dependencies._2Eei3FO.js +71 -0
- package/dist/chunks/{native.DPzPHdi5.js → native.upB-V0CK.js} +50 -37
- package/dist/chunks/{nativeModuleMocker.BkNfQMkH.js → nativeModuleMocker.Dh5azSB4.js} +48 -19
- package/dist/chunks/{index.BCY_7LL2.js → nativeModuleRunner.9xPIMzi7.js} +110 -42
- package/dist/chunks/node.B9mkVmLH.js +47 -0
- package/dist/chunks/offset.Dy-5Fdfn.js +24 -0
- package/dist/chunks/pathe.M-eThtNZ.zq3TM4NT.js +492 -0
- package/dist/chunks/{reporters.d.DtoKVV2s.d.ts → plugin.d.LRFSN46m.d.ts} +2573 -1453
- package/dist/chunks/plugins.DPQHVT0p.js +37 -0
- package/dist/chunks/rawSnapshot.DqSiqIEx.js +356 -0
- package/dist/chunks/resolver.BzpmeQeT.js +48 -0
- package/dist/chunks/rpc.Uhkwr2NM.js +93 -0
- package/dist/chunks/rpc.d.3FOhdFx8.d.ts +75 -0
- package/dist/chunks/run.CjdgFZiW.js +4231 -0
- package/dist/chunks/setup-common.CqAQCXzx.js +36 -0
- package/dist/chunks/source-map.DakdQc29.js +1788 -0
- package/dist/chunks/source-map.d.BkG8YK_3.d.ts +89 -0
- package/dist/chunks/spy.DDMXghXv.js +509 -0
- package/dist/chunks/task-utils.d.D-gFPNFi.d.ts +144 -0
- package/dist/chunks/tinyrainbow.Do8I1XRG.js +88 -0
- package/dist/chunks/{utils.BS4fH3nR.js → utils.BBk_icFG.js} +50 -52
- package/dist/chunks/{utils.BX5Fg8C4.js → utils.DYj33du9.js} +1 -17
- package/dist/chunks/vm.b4MbCAJQ.js +1329 -0
- package/dist/chunks/{worker.d.ZpHpO4yb.d.ts → worker.d.CyJRpyfZ.d.ts} +34 -19
- package/dist/cli.js +5 -6
- package/dist/config.cjs +9 -6
- package/dist/config.d.ts +27 -25
- package/dist/config.js +3 -3
- package/dist/index.d.ts +471 -38
- package/dist/index.js +18 -19
- package/dist/module-evaluator.d.ts +64 -5
- package/dist/module-evaluator.js +122 -62
- package/dist/node.d.ts +355 -87
- package/dist/node.js +49 -73
- package/dist/runtime.d.ts +43 -6
- package/dist/runtime.js +7 -9
- package/dist/spy.js +1 -1
- package/dist/task-utils.js +290 -0
- package/dist/{chunks/traces.DT5aQ62U.js → traces.js} +3 -2
- package/dist/worker.d.ts +8 -10
- package/dist/worker.js +33 -43
- package/dist/workers/forks.js +30 -40
- package/dist/workers/runVmTests.js +66 -43
- package/dist/workers/threads.js +30 -40
- package/dist/workers/vmForks.js +19 -20
- package/dist/workers/vmThreads.js +19 -20
- package/globals.d.ts +19 -19
- package/index.cjs +3 -3
- package/optional-runtime-types.d.ts +1 -1
- package/optional-types.d.ts +1 -1
- package/package.json +59 -74
- package/suppress-warnings.cjs +1 -1
- package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -6
- package/dist/chunks/benchmark.CX_oY03V.js +0 -40
- package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +0 -24
- package/dist/chunks/config.d.A1h_Y6Jt.d.ts +0 -232
- package/dist/chunks/coverage.DM_a_rWm.js +0 -1087
- package/dist/chunks/coverage.d.BZtK59WP.d.ts +0 -37
- package/dist/chunks/evaluatedModules.Dg1zASAC.js +0 -17
- package/dist/chunks/global.d.DVsSRdQ5.d.ts +0 -100
- package/dist/chunks/globals.Dj1TGiMC.js +0 -31
- package/dist/chunks/index.DC7d2Pf8.js +0 -729
- package/dist/chunks/index.DdgEv5B1.js +0 -42
- package/dist/chunks/index.UpGiHP7g.js +0 -4255
- package/dist/chunks/index.og1WyBLx.js +0 -6358
- package/dist/chunks/nativeModuleRunner.BIakptoF.js +0 -36
- package/dist/chunks/node.COQbm6gK.js +0 -14
- package/dist/chunks/plugin.d.DwFIiJ7i.d.ts +0 -38
- package/dist/chunks/rpc.MzXet3jl.js +0 -144
- package/dist/chunks/rpc.d.B_8sPU0w.d.ts +0 -30
- package/dist/chunks/setup-common.DYx3LtFI.js +0 -60
- package/dist/chunks/startVitestModuleRunner.DB-7oCpn.js +0 -740
- package/dist/chunks/suite.d.udJtyAgw.d.ts +0 -10
- package/dist/chunks/test.DNmyFkvJ.js +0 -4430
- package/dist/chunks/traces.d.D2T_R8rx.d.ts +0 -60
- package/dist/chunks/vm.CXMd5FHa.js +0 -785
- package/dist/coverage.d.ts +0 -123
- package/dist/coverage.js +0 -27
- package/dist/environments.d.ts +0 -22
- package/dist/environments.js +0 -5
- package/dist/reporters.d.ts +0 -27
- package/dist/reporters.js +0 -26
- package/dist/runners.d.ts +0 -70
- package/dist/runners.js +0 -19
- package/dist/snapshot.d.ts +0 -9
- package/dist/snapshot.js +0 -6
- package/dist/suite.d.ts +0 -5
- package/dist/suite.js +0 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,36 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export { C as ContextRPC, c as ContextTestEnvironment, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.ZpHpO4yb.js';
|
|
10
|
-
import { b as SerializedRootConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.A1h_Y6Jt.js';
|
|
11
|
-
export { c as RuntimeConfig, S as SerializedConfig, a as SerializedCoverageConfig } from './chunks/config.d.A1h_Y6Jt.js';
|
|
12
|
-
import { U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, P as ProvidedContext } from './chunks/traces.d.D2T_R8rx.js';
|
|
13
|
-
export { a as AfterSuiteRunMeta } from './chunks/traces.d.D2T_R8rx.js';
|
|
14
|
-
import { ExpectStatic, MatcherState, SyncExpectationResult, AsyncExpectationResult, ExpectationResult } from '@vitest/expect';
|
|
15
|
-
export { Assertion, AsymmetricMatchersContaining, DeeplyAllowMatchers, ExpectPollOptions, ExpectStatic, JestAssertion, RawMatcherFn as Matcher, ExpectationResult as MatcherResult, MatcherState, Matchers, chai } from '@vitest/expect';
|
|
16
|
-
import { DomainSnapshotAdapter } from '@vitest/snapshot';
|
|
17
|
-
export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotSerializer, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
|
|
18
|
-
import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
|
|
19
|
-
export { Mock, MockContext, MockInstance, MockResult, MockResultIncomplete, MockResultReturn, MockResultThrow, MockSettledResult, MockSettledResultFulfilled, MockSettledResultIncomplete, MockSettledResultRejected, Mocked, MockedClass, MockedFunction, MockedObject } from '@vitest/spy';
|
|
1
|
+
/// <reference types="chai" />
|
|
2
|
+
import { a as File, A as Awaitable, h as TestAnnotation, j as TestArtifact, k as TaskResultPack, l as TaskEventPack, U as UserConsoleLog, m as SerializedRootConfig, L as LabelColor, M as ModuleGraphData, n as Test, o as TaskPopulated, E as ExpectStatic, p as ProvidedContext, q as MatcherState, r as SyncExpectationResult, t as AsyncExpectationResult, u as DomainSnapshotAdapter, v as ExpectationResult, w as Procedure, x as Mock, e as FakeTimersConfig, y as TemporalTimelike, z as spyOn, B as fn, C as MaybeMockedDeep, G as MaybeMocked, H as MaybePartiallyMocked, I as MaybePartiallyMockedDeep, J as MockInstance, R as RuntimeOptions, K as TestAPI, N as SuiteCollector, O as SuiteAPI, Q as Suite, W as SuiteHooks, V as VitestRunner, b as SerializedConfig, X as VitestRunnerImportSource, Y as Task, Z as CancelReason, $ as TestTryOptions, a0 as TestContext, a1 as ImportDuration, a2 as createChainable } from './chunks/config.d.B3YV4t0O.js';
|
|
3
|
+
export { a3 as AfterSuiteRunMeta, a4 as Assertion, a5 as AsymmetricMatchersContaining, a6 as BaselineData, a7 as Bench, a8 as BenchFn, a9 as BenchFnOptions, aa as BenchFromSource, ab as BenchOptions, ac as BenchRegistration, ad as BenchRegistrationInput, ae as BenchResult, af as BenchRunOptions, ag as BenchStorage, ah as BenchmarkGroup, ai as BenchmarkProvider, aj as BrowserTraceArtifact, ak as DeeplyAllowMatchers, D as DiffOptions, al as DomainMatchResult, am as FailureScreenshotArtifact, an as JestAssertion, ao as Matcher, ap as Matchers, aq as MatchersObject, ar as MockContext, as as MockResult, at as MockResultIncomplete, au as MockResultReturn, av as MockResultThrow, aw as MockSettledResult, ax as MockSettledResultFulfilled, ay as MockSettledResultIncomplete, az as MockSettledResultRejected, aA as Mocked, aB as MockedClass, aC as MockedFunction, aD as MockedObject, aE as OnTestFailedHandler, aF as OnTestFinishedHandler, P as ParsedStack, aG as RunMode, aH as RunnerTaskBase, aI as RunnerTaskResult, aJ as RunnerTaskResultAttempt, aK as RuntimeConfig, S as SerializedCoverageConfig, aL as SerializedError, aM as SnapshotData, aN as SnapshotMatchOptions, aO as SnapshotResult, aP as SnapshotSerializer, aQ as SnapshotStateOptions, aR as SnapshotSummary, aS as SnapshotUpdateState, aT as SuiteFactory, aU as SuiteOptions, aV as TaskCustomOptions, aW as TaskMeta, aX as TaskState, aY as TestAnnotationArtifact, aZ as TestAnnotationLocation, a_ as TestArtifactBase, a$ as TestArtifactLocation, b0 as TestArtifactRegistry, b1 as TestAttachment, b2 as TestBenchmark, b3 as TestBenchmarkTask, T as TestError, b4 as TestFunction, b5 as TestOptions, g as TestTagDefinition, b6 as TestTags, b7 as UncheckedSnapshot, b8 as VisualRegressionArtifact, b9 as afterAll, ba as afterEach, bb as aroundAll, bc as aroundEach, bd as beforeAll, be as beforeEach, bf as onTestFailed, bg as onTestFinished } from './chunks/config.d.B3YV4t0O.js';
|
|
4
|
+
import { M as ModuleDefinitionDurationsDiagnostic, U as UntrackedModuleDefinitionDiagnostic, S as SerializedTestSpecification, a as ModuleDefinitionDiagnostic, b as ModuleDefinitionLocation, c as SourceModuleDiagnostic, d as SourceModuleLocations } from './chunks/browser.d.C7tWgUvw.js';
|
|
5
|
+
export { B as BrowserTesterOptions } from './chunks/browser.d.C7tWgUvw.js';
|
|
6
|
+
import { c as createFileTask } from './chunks/task-utils.d.D-gFPNFi.js';
|
|
7
|
+
import { B as BirpcReturn } from './chunks/worker.d.CyJRpyfZ.js';
|
|
8
|
+
export { C as ContextRPC, a as ContextTestEnvironment, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.CyJRpyfZ.js';
|
|
20
9
|
import { Disposable } from 'vitest/optional-runtime-types.js';
|
|
21
10
|
import { ModuleMockFactoryWithHelper, ModuleMockOptions } from '@vitest/mocker';
|
|
22
|
-
export { b as bench } from './chunks/suite.d.udJtyAgw.js';
|
|
23
11
|
export { V as EvaluatedModules } from './chunks/evaluatedModules.d.BxJ5omdx.js';
|
|
24
|
-
|
|
25
|
-
export {
|
|
12
|
+
import { T as Traces } from './chunks/rpc.d.3FOhdFx8.js';
|
|
13
|
+
export { R as RunnerRPC, a as RuntimeRPC } from './chunks/rpc.d.3FOhdFx8.js';
|
|
26
14
|
export { ExpectTypeOf, expectTypeOf } from 'expect-type';
|
|
27
|
-
export {
|
|
28
|
-
|
|
29
|
-
export {
|
|
30
|
-
import '@vitest/pretty-format';
|
|
15
|
+
export { BenchOptions as BenchCompareOptions } from 'tinybench';
|
|
16
|
+
import * as chai from 'chai';
|
|
17
|
+
export { chai };
|
|
31
18
|
import 'vite/module-runner';
|
|
32
|
-
import './chunks/environment.d.
|
|
33
|
-
import '@vitest/runner/utils';
|
|
19
|
+
import './chunks/environment.d.BFQtFKdZ.js';
|
|
34
20
|
|
|
35
21
|
interface SourceMap {
|
|
36
22
|
file: string;
|
|
@@ -70,8 +56,8 @@ interface WebSocketHandlers {
|
|
|
70
56
|
name: string;
|
|
71
57
|
color?: LabelColor;
|
|
72
58
|
}[];
|
|
73
|
-
getModuleGraph: (projectName: string, id: string,
|
|
74
|
-
getTransformResult: (projectName: string, id: string, testFileId: string
|
|
59
|
+
getModuleGraph: (projectName: string, id: string, viteEnvironment?: string) => Promise<ModuleGraphData>;
|
|
60
|
+
getTransformResult: (projectName: string, id: string, testFileId: string) => Promise<TransformResultWithSource | undefined>;
|
|
75
61
|
getExternalResult: (id: string, testFileId: string) => Promise<ExternalResult | undefined>;
|
|
76
62
|
readTestFile: (id: string) => Promise<string | null>;
|
|
77
63
|
saveTestFile: (id: string, content: string) => Promise<void>;
|
|
@@ -86,6 +72,7 @@ interface WebSocketEvents {
|
|
|
86
72
|
onTestAnnotate?: (testId: string, annotation: TestAnnotation) => Awaitable<void>;
|
|
87
73
|
onTestArtifactRecord?: (testId: string, artifact: TestArtifact) => Awaitable<void>;
|
|
88
74
|
onTaskUpdate?: (packs: TaskResultPack[], events: TaskEventPack[]) => Awaitable<void>;
|
|
75
|
+
onTestRemoved?: (path?: string) => Awaitable<void>;
|
|
89
76
|
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
90
77
|
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
91
78
|
onSpecsCollected?: (specs?: SerializedTestSpecification[], startTime?: number) => Awaitable<void>;
|
|
@@ -192,6 +179,229 @@ declare const Snapshots: {
|
|
|
192
179
|
toMatchDomainInlineSnapshot(this: MatcherState, domain: DomainSnapshotAdapter<any, any>, received: unknown, inlineSnapshot?: string): ExpectationResult;
|
|
193
180
|
};
|
|
194
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Returns `true` if the given value is a {@linkcode When} chain created by {@linkcode when|vi.when}.
|
|
184
|
+
*
|
|
185
|
+
* @param input - The value to check.
|
|
186
|
+
* @returns `true` if `input` is a {@linkcode When} instance, `false` otherwise.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* const spy = vi.fn()
|
|
190
|
+
* const w = vi.when(spy).calledWith(1).thenReturn(0)
|
|
191
|
+
*
|
|
192
|
+
* expect(isWhenChain(w)).toBe(true)
|
|
193
|
+
* expect(isWhenChain(spy)).toBe(false)
|
|
194
|
+
*/
|
|
195
|
+
declare function isWhenChain(input: object): input is When<Procedure>;
|
|
196
|
+
interface BehaviorOptions {
|
|
197
|
+
/**
|
|
198
|
+
* How many times this behavior should apply before being exhausted.
|
|
199
|
+
*
|
|
200
|
+
* By default it applies indefinitely.
|
|
201
|
+
*
|
|
202
|
+
* @default Number.POSITIVE_INFINITY
|
|
203
|
+
*/
|
|
204
|
+
times?: number | undefined;
|
|
205
|
+
}
|
|
206
|
+
type OnceBehaviorOptions = Omit<BehaviorOptions, "times">;
|
|
207
|
+
/**
|
|
208
|
+
* Fluent interface returned by {@linkcode When.calledWith} for defining behaviors on a specific set of arguments.
|
|
209
|
+
*
|
|
210
|
+
* Each `then*` method appends an action and returns the same instance, allowing multiple behaviors to be chained for the same argument set.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* vi.when(spy)
|
|
214
|
+
* .calledWith('darkMode')
|
|
215
|
+
* .thenReturn(true)
|
|
216
|
+
* .thenReturnOnce(false)
|
|
217
|
+
*/
|
|
218
|
+
type CalledWithInstance<
|
|
219
|
+
ReturnType,
|
|
220
|
+
Fn extends Procedure
|
|
221
|
+
> = When<Fn> & {
|
|
222
|
+
/**
|
|
223
|
+
* Schedules a synchronous return value for when the spy is called with the registered arguments.
|
|
224
|
+
*
|
|
225
|
+
* @param value - The value to return.
|
|
226
|
+
* @param options - Optional behavior configuration.
|
|
227
|
+
* @returns The same {@linkcode when|vi.when} instance for chaining.
|
|
228
|
+
*/
|
|
229
|
+
thenReturn: (value: ReturnType, options?: BehaviorOptions | undefined) => CalledWithInstance<ReturnType, Fn>;
|
|
230
|
+
/**
|
|
231
|
+
* Schedules a resolved `Promise` return value for when the spy is called with the registered arguments.
|
|
232
|
+
*
|
|
233
|
+
* @param value - The value to resolve with.
|
|
234
|
+
* @param options - Optional behavior configuration.
|
|
235
|
+
* @returns The same {@linkcode when|vi.when} instance for chaining.
|
|
236
|
+
*/
|
|
237
|
+
thenResolve: (value: Awaited<ReturnType>, options?: BehaviorOptions | undefined) => CalledWithInstance<ReturnType, Fn>;
|
|
238
|
+
/**
|
|
239
|
+
* Schedules a synchronous return value for a single call with the registered arguments, then removes the behavior.
|
|
240
|
+
*
|
|
241
|
+
* @param value - The value to return.
|
|
242
|
+
* @param options - Optional behavior configuration.
|
|
243
|
+
* @returns The same {@linkcode when|vi.when} instance for chaining.
|
|
244
|
+
*/
|
|
245
|
+
thenReturnOnce: (value: ReturnType, options?: OnceBehaviorOptions | undefined) => CalledWithInstance<ReturnType, Fn>;
|
|
246
|
+
/**
|
|
247
|
+
* Schedules a resolved `Promise` return value for a single call with the registered arguments, then removes the behavior.
|
|
248
|
+
*
|
|
249
|
+
* @param value - The value to resolve with.
|
|
250
|
+
* @param options - Optional behavior configuration.
|
|
251
|
+
* @returns The same {@linkcode when|vi.when} instance for chaining.
|
|
252
|
+
*/
|
|
253
|
+
thenResolveOnce: (value: Awaited<ReturnType>, options?: OnceBehaviorOptions | undefined) => CalledWithInstance<ReturnType, Fn>;
|
|
254
|
+
/**
|
|
255
|
+
* Schedules a thrown error for when the spy is called with the registered arguments.
|
|
256
|
+
*
|
|
257
|
+
* @param value - The value to throw.
|
|
258
|
+
* @param options - Optional behavior configuration.
|
|
259
|
+
* @returns The same {@linkcode when|vi.when} instance for chaining.
|
|
260
|
+
*/
|
|
261
|
+
thenThrow: (value: unknown, options?: BehaviorOptions | undefined) => CalledWithInstance<ReturnType, Fn>;
|
|
262
|
+
/**
|
|
263
|
+
* Schedules a rejected `Promise` for when the spy is called with the registered arguments.
|
|
264
|
+
*
|
|
265
|
+
* @param value - The value to reject with.
|
|
266
|
+
* @param options - Optional behavior configuration.
|
|
267
|
+
* @returns The same {@linkcode when|vi.when} instance for chaining.
|
|
268
|
+
*/
|
|
269
|
+
thenReject: (value: unknown, options?: BehaviorOptions | undefined) => CalledWithInstance<ReturnType, Fn>;
|
|
270
|
+
/**
|
|
271
|
+
* Schedules a thrown error for a single call with the registered arguments, then removes the behavior.
|
|
272
|
+
*
|
|
273
|
+
* @param value - The value to throw.
|
|
274
|
+
* @param options - Optional behavior configuration.
|
|
275
|
+
* @returns The same {@linkcode when|vi.when} instance for chaining.
|
|
276
|
+
*/
|
|
277
|
+
thenThrowOnce: (value: unknown, options?: OnceBehaviorOptions | undefined) => CalledWithInstance<ReturnType, Fn>;
|
|
278
|
+
/**
|
|
279
|
+
* Schedules a rejected `Promise` for a single call with the registered arguments, then removes the behavior.
|
|
280
|
+
*
|
|
281
|
+
* @param value - The value to reject with.
|
|
282
|
+
* @param options - Optional behavior configuration.
|
|
283
|
+
* @returns The same {@linkcode when|vi.when} instance for chaining.
|
|
284
|
+
*/
|
|
285
|
+
thenRejectOnce: (value: unknown, options?: OnceBehaviorOptions | undefined) => CalledWithInstance<ReturnType, Fn>;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* A handle returned by {@linkcode when|vi.when} that lets define per-argument behaviors on a spy and check whether all defined behaviors have been consumed.
|
|
289
|
+
*
|
|
290
|
+
* Implements `Symbol.dispose` so it can be used with the `using` keyword. When the block exits the spy's original implementation is automatically restored.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* using w = vi.when(spy)
|
|
294
|
+
* .calledWith('hello')
|
|
295
|
+
* .thenReturn('HELLO')
|
|
296
|
+
*/
|
|
297
|
+
interface When<Fn extends Procedure> extends Disposable {
|
|
298
|
+
/**
|
|
299
|
+
* Defines behavior for a specific set of arguments.
|
|
300
|
+
*
|
|
301
|
+
* Multiple behaviors can be stacked for the same arguments. They are matched last-registered first (LIFO stack, last in first out), so earlier entries act as fallbacks once later ones are exhausted.
|
|
302
|
+
*
|
|
303
|
+
* @param args - The arguments to match against.
|
|
304
|
+
* @returns A {@linkcode CalledWithInstance} for chaining `then*` actions.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* vi.when(spy)
|
|
308
|
+
* .calledWith(expect.any(Number))
|
|
309
|
+
* .thenReturn(0)
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* // Stack behaviors: first call returns `false`, subsequent calls return `true`
|
|
313
|
+
* vi.when(spy)
|
|
314
|
+
* .calledWith('darkMode')
|
|
315
|
+
* .thenReturn(true)
|
|
316
|
+
* .thenReturnOnce(false)
|
|
317
|
+
*/
|
|
318
|
+
calledWith: (...args: Parameters<Fn>) => CalledWithInstance<ReturnType<Fn>, Fn>;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Options for {@linkcode when|vi.when}.
|
|
322
|
+
*/
|
|
323
|
+
interface WhenOptions<Fn extends Procedure = Procedure> {
|
|
324
|
+
/**
|
|
325
|
+
* Controls what happens when the spy is called with arguments that have no matching `calledWith` behavior.
|
|
326
|
+
*
|
|
327
|
+
* Valid configurations are:
|
|
328
|
+
* - `'passthrough'`: delegates to the spy's original implementation (default)
|
|
329
|
+
* - `'throw'`: throws an error
|
|
330
|
+
* - a function: called with the unmatched arguments; its return value is used
|
|
331
|
+
*
|
|
332
|
+
* @default
|
|
333
|
+
* 'passthrough'
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* vi.when(spy, { onUnmatched: 'throw' })
|
|
337
|
+
* .calledWith(1)
|
|
338
|
+
* .thenReturn({ id: 1, name: 'Alice' })
|
|
339
|
+
*
|
|
340
|
+
* expect(spy(1)).toEqual({ id: 1, name: 'Alice' })
|
|
341
|
+
* expect(() => spy(2)).toThrow()
|
|
342
|
+
*/
|
|
343
|
+
onUnmatched?: "throw" | "passthrough" | Fn | undefined;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Defines conditional behaviors on a Vitest spy based on the arguments it is called with.
|
|
347
|
+
*
|
|
348
|
+
* Behaviors are matched using deep equality, last-registered first within each argument set.
|
|
349
|
+
*
|
|
350
|
+
* It automatically restores the spy's original implementation when the enclosing block exits if used with the `using` keyword.
|
|
351
|
+
*
|
|
352
|
+
* @param spy - A Vitest mock function to attach behaviors to.
|
|
353
|
+
* @param options - Optional configuration.
|
|
354
|
+
* @returns A {@linkcode When} instance for registering behaviors.
|
|
355
|
+
*
|
|
356
|
+
* @throws {TypeError} If `spy` is not a Vitest mock function.
|
|
357
|
+
* @throws {Error} If chaining a non-existent method after `calledWith`.
|
|
358
|
+
* @throws {RangeError} If setting the `times` option on a `then*` method as a negative value or `0`.
|
|
359
|
+
*
|
|
360
|
+
* @since 5.0.0
|
|
361
|
+
* @see {@link https://vitest.dev/api/vi#vi-when}
|
|
362
|
+
* @see {@link https://vitest.dev/guide/recipes/conditional-mocking}
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* // Basic usage
|
|
366
|
+
* const spy = vi.fn(() => Number.NEGATIVE_INFINITY)
|
|
367
|
+
* vi.when(spy).calledWith(1).thenReturn(0)
|
|
368
|
+
*
|
|
369
|
+
* expect(spy(1)).toBe(0)
|
|
370
|
+
* expect(spy(2)).toBe(Number.NEGATIVE_INFINITY) // falls through to original implementation
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* // Async
|
|
374
|
+
* const spy = vi.fn()
|
|
375
|
+
* vi.when(spy).calledWith('user').thenResolve({ id: 1 })
|
|
376
|
+
*
|
|
377
|
+
* await expect(spy('user')).resolves.toEqual({ id: 1 })
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* // Scoped with `using`
|
|
381
|
+
* const spy = vi.fn()
|
|
382
|
+
*
|
|
383
|
+
* {
|
|
384
|
+
* using w = vi.when(spy)
|
|
385
|
+
* .calledWith('darkMode')
|
|
386
|
+
* .thenReturn(true)
|
|
387
|
+
*
|
|
388
|
+
* expect(spy('darkMode')).toBe(true)
|
|
389
|
+
* }
|
|
390
|
+
*
|
|
391
|
+
* // spy's original implementation is restored here
|
|
392
|
+
* expect(spy('darkMode')).toBe(undefined)
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* // Throw on unmatched calls
|
|
396
|
+
* vi.when(spy, { onUnmatched: 'throw' })
|
|
397
|
+
* .calledWith(1)
|
|
398
|
+
* .thenReturn({ id: 1, name: 'Alice' })
|
|
399
|
+
*
|
|
400
|
+
* expect(spy(1)).toEqual({ id: 1, name: 'Alice' })
|
|
401
|
+
* expect(() => spy(2)).toThrow()
|
|
402
|
+
*/
|
|
403
|
+
declare function when<Fn extends Procedure>(spy: Fn | Mock<Fn>, options?: WhenOptions<Fn>): When<Fn>;
|
|
404
|
+
|
|
195
405
|
type WaitForCallback<T> = () => T | Promise<T>;
|
|
196
406
|
interface WaitForOptions {
|
|
197
407
|
/**
|
|
@@ -204,10 +414,14 @@ interface WaitForOptions {
|
|
|
204
414
|
* @default 1000ms
|
|
205
415
|
*/
|
|
206
416
|
timeout?: number;
|
|
417
|
+
/**
|
|
418
|
+
* @description Message that describes what is being waited for. It prefixes the error and names the trace step
|
|
419
|
+
*/
|
|
420
|
+
message?: string;
|
|
207
421
|
}
|
|
208
422
|
declare function waitFor<T>(callback: WaitForCallback<T>, options?: number | WaitForOptions): Promise<T>;
|
|
209
423
|
type WaitUntilCallback<T> = () => T | Promise<T>;
|
|
210
|
-
interface WaitUntilOptions extends Pick<WaitForOptions, "interval" | "timeout"> {}
|
|
424
|
+
interface WaitUntilOptions extends Pick<WaitForOptions, "interval" | "timeout" | "message"> {}
|
|
211
425
|
type Truthy<T> = T extends false | "" | 0 | null | undefined ? never : T;
|
|
212
426
|
declare function waitUntil<T>(callback: WaitUntilCallback<T>, options?: number | WaitUntilOptions): Promise<Truthy<T>>;
|
|
213
427
|
|
|
@@ -220,7 +434,7 @@ interface VitestUtils {
|
|
|
220
434
|
/**
|
|
221
435
|
* This method wraps all further calls to timers until [`vi.useRealTimers()`](https://vitest.dev/api/vi#vi-userealtimers) is called.
|
|
222
436
|
*/
|
|
223
|
-
useFakeTimers: (config?:
|
|
437
|
+
useFakeTimers: (config?: FakeTimersConfig) => VitestUtils;
|
|
224
438
|
/**
|
|
225
439
|
* Restores mocked timers to their original implementations. All timers that were scheduled before will be discarded.
|
|
226
440
|
*/
|
|
@@ -277,7 +491,7 @@ interface VitestUtils {
|
|
|
277
491
|
* If fake timers are enabled, this method simulates a user changing the system clock (will affect date related API like `hrtime`, `performance.now` or `new Date()`) - however, it will not fire any timers.
|
|
278
492
|
* If fake timers are not enabled, this method will only mock `Date.*` and `new Date()` calls.
|
|
279
493
|
*/
|
|
280
|
-
setSystemTime: (time: number | string | Date) => VitestUtils;
|
|
494
|
+
setSystemTime: (time: number | string | Date | TemporalTimelike) => VitestUtils;
|
|
281
495
|
/**
|
|
282
496
|
* Returns mocked current date. If date is not mocked the method will return `null`.
|
|
283
497
|
*/
|
|
@@ -335,6 +549,8 @@ interface VitestUtils {
|
|
|
335
549
|
* ```
|
|
336
550
|
*/
|
|
337
551
|
fn: typeof fn;
|
|
552
|
+
when: typeof when;
|
|
553
|
+
isWhenChain: typeof isWhenChain;
|
|
338
554
|
/**
|
|
339
555
|
* Wait for the callback to execute successfully. If the callback throws an error or returns a rejected promise it will continue to wait until it succeeds or times out.
|
|
340
556
|
*
|
|
@@ -463,9 +679,9 @@ interface VitestUtils {
|
|
|
463
679
|
* @example
|
|
464
680
|
* ```ts
|
|
465
681
|
* vi.mock('./example.js', async () => {
|
|
466
|
-
* const
|
|
682
|
+
* const original = await vi.importActual<typeof import('./example.js')>('./example.js')
|
|
467
683
|
*
|
|
468
|
-
* return { ...
|
|
684
|
+
* return { ...original, get: vi.fn() }
|
|
469
685
|
* })
|
|
470
686
|
* ```
|
|
471
687
|
* @param path Path to the module. Can be aliased, if your config supports it
|
|
@@ -590,7 +806,7 @@ interface VitestUtils {
|
|
|
590
806
|
* Changes the value of `import.meta.env` and `process.env`.
|
|
591
807
|
* You can return it back to original value with `vi.unstubAllEnvs`, or by enabling `unstubEnvs` config option.
|
|
592
808
|
*/
|
|
593
|
-
stubEnv: <T extends string>(name: T, value: T extends "PROD" | "DEV" | "SSR" ? boolean : string | undefined) => VitestUtils;
|
|
809
|
+
stubEnv: <T extends string>(name: T, value: T extends "PROD" | "DEV" | "SSR" ? boolean | undefined : string | undefined) => VitestUtils;
|
|
594
810
|
/**
|
|
595
811
|
* Reset the value to original value that was available before first `vi.stubGlobal` was called.
|
|
596
812
|
*/
|
|
@@ -624,6 +840,220 @@ interface VitestUtils {
|
|
|
624
840
|
declare const vitest: VitestUtils;
|
|
625
841
|
declare const vi: VitestUtils;
|
|
626
842
|
|
|
843
|
+
/**
|
|
844
|
+
* @experimental
|
|
845
|
+
* @advanced
|
|
846
|
+
*
|
|
847
|
+
* Records a custom test artifact during test execution.
|
|
848
|
+
*
|
|
849
|
+
* This function allows you to attach structured data, files, or metadata to a test.
|
|
850
|
+
*
|
|
851
|
+
* Vitest automatically injects the source location where the artifact was created and manages any attachments you include.
|
|
852
|
+
*
|
|
853
|
+
* **Note:** artifacts must be recorded before the task is reported. Any artifacts recorded after that will not be included in the task.
|
|
854
|
+
*
|
|
855
|
+
* @param task - The test task context, typically accessed via `this.task` in custom matchers or `context.task` in tests
|
|
856
|
+
* @param artifact - The artifact to record. Must extend {@linkcode TestArtifactBase}
|
|
857
|
+
*
|
|
858
|
+
* @returns A promise that resolves to the recorded artifact with location injected
|
|
859
|
+
*
|
|
860
|
+
* @throws {Error} If the test runner doesn't support artifacts
|
|
861
|
+
*
|
|
862
|
+
* @example
|
|
863
|
+
* ```ts
|
|
864
|
+
* // In a custom assertion
|
|
865
|
+
* async function toHaveValidSchema(this: MatcherState, actual: unknown) {
|
|
866
|
+
* const validation = validateSchema(actual)
|
|
867
|
+
*
|
|
868
|
+
* await recordArtifact(this.task, {
|
|
869
|
+
* type: 'my-plugin:schema-validation',
|
|
870
|
+
* passed: validation.valid,
|
|
871
|
+
* errors: validation.errors,
|
|
872
|
+
* })
|
|
873
|
+
*
|
|
874
|
+
* return { pass: validation.valid, message: () => '...' }
|
|
875
|
+
* }
|
|
876
|
+
* ```
|
|
877
|
+
*/
|
|
878
|
+
declare function recordArtifact<Artifact extends TestArtifact>(task: Test, artifact: Artifact): Promise<Artifact>;
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* Creates a suite of tests, allowing for grouping and hierarchical organization of tests.
|
|
882
|
+
* Suites can contain both tests and other suites, enabling complex test structures.
|
|
883
|
+
*
|
|
884
|
+
* @param {string} name - The name of the suite, used for identification and reporting.
|
|
885
|
+
* @param {Function} fn - A function that defines the tests and suites within this suite.
|
|
886
|
+
* @example
|
|
887
|
+
* ```ts
|
|
888
|
+
* // Define a suite with two tests
|
|
889
|
+
* suite('Math operations', () => {
|
|
890
|
+
* test('should add two numbers', () => {
|
|
891
|
+
* expect(add(1, 2)).toBe(3);
|
|
892
|
+
* });
|
|
893
|
+
*
|
|
894
|
+
* test('should subtract two numbers', () => {
|
|
895
|
+
* expect(subtract(5, 2)).toBe(3);
|
|
896
|
+
* });
|
|
897
|
+
* });
|
|
898
|
+
* ```
|
|
899
|
+
* @example
|
|
900
|
+
* ```ts
|
|
901
|
+
* // Define nested suites
|
|
902
|
+
* suite('String operations', () => {
|
|
903
|
+
* suite('Trimming', () => {
|
|
904
|
+
* test('should trim whitespace from start and end', () => {
|
|
905
|
+
* expect(' hello '.trim()).toBe('hello');
|
|
906
|
+
* });
|
|
907
|
+
* });
|
|
908
|
+
*
|
|
909
|
+
* suite('Concatenation', () => {
|
|
910
|
+
* test('should concatenate two strings', () => {
|
|
911
|
+
* expect('hello' + ' ' + 'world').toBe('hello world');
|
|
912
|
+
* });
|
|
913
|
+
* });
|
|
914
|
+
* });
|
|
915
|
+
* ```
|
|
916
|
+
*/
|
|
917
|
+
declare const suite: SuiteAPI;
|
|
918
|
+
/**
|
|
919
|
+
* Defines a test case with a given name and test function. The test function can optionally be configured with test options.
|
|
920
|
+
*
|
|
921
|
+
* @param {string | Function} name - The name of the test or a function that will be used as a test name.
|
|
922
|
+
* @param {TestOptions | TestFunction} [optionsOrFn] - Optional. The test options or the test function if no explicit name is provided.
|
|
923
|
+
* @param {number | TestOptions | TestFunction} [optionsOrTest] - Optional. The test function or options, depending on the previous parameters.
|
|
924
|
+
* @throws {Error} If called inside another test function.
|
|
925
|
+
* @example
|
|
926
|
+
* ```ts
|
|
927
|
+
* // Define a simple test
|
|
928
|
+
* test('should add two numbers', () => {
|
|
929
|
+
* expect(add(1, 2)).toBe(3);
|
|
930
|
+
* });
|
|
931
|
+
* ```
|
|
932
|
+
* @example
|
|
933
|
+
* ```ts
|
|
934
|
+
* // Define a test with options
|
|
935
|
+
* test('should subtract two numbers', { retry: 3 }, () => {
|
|
936
|
+
* expect(subtract(5, 2)).toBe(3);
|
|
937
|
+
* });
|
|
938
|
+
* ```
|
|
939
|
+
*/
|
|
940
|
+
declare const test: TestAPI;
|
|
941
|
+
/**
|
|
942
|
+
* Creates a suite of tests, allowing for grouping and hierarchical organization of tests.
|
|
943
|
+
* Suites can contain both tests and other suites, enabling complex test structures.
|
|
944
|
+
*
|
|
945
|
+
* @param {string} name - The name of the suite, used for identification and reporting.
|
|
946
|
+
* @param {Function} fn - A function that defines the tests and suites within this suite.
|
|
947
|
+
* @example
|
|
948
|
+
* ```ts
|
|
949
|
+
* // Define a suite with two tests
|
|
950
|
+
* describe('Math operations', () => {
|
|
951
|
+
* test('should add two numbers', () => {
|
|
952
|
+
* expect(add(1, 2)).toBe(3);
|
|
953
|
+
* });
|
|
954
|
+
*
|
|
955
|
+
* test('should subtract two numbers', () => {
|
|
956
|
+
* expect(subtract(5, 2)).toBe(3);
|
|
957
|
+
* });
|
|
958
|
+
* });
|
|
959
|
+
* ```
|
|
960
|
+
* @example
|
|
961
|
+
* ```ts
|
|
962
|
+
* // Define nested suites
|
|
963
|
+
* describe('String operations', () => {
|
|
964
|
+
* describe('Trimming', () => {
|
|
965
|
+
* test('should trim whitespace from start and end', () => {
|
|
966
|
+
* expect(' hello '.trim()).toBe('hello');
|
|
967
|
+
* });
|
|
968
|
+
* });
|
|
969
|
+
*
|
|
970
|
+
* describe('Concatenation', () => {
|
|
971
|
+
* test('should concatenate two strings', () => {
|
|
972
|
+
* expect('hello' + ' ' + 'world').toBe('hello world');
|
|
973
|
+
* });
|
|
974
|
+
* });
|
|
975
|
+
* });
|
|
976
|
+
* ```
|
|
977
|
+
*/
|
|
978
|
+
declare const describe: SuiteAPI;
|
|
979
|
+
/**
|
|
980
|
+
* Defines a test case with a given name and test function. The test function can optionally be configured with test options.
|
|
981
|
+
*
|
|
982
|
+
* @param {string | Function} name - The name of the test or a function that will be used as a test name.
|
|
983
|
+
* @param {TestOptions | TestFunction} [optionsOrFn] - Optional. The test options or the test function if no explicit name is provided.
|
|
984
|
+
* @param {number | TestOptions | TestFunction} [optionsOrTest] - Optional. The test function or options, depending on the previous parameters.
|
|
985
|
+
* @throws {Error} If called inside another test function.
|
|
986
|
+
* @example
|
|
987
|
+
* ```ts
|
|
988
|
+
* // Define a simple test
|
|
989
|
+
* it('adds two numbers', () => {
|
|
990
|
+
* expect(add(1, 2)).toBe(3);
|
|
991
|
+
* });
|
|
992
|
+
* ```
|
|
993
|
+
* @example
|
|
994
|
+
* ```ts
|
|
995
|
+
* // Define a test with options
|
|
996
|
+
* it('subtracts two numbers', { retry: 3 }, () => {
|
|
997
|
+
* expect(subtract(5, 2)).toBe(3);
|
|
998
|
+
* });
|
|
999
|
+
* ```
|
|
1000
|
+
*/
|
|
1001
|
+
declare const it: TestAPI;
|
|
1002
|
+
declare function getCurrentSuite<ExtraContext = object>(): SuiteCollector<ExtraContext>;
|
|
1003
|
+
declare function createTaskCollector(fn: (...args: any[]) => any): TestAPI;
|
|
1004
|
+
|
|
1005
|
+
declare function getFn<Task = Test>(key: Task): () => Awaitable<void>;
|
|
1006
|
+
declare function getHooks(key: Suite): SuiteHooks;
|
|
1007
|
+
|
|
1008
|
+
declare function getCurrentTest<T extends Test | undefined>(): T;
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* @experimental
|
|
1012
|
+
*/
|
|
1013
|
+
declare function matchesTags(testTags: string[]): boolean;
|
|
1014
|
+
|
|
1015
|
+
declare class TestRunner implements VitestRunner {
|
|
1016
|
+
config: SerializedConfig;
|
|
1017
|
+
private snapshotClient;
|
|
1018
|
+
private workerState;
|
|
1019
|
+
private moduleRunner;
|
|
1020
|
+
private cancelRun;
|
|
1021
|
+
private assertionsErrors;
|
|
1022
|
+
private benchInstances;
|
|
1023
|
+
pool: string;
|
|
1024
|
+
viteEnvironment: string;
|
|
1025
|
+
private viteModuleRunner;
|
|
1026
|
+
constructor(config: SerializedConfig);
|
|
1027
|
+
importFile(filepath: string, source: VitestRunnerImportSource): unknown;
|
|
1028
|
+
onCollectStart(file: File): void;
|
|
1029
|
+
onCleanupWorkerContext?: (listener: () => unknown) => void;
|
|
1030
|
+
onAfterRunFiles(_files: File[]): void;
|
|
1031
|
+
onAfterRunSuite(suite: Suite): Promise<void>;
|
|
1032
|
+
onAfterRunTask(test: Task): void;
|
|
1033
|
+
cancel(_reason: CancelReason): void;
|
|
1034
|
+
injectValue(key: string): any;
|
|
1035
|
+
onBeforeRunTask(test: Task): Promise<void>;
|
|
1036
|
+
onBeforeRunSuite(suite: Suite): Promise<void>;
|
|
1037
|
+
onBeforeTryTask(test: Task, options: TestTryOptions): void;
|
|
1038
|
+
onAfterRetryTask(test: Test, _options: TestTryOptions): Promise<void>;
|
|
1039
|
+
onAfterTryTask(test: Test): void;
|
|
1040
|
+
extendTaskContext(context: TestContext): TestContext;
|
|
1041
|
+
getImportDurations(): Record<string, ImportDuration>;
|
|
1042
|
+
getModuleFetchDuration(): number;
|
|
1043
|
+
trace: <T>(name: string, attributes: Record<string, any> | (() => T), cb?: () => T) => T;
|
|
1044
|
+
__setTraces(traces: Traces): void;
|
|
1045
|
+
static createTaskCollector: typeof createTaskCollector;
|
|
1046
|
+
static getCurrentSuite: typeof getCurrentSuite;
|
|
1047
|
+
static getCurrentTest: typeof getCurrentTest;
|
|
1048
|
+
static createChainable: typeof createChainable;
|
|
1049
|
+
static getSuiteHooks: typeof getHooks;
|
|
1050
|
+
static getTestFn: typeof getFn;
|
|
1051
|
+
static setSuiteHooks: typeof getHooks;
|
|
1052
|
+
static setTestFn: typeof getFn;
|
|
1053
|
+
static matchesTags: typeof matchesTags;
|
|
1054
|
+
static createFileTask: typeof createFileTask;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
627
1057
|
interface AssertType {
|
|
628
1058
|
<T>(value: T): void;
|
|
629
1059
|
}
|
|
@@ -638,5 +1068,8 @@ declare namespace Experimental {
|
|
|
638
1068
|
export { ModuleDefinitionDiagnostic, ModuleDefinitionDurationsDiagnostic, ModuleDefinitionLocation, SourceModuleDiagnostic, SourceModuleLocations, UntrackedModuleDefinitionDiagnostic };
|
|
639
1069
|
}
|
|
640
1070
|
|
|
641
|
-
|
|
642
|
-
|
|
1071
|
+
/** @deprecated use `SerializedConfig` instead */
|
|
1072
|
+
type TestRunnerConfig = SerializedConfig;
|
|
1073
|
+
|
|
1074
|
+
export { AsyncExpectationResult as AsyncMatcherResult, CancelReason, DomainSnapshotAdapter, ExpectStatic, Experimental, FakeTimersConfig, ImportDuration, LabelColor, ExpectationResult as MatcherResult, MatcherState, Mock, MockInstance, ModuleGraphData, ProvidedContext, Task as RunnerTask, TaskEventPack as RunnerTaskEventPack, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SerializedConfig, SerializedRootConfig, SerializedTestSpecification, Snapshots, SuiteAPI, SuiteCollector, SyncExpectationResult as SyncMatcherResult, TestAPI, TestAnnotation, TestArtifact, TestContext, TestRunner, TestTryOptions, UserConsoleLog, VitestRunner as VitestTestRunner, assert, assertType, createExpect, describe, globalExpect as expect, inject, it, recordArtifact, should, suite, test, vi, vitest };
|
|
1075
|
+
export type { AssertType, BrowserUI, ExternalResult, TestRunnerConfig, TransformResultWithSource, VitestUtils, WebSocketEvents, WebSocketHandlers, WebSocketRPC };
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { a as assertType } from './chunks/index.DdgEv5B1.js';
|
|
1
|
+
export { S as Snapshots, T as TestRunner, a as assert, b as assertType, c as createExpect, g as expect, d as inject, s as should, v as vi, e as vitest } from './chunks/index.CZzC1gGg.js';
|
|
2
|
+
export { V as EvaluatedModules } from './chunks/rpc.Uhkwr2NM.js';
|
|
3
|
+
export { k as afterAll, l as afterEach, n as aroundAll, o as aroundEach, q as beforeAll, t as beforeEach, u as describe, v as it, w as onTestFailed, x as onTestFinished, r as recordArtifact, y as suite, z as test } from './chunks/run.CjdgFZiW.js';
|
|
5
4
|
export { expectTypeOf } from 'expect-type';
|
|
6
|
-
|
|
7
|
-
export { chai }
|
|
8
|
-
import '
|
|
9
|
-
import '
|
|
10
|
-
import './chunks/
|
|
11
|
-
import '
|
|
12
|
-
import '
|
|
13
|
-
import '
|
|
14
|
-
import '
|
|
15
|
-
import '
|
|
16
|
-
import '
|
|
17
|
-
import './chunks/
|
|
18
|
-
import './chunks/
|
|
19
|
-
import '
|
|
20
|
-
import '@vitest/snapshot';
|
|
5
|
+
import * as chai from 'chai';
|
|
6
|
+
export { chai };
|
|
7
|
+
import './chunks/utils.DYj33du9.js';
|
|
8
|
+
import './chunks/source-map.DakdQc29.js';
|
|
9
|
+
import './chunks/index.D0heQG4v.js';
|
|
10
|
+
import './chunks/tinyrainbow.Do8I1XRG.js';
|
|
11
|
+
import './chunks/pathe.M-eThtNZ.zq3TM4NT.js';
|
|
12
|
+
import './chunks/spy.DDMXghXv.js';
|
|
13
|
+
import './chunks/display.BlTmubjj.js';
|
|
14
|
+
import './task-utils.js';
|
|
15
|
+
import './chunks/plugins.DPQHVT0p.js';
|
|
16
|
+
import './chunks/rawSnapshot.DqSiqIEx.js';
|
|
17
|
+
import './chunks/offset.Dy-5Fdfn.js';
|
|
18
|
+
import 'tinybench';
|
|
21
19
|
import 'vite/module-runner';
|
|
20
|
+
import './chunks/index.DmDMHCg8.js';
|