vitest 3.0.8 → 3.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +12 -23
- package/dist/browser.js +2 -2
- package/dist/chunks/{base.XvKTsMeK.js → base.DV59CbtV.js} +1 -1
- package/dist/chunks/{benchmark.Cdu9hjj4.js → benchmark.DL72EVN-.js} +1 -1
- package/dist/chunks/{benchmark.CFFwLv-O.d.ts → benchmark.d.BwvBVTda.d.ts} +11 -11
- package/dist/chunks/{cac.VN5q-TPC.js → cac.BjmXy7OV.js} +11 -6
- package/dist/chunks/{cli-api.Dis64jtY.js → cli-api.BwkkJsRe.js} +13 -8
- package/dist/chunks/config.d.DevWltVl.d.ts +218 -0
- package/dist/chunks/{constants.fzPh7AOq.js → constants.DTYd6dNH.js} +1 -1
- package/dist/chunks/{coverage.DnNIv-kJ.js → coverage.A3sS5-Wm.js} +1 -29
- package/dist/chunks/coverage.d.S9RMNXIe.d.ts +35 -0
- package/dist/chunks/{resolveConfig.L1_HR0_0.js → coverage.gV8doR2Y.js} +496 -127
- package/dist/chunks/{creator.2CFRE1Yx.js → creator.BsBnpTzI.js} +1 -1
- package/dist/chunks/defaults.C2Ndd9wx.js +119 -0
- package/dist/chunks/env.D4Lgay0q.js +8 -0
- package/dist/chunks/environment.d.C8UItCbf.d.ts +170 -0
- package/dist/chunks/global.d.Cg2sEPIm.d.ts +127 -0
- package/dist/chunks/{globals.CydvVTgC.js → globals.BEpDe-k3.js} +4 -4
- package/dist/chunks/{index.CNRemkXW.js → index.D7Ny8f_s.js} +2 -2
- package/dist/chunks/{index.B7vJpkTD.js → index.DOyx6FYJ.js} +48 -18
- package/dist/chunks/{index.BmFgJtkv.js → index.uXkkC4xl.js} +1 -2
- package/dist/chunks/{mocker.cRtM890J.d.ts → mocker.d.BE_2ls6u.d.ts} +6 -6
- package/dist/chunks/reporters.d.r7poTZjA.d.ts +3012 -0
- package/dist/chunks/{runBaseTests.DnaAUBKD.js → runBaseTests.BVrL_ow3.js} +8 -8
- package/dist/chunks/{setup-common.Uaw6Zgv9.js → setup-common.CPvtqi8q.js} +25 -2
- package/dist/chunks/{suite.qtkXWc6R.d.ts → suite.d.FvehnV49.d.ts} +1 -1
- package/dist/chunks/{typechecker.cZ0LjdSi.js → typechecker.BlF3eHsb.js} +2 -7
- package/dist/chunks/{vi.B5EKKJdE.js → vi.nSCvwQ7l.js} +3 -3
- package/dist/chunks/vite.d.Fvq-NZoa.d.ts +11 -0
- package/dist/chunks/{worker.BmVno_ab.d.ts → worker.d.C58isfFm.d.ts} +62 -62
- package/dist/chunks/{worker.BT4v-DKx.d.ts → worker.d.CSFlSYJg.d.ts} +2 -2
- package/dist/cli.js +2 -2
- package/dist/config.d.ts +48 -45
- package/dist/config.js +6 -123
- package/dist/coverage.d.ts +82 -79
- package/dist/coverage.js +19 -469
- package/dist/environments.d.ts +11 -11
- package/dist/execute.d.ts +109 -109
- package/dist/index.d.ts +414 -412
- package/dist/index.js +3 -3
- package/dist/node.d.ts +51 -48
- package/dist/node.js +13 -10
- package/dist/reporters.d.ts +7 -4
- package/dist/reporters.js +3 -2
- package/dist/runners.d.ts +28 -28
- package/dist/runners.js +2 -3
- package/dist/snapshot.d.ts +2 -2
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +1 -1
- package/dist/workers/forks.js +1 -1
- package/dist/workers/runVmTests.js +8 -8
- package/dist/workers/threads.js +1 -1
- package/dist/workers.d.ts +13 -13
- package/dist/workers.js +1 -1
- package/package.json +11 -11
- package/dist/chunks/config.BCv-fVdT.d.ts +0 -215
- package/dist/chunks/environment.d8YfPkTm.d.ts +0 -173
- package/dist/chunks/global.CnI8_G5V.d.ts +0 -133
- package/dist/chunks/reporters.66aFHiyX.d.ts +0 -3051
- package/dist/chunks/vite.BCQa3xFG.d.ts +0 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { File as File$1, TaskResultPack as TaskResultPack$1, TaskEventPack, TaskPopulated, Suite as Suite$1, Test as Test$1, Custom as Custom$1, Task as Task$1, TaskBase as TaskBase$1, TaskResult as TaskResult$1, DoneCallback as DoneCallback$1, RuntimeContext as RuntimeContext$1, SuiteHooks as SuiteHooks$1, SequenceHooks as SequenceHooks$1, SequenceSetupFiles as SequenceSetupFiles$1 } from '@vitest/runner';
|
|
2
2
|
export { CancelReason, ExtendedContext, HookCleanupCallback, HookListener, OnTestFailedHandler, OnTestFinishedHandler, RunMode, Custom as RunnerCustomCase, Task as RunnerTask, TaskBase as RunnerTaskBase, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SuiteAPI, SuiteCollector, SuiteFactory, TaskContext, TaskCustomOptions, TaskMeta, TaskState, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
3
|
-
import { S as SerializedTestSpecification,
|
|
4
|
-
import { W as WorkerContext$1 } from './chunks/worker.
|
|
5
|
-
import { R as RawErrsMap$1, T as TscErrorInfo$1, C as CollectLineNumbers$1, a as CollectLines$1, b as RootAndTarget$1, c as Context$1 } from './chunks/global.
|
|
6
|
-
import { b as Awaitable$1, U as UserConsoleLog, M as ModuleGraphData, P as ProvidedContext, N as Nullable$1, c as Arrayable$1, d as ArgumentsType$1, e as MutableArray$1, C as Constructable$1, a as EnvironmentReturn$1, V as VmEnvironmentReturn$1, E as Environment$1, R as ResolvedTestEnvironment$1, J as JSDOMOptions$1, H as HappyDOMOptions$1, f as EnvironmentOptions$1 } from './chunks/environment.
|
|
7
|
-
export { A as AfterSuiteRunMeta, g as ModuleCache } from './chunks/environment.
|
|
8
|
-
import { a as BirpcReturn, b as WorkerRPC$1 } from './chunks/worker.
|
|
9
|
-
export { C as ContextRPC, d as ContextTestEnvironment, e as ResolveIdFunction, c as RunnerRPC, R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.
|
|
10
|
-
import './chunks/vite.
|
|
11
|
-
import { a as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.
|
|
12
|
-
export { b as RuntimeConfig, S as SerializedCoverageConfig } from './chunks/config.
|
|
3
|
+
import { S as SerializedTestSpecification, e as CoverageProvider$1, a as ReportContext$1, f as CoverageProviderModule$1, g as CoverageReporter$1, h as CoverageProviderName, i as CoverageOptions$1, R as ResolvedCoverageOptions$1, B as BaseCoverageOptions$1, j as CoverageIstanbulOptions$1, b as CoverageV8Options$1, k as CustomProviderOptions$1, l as Reporter$1, V as Vitest$1, m as BrowserScript$1, n as BrowserConfigOptions$1, o as BuiltinEnvironment$1, p as VitestEnvironment$1, P as Pool$1, q as PoolOptions$1, r as CSSModuleScopeStrategy$1, A as ApiConfig$1, s as VitestRunMode$1, D as DepsOptimizationOptions$1, t as TransformModePatterns$1, I as InlineConfig$1, u as TypecheckConfig$1, v as UserConfig$1, w as ResolvedConfig$1, x as ProjectConfig$1, U as UserWorkspaceConfig$1, y as BenchmarkUserOptions$1 } from './chunks/reporters.d.r7poTZjA.js';
|
|
4
|
+
import { W as WorkerContext$1 } from './chunks/worker.d.CSFlSYJg.js';
|
|
5
|
+
import { R as RawErrsMap$1, T as TscErrorInfo$1, C as CollectLineNumbers$1, a as CollectLines$1, b as RootAndTarget$1, c as Context$1 } from './chunks/global.d.Cg2sEPIm.js';
|
|
6
|
+
import { b as Awaitable$1, U as UserConsoleLog, M as ModuleGraphData, P as ProvidedContext, N as Nullable$1, c as Arrayable$1, d as ArgumentsType$1, e as MutableArray$1, C as Constructable$1, a as EnvironmentReturn$1, V as VmEnvironmentReturn$1, E as Environment$1, R as ResolvedTestEnvironment$1, J as JSDOMOptions$1, H as HappyDOMOptions$1, f as EnvironmentOptions$1 } from './chunks/environment.d.C8UItCbf.js';
|
|
7
|
+
export { A as AfterSuiteRunMeta, g as ModuleCache } from './chunks/environment.d.C8UItCbf.js';
|
|
8
|
+
import { a as BirpcReturn, b as WorkerRPC$1 } from './chunks/worker.d.C58isfFm.js';
|
|
9
|
+
export { C as ContextRPC, d as ContextTestEnvironment, e as ResolveIdFunction, c as RunnerRPC, R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.d.C58isfFm.js';
|
|
10
|
+
import './chunks/vite.d.Fvq-NZoa.js';
|
|
11
|
+
import { a as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.DevWltVl.js';
|
|
12
|
+
export { b as RuntimeConfig, S as SerializedCoverageConfig } from './chunks/config.d.DevWltVl.js';
|
|
13
13
|
import { ExpectStatic } from '@vitest/expect';
|
|
14
14
|
export { Assertion, AsymmetricMatchersContaining, ExpectPollOptions, ExpectStatic, JestAssertion } from '@vitest/expect';
|
|
15
15
|
import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
|
|
16
16
|
export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject } from '@vitest/spy';
|
|
17
|
-
import { M as MockFactoryWithHelper, a as MockOptions } from './chunks/mocker.
|
|
18
|
-
export { b as bench } from './chunks/suite.
|
|
19
|
-
export { a as BenchFunction, b as Benchmark, c as BenchmarkAPI, B as BenchmarkResult } from './chunks/benchmark.
|
|
17
|
+
import { M as MockFactoryWithHelper, a as MockOptions } from './chunks/mocker.d.BE_2ls6u.js';
|
|
18
|
+
export { b as bench } from './chunks/suite.d.FvehnV49.js';
|
|
19
|
+
export { a as BenchFunction, b as Benchmark, c as BenchmarkAPI, B as BenchmarkResult } from './chunks/benchmark.d.BwvBVTda.js';
|
|
20
20
|
export { ExpectTypeOf, expectTypeOf } from 'expect-type';
|
|
21
21
|
export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotSerializer, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
|
|
22
22
|
export { ErrorWithDiff, ParsedStack, SerializedError, TestError } from '@vitest/utils';
|
|
@@ -27,9 +27,12 @@ export { assert, should } from 'chai';
|
|
|
27
27
|
export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
|
|
28
28
|
import 'node:stream';
|
|
29
29
|
import 'vite';
|
|
30
|
+
import 'node:console';
|
|
30
31
|
import '@vitest/utils/source-map';
|
|
31
32
|
import '@vitest/pretty-format';
|
|
32
33
|
import 'vite-node';
|
|
34
|
+
import './chunks/coverage.d.S9RMNXIe.js';
|
|
35
|
+
import 'vite-node/client';
|
|
33
36
|
import '@vitest/snapshot/manager';
|
|
34
37
|
import 'node:fs';
|
|
35
38
|
import 'node:worker_threads';
|
|
@@ -38,49 +41,49 @@ import '@vitest/mocker';
|
|
|
38
41
|
import '@vitest/runner/utils';
|
|
39
42
|
|
|
40
43
|
interface SourceMap {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
file: string;
|
|
45
|
+
mappings: string;
|
|
46
|
+
names: string[];
|
|
47
|
+
sources: string[];
|
|
48
|
+
sourcesContent?: string[];
|
|
49
|
+
version: number;
|
|
50
|
+
toString: () => string;
|
|
51
|
+
toUrl: () => string;
|
|
49
52
|
}
|
|
50
53
|
interface TransformResultWithSource {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
code: string;
|
|
55
|
+
map: SourceMap | {
|
|
56
|
+
mappings: ""
|
|
57
|
+
} | null;
|
|
58
|
+
etag?: string;
|
|
59
|
+
deps?: string[];
|
|
60
|
+
dynamicDeps?: string[];
|
|
61
|
+
source?: string;
|
|
59
62
|
}
|
|
60
63
|
interface WebSocketHandlers {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
onTaskUpdate: (packs: TaskResultPack$1[], events: TaskEventPack[]) => void;
|
|
65
|
+
getFiles: () => File$1[];
|
|
66
|
+
getTestFiles: () => Promise<SerializedTestSpecification[]>;
|
|
67
|
+
getPaths: () => string[];
|
|
68
|
+
getConfig: () => SerializedConfig;
|
|
69
|
+
getResolvedProjectNames: () => string[];
|
|
70
|
+
getModuleGraph: (projectName: string, id: string, browser?: boolean) => Promise<ModuleGraphData>;
|
|
71
|
+
getTransformResult: (projectName: string, id: string, browser?: boolean) => Promise<TransformResultWithSource | undefined>;
|
|
72
|
+
readTestFile: (id: string) => Promise<string | null>;
|
|
73
|
+
saveTestFile: (id: string, content: string) => Promise<void>;
|
|
74
|
+
rerun: (files: string[], resetTestNamePattern?: boolean) => Promise<void>;
|
|
75
|
+
rerunTask: (id: string) => Promise<void>;
|
|
76
|
+
updateSnapshot: (file?: File$1) => Promise<void>;
|
|
77
|
+
getUnhandledErrors: () => unknown[];
|
|
75
78
|
}
|
|
76
79
|
interface WebSocketEvents {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
onCollected?: (files?: File$1[]) => Awaitable$1<void>;
|
|
81
|
+
onFinished?: (files: File$1[], errors: unknown[], coverage?: unknown) => Awaitable$1<void>;
|
|
82
|
+
onTaskUpdate?: (packs: TaskResultPack$1[]) => Awaitable$1<void>;
|
|
83
|
+
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable$1<void>;
|
|
84
|
+
onPathsCollected?: (paths?: string[]) => Awaitable$1<void>;
|
|
85
|
+
onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable$1<void>;
|
|
86
|
+
onFinishedReportCoverage: () => void;
|
|
84
87
|
}
|
|
85
88
|
type WebSocketRPC = BirpcReturn<WebSocketEvents, WebSocketHandlers>;
|
|
86
89
|
|
|
@@ -88,395 +91,394 @@ declare function createExpect(test?: TaskPopulated): ExpectStatic;
|
|
|
88
91
|
declare const globalExpect: ExpectStatic;
|
|
89
92
|
|
|
90
93
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
* Gives access to injected context provided from the main thread.
|
|
95
|
+
* This usually returns a value provided by `globalSetup` or an external library.
|
|
96
|
+
*/
|
|
94
97
|
declare function inject<T extends keyof ProvidedContext & string>(key: T): ProvidedContext[T];
|
|
95
98
|
|
|
96
99
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
* This utils allows computational intensive tasks to only be ran once
|
|
101
|
+
* across test reruns to improve the watch mode performance.
|
|
102
|
+
*
|
|
103
|
+
* Currently only works with `poolOptions.<pool>.isolate: false`
|
|
104
|
+
*
|
|
105
|
+
* @experimental
|
|
106
|
+
*/
|
|
104
107
|
declare function runOnce<T>(fn: () => T, key?: string): T;
|
|
105
108
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
* Get a boolean indicates whether the task is running in the first time.
|
|
110
|
+
* Could only be `false` in watch mode.
|
|
111
|
+
*
|
|
112
|
+
* Currently only works with `isolate: false`
|
|
113
|
+
*
|
|
114
|
+
* @experimental
|
|
115
|
+
*/
|
|
113
116
|
declare function isFirstRun(): boolean;
|
|
114
117
|
|
|
115
|
-
declare function getRunningMode():
|
|
118
|
+
declare function getRunningMode(): "watch" | "run";
|
|
116
119
|
declare function isWatchMode(): boolean;
|
|
117
120
|
|
|
118
121
|
type WaitForCallback<T> = () => T | Promise<T>;
|
|
119
122
|
interface WaitForOptions {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
/**
|
|
124
|
+
* @description Time in ms between each check callback
|
|
125
|
+
* @default 50ms
|
|
126
|
+
*/
|
|
127
|
+
interval?: number;
|
|
128
|
+
/**
|
|
129
|
+
* @description Time in ms after which the throw a timeout error
|
|
130
|
+
* @default 1000ms
|
|
131
|
+
*/
|
|
132
|
+
timeout?: number;
|
|
130
133
|
}
|
|
131
134
|
declare function waitFor<T>(callback: WaitForCallback<T>, options?: number | WaitForOptions): Promise<T>;
|
|
132
135
|
type WaitUntilCallback<T> = () => T | Promise<T>;
|
|
133
|
-
interface WaitUntilOptions extends Pick<WaitForOptions,
|
|
134
|
-
|
|
135
|
-
type Truthy<T> = T extends false | '' | 0 | null | undefined ? never : T;
|
|
136
|
+
interface WaitUntilOptions extends Pick<WaitForOptions, "interval" | "timeout"> {}
|
|
137
|
+
type Truthy<T> = T extends false | "" | 0 | null | undefined ? never : T;
|
|
136
138
|
declare function waitUntil<T>(callback: WaitUntilCallback<T>, options?: number | WaitUntilOptions): Promise<Truthy<T>>;
|
|
137
139
|
|
|
138
140
|
type ESModuleExports = Record<string, unknown>;
|
|
139
141
|
interface VitestUtils {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Checks if fake timers are enabled.
|
|
144
|
+
*/
|
|
145
|
+
isFakeTimers: () => boolean;
|
|
146
|
+
/**
|
|
147
|
+
* This method wraps all further calls to timers until [`vi.useRealTimers()`](https://vitest.dev/api/vi#vi-userealtimers) is called.
|
|
148
|
+
*/
|
|
149
|
+
useFakeTimers: (config?: FakeTimerInstallOpts) => VitestUtils;
|
|
150
|
+
/**
|
|
151
|
+
* Restores mocked timers to their original implementations. All timers that were scheduled before will be discarded.
|
|
152
|
+
*/
|
|
153
|
+
useRealTimers: () => VitestUtils;
|
|
154
|
+
/**
|
|
155
|
+
* This method will call every timer that was initiated after [`vi.useFakeTimers`](https://vitest.dev/api/vi#vi-usefaketimers) call.
|
|
156
|
+
* It will not fire any timer that was initiated during its call.
|
|
157
|
+
*/
|
|
158
|
+
runOnlyPendingTimers: () => VitestUtils;
|
|
159
|
+
/**
|
|
160
|
+
* This method will asynchronously call every timer that was initiated after [`vi.useFakeTimers`](https://vitest.dev/api/vi#vi-usefaketimers) call, even asynchronous ones.
|
|
161
|
+
* It will not fire any timer that was initiated during its call.
|
|
162
|
+
*/
|
|
163
|
+
runOnlyPendingTimersAsync: () => Promise<VitestUtils>;
|
|
164
|
+
/**
|
|
165
|
+
* This method will invoke every initiated timer until the timer queue is empty. It means that every timer called during `runAllTimers` will be fired.
|
|
166
|
+
* If you have an infinite interval, it will throw after 10,000 tries (can be configured with [`fakeTimers.loopLimit`](https://vitest.dev/config/#faketimers-looplimit)).
|
|
167
|
+
*/
|
|
168
|
+
runAllTimers: () => VitestUtils;
|
|
169
|
+
/**
|
|
170
|
+
* This method will asynchronously invoke every initiated timer until the timer queue is empty. It means that every timer called during `runAllTimersAsync` will be fired even asynchronous timers.
|
|
171
|
+
* If you have an infinite interval, it will throw after 10 000 tries (can be configured with [`fakeTimers.loopLimit`](https://vitest.dev/config/#faketimers-looplimit)).
|
|
172
|
+
*/
|
|
173
|
+
runAllTimersAsync: () => Promise<VitestUtils>;
|
|
174
|
+
/**
|
|
175
|
+
* Calls every microtask that was queued by `process.nextTick`. This will also run all microtasks scheduled by themselves.
|
|
176
|
+
*/
|
|
177
|
+
runAllTicks: () => VitestUtils;
|
|
178
|
+
/**
|
|
179
|
+
* This method will invoke every initiated timer until the specified number of milliseconds is passed or the queue is empty - whatever comes first.
|
|
180
|
+
*/
|
|
181
|
+
advanceTimersByTime: (ms: number) => VitestUtils;
|
|
182
|
+
/**
|
|
183
|
+
* This method will invoke every initiated timer until the specified number of milliseconds is passed or the queue is empty - whatever comes first. This will include and await asynchronously set timers.
|
|
184
|
+
*/
|
|
185
|
+
advanceTimersByTimeAsync: (ms: number) => Promise<VitestUtils>;
|
|
186
|
+
/**
|
|
187
|
+
* Will call next available timer. Useful to make assertions between each timer call. You can chain call it to manage timers by yourself.
|
|
188
|
+
*/
|
|
189
|
+
advanceTimersToNextTimer: () => VitestUtils;
|
|
190
|
+
/**
|
|
191
|
+
* Will call next available timer and wait until it's resolved if it was set asynchronously. Useful to make assertions between each timer call.
|
|
192
|
+
*/
|
|
193
|
+
advanceTimersToNextTimerAsync: () => Promise<VitestUtils>;
|
|
194
|
+
/**
|
|
195
|
+
* Similar to [`vi.advanceTimersByTime`](https://vitest.dev/api/vi#vi-advancetimersbytime), but will advance timers by the milliseconds needed to execute callbacks currently scheduled with `requestAnimationFrame`.
|
|
196
|
+
*/
|
|
197
|
+
advanceTimersToNextFrame: () => VitestUtils;
|
|
198
|
+
/**
|
|
199
|
+
* Get the number of waiting timers.
|
|
200
|
+
*/
|
|
201
|
+
getTimerCount: () => number;
|
|
202
|
+
/**
|
|
203
|
+
* 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.
|
|
204
|
+
* If fake timers are not enabled, this method will only mock `Date.*` and `new Date()` calls.
|
|
205
|
+
*/
|
|
206
|
+
setSystemTime: (time: number | string | Date) => VitestUtils;
|
|
207
|
+
/**
|
|
208
|
+
* Returns mocked current date. If date is not mocked the method will return `null`.
|
|
209
|
+
*/
|
|
210
|
+
getMockedSystemTime: () => Date | null;
|
|
211
|
+
/**
|
|
212
|
+
* When using `vi.useFakeTimers`, `Date.now` calls are mocked. If you need to get real time in milliseconds, you can call this function.
|
|
213
|
+
*/
|
|
214
|
+
getRealSystemTime: () => number;
|
|
215
|
+
/**
|
|
216
|
+
* Removes all timers that are scheduled to run. These timers will never run in the future.
|
|
217
|
+
*/
|
|
218
|
+
clearAllTimers: () => VitestUtils;
|
|
219
|
+
/**
|
|
220
|
+
* Creates a spy on a method or getter/setter of an object similar to [`vi.fn()`](https://vitest.dev/api/vi#vi-fn). It returns a [mock function](https://vitest.dev/api/mock).
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* const cart = {
|
|
224
|
+
* getApples: () => 42
|
|
225
|
+
* }
|
|
226
|
+
*
|
|
227
|
+
* const spy = vi.spyOn(cart, 'getApples').mockReturnValue(10)
|
|
228
|
+
*
|
|
229
|
+
* expect(cart.getApples()).toBe(10)
|
|
230
|
+
* expect(spy).toHaveBeenCalled()
|
|
231
|
+
* expect(spy).toHaveReturnedWith(10)
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
spyOn: typeof spyOn;
|
|
235
|
+
/**
|
|
236
|
+
* Creates a spy on a function, though can be initiated without one. Every time a function is invoked, it stores its call arguments, returns, and instances. Also, you can manipulate its behavior with [methods](https://vitest.dev/api/mock).
|
|
237
|
+
*
|
|
238
|
+
* If no function is given, mock will return `undefined`, when invoked.
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* const getApples = vi.fn(() => 0)
|
|
242
|
+
*
|
|
243
|
+
* getApples()
|
|
244
|
+
*
|
|
245
|
+
* expect(getApples).toHaveBeenCalled()
|
|
246
|
+
* expect(getApples).toHaveReturnedWith(0)
|
|
247
|
+
*
|
|
248
|
+
* getApples.mockReturnValueOnce(5)
|
|
249
|
+
*
|
|
250
|
+
* expect(getApples()).toBe(5)
|
|
251
|
+
* expect(getApples).toHaveNthReturnedWith(2, 5)
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
fn: typeof fn;
|
|
255
|
+
/**
|
|
256
|
+
* 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.
|
|
257
|
+
*
|
|
258
|
+
* This is very useful when you need to wait for some asynchronous action to complete, for example, when you start a server and need to wait for it to start.
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* const server = createServer()
|
|
262
|
+
*
|
|
263
|
+
* await vi.waitFor(
|
|
264
|
+
* () => {
|
|
265
|
+
* if (!server.isReady)
|
|
266
|
+
* throw new Error('Server not started')
|
|
267
|
+
*
|
|
268
|
+
* console.log('Server started')
|
|
269
|
+
* }, {
|
|
270
|
+
* timeout: 500, // default is 1000
|
|
271
|
+
* interval: 20, // default is 50
|
|
272
|
+
* }
|
|
273
|
+
* )
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
waitFor: typeof waitFor;
|
|
277
|
+
/**
|
|
278
|
+
* This is similar to [`vi.waitFor`](https://vitest.dev/api/vi#vi-waitfor), but if the callback throws any errors, execution is immediately interrupted and an error message is received.
|
|
279
|
+
*
|
|
280
|
+
* If the callback returns a falsy value, the next check will continue until a truthy value is returned. This is useful when you need to wait for something to exist before taking the next step.
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts
|
|
283
|
+
* const element = await vi.waitUntil(
|
|
284
|
+
* () => document.querySelector('.element'),
|
|
285
|
+
* {
|
|
286
|
+
* timeout: 500, // default is 1000
|
|
287
|
+
* interval: 20, // default is 50
|
|
288
|
+
* }
|
|
289
|
+
* )
|
|
290
|
+
*
|
|
291
|
+
* // do something with the element
|
|
292
|
+
* expect(element.querySelector('.element-child')).toBeTruthy()
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
waitUntil: typeof waitUntil;
|
|
296
|
+
/**
|
|
297
|
+
* Run the factory before imports are evaluated. You can return a value from the factory
|
|
298
|
+
* to reuse it inside your [`vi.mock`](https://vitest.dev/api/vi#vi-mock) factory and tests.
|
|
299
|
+
*
|
|
300
|
+
* If used with [`vi.mock`](https://vitest.dev/api/vi#vi-mock), both will be hoisted in the order they are defined in.
|
|
301
|
+
*/
|
|
302
|
+
hoisted: <T>(factory: () => T) => T;
|
|
303
|
+
/**
|
|
304
|
+
* Mocks every import call to the module even if it was already statically imported.
|
|
305
|
+
*
|
|
306
|
+
* The call to `vi.mock` is hoisted to the top of the file, so you don't have access to variables declared in the global file scope
|
|
307
|
+
* unless they are defined with [`vi.hoisted`](https://vitest.dev/api/vi#vi-hoisted) before this call.
|
|
308
|
+
*
|
|
309
|
+
* Mocking algorithm is described in [documentation](https://vitest.dev/guide/mocking#modules).
|
|
310
|
+
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
|
311
|
+
* @param factory Mocked module factory. The result of this function will be an exports object
|
|
312
|
+
*/
|
|
313
|
+
mock(path: string, factory?: MockFactoryWithHelper | MockOptions): void;
|
|
314
|
+
mock<T>(module: Promise<T>, factory?: MockFactoryWithHelper<T> | MockOptions): void;
|
|
315
|
+
/**
|
|
316
|
+
* Removes module from mocked registry. All calls to import will return the original module even if it was mocked before.
|
|
317
|
+
*
|
|
318
|
+
* This call is hoisted to the top of the file, so it will only unmock modules that were defined in `setupFiles`, for example.
|
|
319
|
+
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
|
320
|
+
*/
|
|
321
|
+
unmock(path: string): void;
|
|
322
|
+
unmock(module: Promise<unknown>): void;
|
|
323
|
+
/**
|
|
324
|
+
* Mocks every subsequent [dynamic import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) call.
|
|
325
|
+
*
|
|
326
|
+
* Unlike [`vi.mock`](https://vitest.dev/api/vi#vi-mock), this method will not mock statically imported modules because it is not hoisted to the top of the file.
|
|
327
|
+
*
|
|
328
|
+
* Mocking algorithm is described in [documentation](https://vitest.dev/guide/mocking#modules).
|
|
329
|
+
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
|
330
|
+
* @param factory Mocked module factory. The result of this function will be an exports object
|
|
331
|
+
*/
|
|
332
|
+
doMock(path: string, factory?: MockFactoryWithHelper | MockOptions): void;
|
|
333
|
+
doMock<T>(module: Promise<T>, factory?: MockFactoryWithHelper<T> | MockOptions): void;
|
|
334
|
+
/**
|
|
335
|
+
* Removes module from mocked registry. All subsequent calls to import will return original module.
|
|
336
|
+
*
|
|
337
|
+
* Unlike [`vi.unmock`](https://vitest.dev/api/vi#vi-unmock), this method is not hoisted to the top of the file.
|
|
338
|
+
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
|
339
|
+
*/
|
|
340
|
+
doUnmock(path: string): void;
|
|
341
|
+
doUnmock(module: Promise<unknown>): void;
|
|
342
|
+
/**
|
|
343
|
+
* Imports module, bypassing all checks if it should be mocked.
|
|
344
|
+
* Can be useful if you want to mock module partially.
|
|
345
|
+
* @example
|
|
346
|
+
* ```ts
|
|
347
|
+
* vi.mock('./example.js', async () => {
|
|
348
|
+
* const axios = await vi.importActual<typeof import('./example.js')>('./example.js')
|
|
349
|
+
*
|
|
350
|
+
* return { ...axios, get: vi.fn() }
|
|
351
|
+
* })
|
|
352
|
+
* ```
|
|
353
|
+
* @param path Path to the module. Can be aliased, if your config supports it
|
|
354
|
+
*/
|
|
355
|
+
importActual: <T = ESModuleExports>(path: string) => Promise<T>;
|
|
356
|
+
/**
|
|
357
|
+
* Imports a module with all of its properties and nested properties mocked.
|
|
358
|
+
*
|
|
359
|
+
* Mocking algorithm is described in [documentation](https://vitest.dev/guide/mocking#modules).
|
|
360
|
+
* @example
|
|
361
|
+
* ```ts
|
|
362
|
+
* const example = await vi.importMock<typeof import('./example.js')>('./example.js')
|
|
363
|
+
* example.calc.mockReturnValue(10)
|
|
364
|
+
* expect(example.calc()).toBe(10)
|
|
365
|
+
* ```
|
|
366
|
+
* @param path Path to the module. Can be aliased, if your config supports it
|
|
367
|
+
* @returns Fully mocked module
|
|
368
|
+
*/
|
|
369
|
+
importMock: <T = ESModuleExports>(path: string) => Promise<MaybeMockedDeep<T>>;
|
|
370
|
+
/**
|
|
371
|
+
* Type helper for TypeScript. Just returns the object that was passed.
|
|
372
|
+
*
|
|
373
|
+
* When `partial` is `true` it will expect a `Partial<T>` as a return value. By default, this will only make TypeScript believe that
|
|
374
|
+
* the first level values are mocked. You can pass down `{ deep: true }` as a second argument to tell TypeScript that the whole object is mocked, if it actually is.
|
|
375
|
+
* @example
|
|
376
|
+
* ```ts
|
|
377
|
+
* import example from './example.js'
|
|
378
|
+
* vi.mock('./example.js')
|
|
379
|
+
*
|
|
380
|
+
* test('1 + 1 equals 10' async () => {
|
|
381
|
+
* vi.mocked(example.calc).mockReturnValue(10)
|
|
382
|
+
* expect(example.calc(1, '+', 1)).toBe(10)
|
|
383
|
+
* })
|
|
384
|
+
* ```
|
|
385
|
+
* @param item Anything that can be mocked
|
|
386
|
+
* @param deep If the object is deeply mocked
|
|
387
|
+
* @param options If the object is partially or deeply mocked
|
|
388
|
+
*/
|
|
389
|
+
mocked: (<T>(item: T, deep?: false) => MaybeMocked<T>) & (<T>(item: T, deep: true) => MaybeMockedDeep<T>) & (<T>(item: T, options: {
|
|
390
|
+
partial?: false
|
|
391
|
+
deep?: false
|
|
392
|
+
}) => MaybeMocked<T>) & (<T>(item: T, options: {
|
|
393
|
+
partial?: false
|
|
394
|
+
deep: true
|
|
395
|
+
}) => MaybeMockedDeep<T>) & (<T>(item: T, options: {
|
|
396
|
+
partial: true
|
|
397
|
+
deep?: false
|
|
398
|
+
}) => MaybePartiallyMocked<T>) & (<T>(item: T, options: {
|
|
399
|
+
partial: true
|
|
400
|
+
deep: true
|
|
401
|
+
}) => MaybePartiallyMockedDeep<T>) & (<T>(item: T) => MaybeMocked<T>);
|
|
402
|
+
/**
|
|
403
|
+
* Checks that a given parameter is a mock function. If you are using TypeScript, it will also narrow down its type.
|
|
404
|
+
*/
|
|
405
|
+
isMockFunction: (fn: any) => fn is MockInstance;
|
|
406
|
+
/**
|
|
407
|
+
* Calls [`.mockClear()`](https://vitest.dev/api/mock#mockclear) on every mocked function.
|
|
408
|
+
*
|
|
409
|
+
* This will only empty `.mock` state, it will not affect mock implementations.
|
|
410
|
+
*
|
|
411
|
+
* This is useful if you need to clean up mocks between different assertions within a test.
|
|
412
|
+
*/
|
|
413
|
+
clearAllMocks: () => VitestUtils;
|
|
414
|
+
/**
|
|
415
|
+
* Calls [`.mockReset()`](https://vitest.dev/api/mock#mockreset) on every mocked function.
|
|
416
|
+
*
|
|
417
|
+
* This will empty `.mock` state, reset "once" implementations, and reset each mock's base implementation to its original.
|
|
418
|
+
*
|
|
419
|
+
* This is useful when you want to reset all mocks to their original states.
|
|
420
|
+
*/
|
|
421
|
+
resetAllMocks: () => VitestUtils;
|
|
422
|
+
/**
|
|
423
|
+
* Calls [`.mockRestore()`](https://vitest.dev/api/mock#mockrestore) on every mocked function.
|
|
424
|
+
*
|
|
425
|
+
* This will empty `.mock` state, restore all original mock implementations, and restore original descriptors of spied-on objects.
|
|
426
|
+
*
|
|
427
|
+
* This is useful for inter-test cleanup and/or removing mocks created by [`vi.spyOn(...)`](https://vitest.dev/api/vi#vi-spyon).
|
|
428
|
+
*/
|
|
429
|
+
restoreAllMocks: () => VitestUtils;
|
|
430
|
+
/**
|
|
431
|
+
* Makes value available on global namespace.
|
|
432
|
+
* Useful, if you want to have global variables available, like `IntersectionObserver`.
|
|
433
|
+
* You can return it back to original value with `vi.unstubAllGlobals`, or by enabling `unstubGlobals` config option.
|
|
434
|
+
*/
|
|
435
|
+
stubGlobal: (name: string | symbol | number, value: unknown) => VitestUtils;
|
|
436
|
+
/**
|
|
437
|
+
* Changes the value of `import.meta.env` and `process.env`.
|
|
438
|
+
* You can return it back to original value with `vi.unstubAllEnvs`, or by enabling `unstubEnvs` config option.
|
|
439
|
+
*/
|
|
440
|
+
stubEnv: <T extends string>(name: T, value: T extends "PROD" | "DEV" | "SSR" ? boolean : string | undefined) => VitestUtils;
|
|
441
|
+
/**
|
|
442
|
+
* Reset the value to original value that was available before first `vi.stubGlobal` was called.
|
|
443
|
+
*/
|
|
444
|
+
unstubAllGlobals: () => VitestUtils;
|
|
445
|
+
/**
|
|
446
|
+
* Reset environmental variables to the ones that were available before first `vi.stubEnv` was called.
|
|
447
|
+
*/
|
|
448
|
+
unstubAllEnvs: () => VitestUtils;
|
|
449
|
+
/**
|
|
450
|
+
* Resets modules registry by clearing the cache of all modules. This allows modules to be reevaluated when reimported.
|
|
451
|
+
* Top-level imports cannot be re-evaluated. Might be useful to isolate modules where local state conflicts between tests.
|
|
452
|
+
*
|
|
453
|
+
* This method does not reset mocks registry. To clear mocks registry, use [`vi.unmock`](https://vitest.dev/api/vi#vi-unmock) or [`vi.doUnmock`](https://vitest.dev/api/vi#vi-dounmock).
|
|
454
|
+
*/
|
|
455
|
+
resetModules: () => VitestUtils;
|
|
456
|
+
/**
|
|
457
|
+
* Wait for all imports to load. Useful, if you have a synchronous call that starts
|
|
458
|
+
* importing a module that you cannot await otherwise.
|
|
459
|
+
* Will also wait for new imports, started during the wait.
|
|
460
|
+
*/
|
|
461
|
+
dynamicImportSettled: () => Promise<void>;
|
|
462
|
+
/**
|
|
463
|
+
* Updates runtime config. You can only change values that are used when executing tests.
|
|
464
|
+
*/
|
|
465
|
+
setConfig: (config: RuntimeOptions) => void;
|
|
466
|
+
/**
|
|
467
|
+
* If config was changed with `vi.setConfig`, this will reset it to the original state.
|
|
468
|
+
*/
|
|
469
|
+
resetConfig: () => void;
|
|
468
470
|
}
|
|
469
471
|
declare const vitest: VitestUtils;
|
|
470
472
|
declare const vi: VitestUtils;
|
|
471
473
|
|
|
472
474
|
interface AssertType {
|
|
473
|
-
|
|
475
|
+
<T>(value: T): void;
|
|
474
476
|
}
|
|
475
477
|
declare const assertType: AssertType;
|
|
476
478
|
|
|
477
479
|
interface BrowserUI {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
+
setCurrentFileId: (fileId: string) => void;
|
|
481
|
+
setIframeViewport: (width: number, height: number) => Promise<void>;
|
|
480
482
|
}
|
|
481
483
|
|
|
482
484
|
/** @deprecated import `TypeCheckRawErrorsMap` from `vitest/node` instead */
|