import { File, TaskResultPack, CancelReason } from '@vitest/runner'; export { DoneCallback, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner'; import { v as BenchmarkAPI, m as FakeTimerInstallOpts, w as MockFactoryWithHelper, x as RuntimeConfig, A as AfterSuiteRunMeta, y as UserConsoleLog, R as ResolvedConfig, z as ModuleGraphData, D as Reporter } from './types-198fd1d9.js'; export { a2 as ApiConfig, ah as ArgumentsType, ag as Arrayable, ae as Awaitable, B as BaseCoverageOptions, as as BenchFunction, aq as Benchmark, ar as BenchmarkResult, ap as BenchmarkUserOptions, _ as BuiltinEnvironment, a1 as CSSModuleScopeStrategy, K as ChaiConfig, Q as CollectLineNumbers, S as CollectLines, aj as Constructable, Y as Context, aa as ContextRPC, a9 as ContextTestEnvironment, e as CoverageC8Options, g as CoverageIstanbulOptions, C as CoverageOptions, a as CoverageProvider, b as CoverageProviderModule, ao as CoverageReporter, d as CoverageV8Options, f as CustomProviderOptions, a4 as DepsOptimizationOptions, E as Environment, a3 as EnvironmentOptions, al as EnvironmentReturn, a5 as InlineConfig, Z as JSDOMOptions, ak as ModuleCache, ai as MutableArray, af as Nullable, am as OnServerRestartHandler, n as ProjectConfig, N as RawErrsMap, an as ReportContext, ac as ResolveIdFunction, c as ResolvedCoverageOptions, X as RootAndTarget, a8 as RunnerRPC, a7 as RuntimeRPC, O as TscErrorInfo, a6 as TypecheckConfig, U as UserConfig, o as Vitest, $ as VitestEnvironment, a0 as VitestPool, V as VitestRunMode, ab as WorkerContext, ad as WorkerGlobalState, I as createExpect, G as expect, J as setupChaiConfig } from './types-198fd1d9.js'; import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, EnhancedSpy } from '@vitest/spy'; export { EnhancedSpy, Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy'; export { SnapshotEnvironment } from '@vitest/snapshot/environment'; import { SnapshotResult } from '@vitest/snapshot'; export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot'; export { Assertion, AsymmetricMatchersContaining, ExpectStatic, JestAssertion } from '@vitest/expect'; import { TransformResult } from 'vite'; import * as chai from 'chai'; export { chai }; export { assert, should } from 'chai'; export { UserWorkspaceConfig } from './config.js'; export { ErrorWithDiff, ParsedStack } from '@vitest/utils'; export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench'; import '@vitest/runner/utils'; import 'vite-node/client'; import '@vitest/snapshot/manager'; import 'vite-node/server'; import 'node:worker_threads'; import 'vite-node'; import 'node:fs'; declare type Not = T extends true ? false : true; declare type And = Types[number] extends true ? true : false; declare type Eq = Left extends true ? Right : Not; declare const secret: unique symbol; declare type Secret = typeof secret; declare type IsNever = [T] extends [never] ? true : false; declare type IsAny = [T] extends [Secret] ? Not> : false; declare type IsUnknown = [unknown] extends [T] ? Not> : false; /** * Recursively walk a type and replace it with a branded type related to the original. This is useful for * equality-checking stricter than `A extends B ? B extends A ? true : false : false`, because it detects * the difference between a few edge-case types that vanilla typescript doesn't by default: * - `any` vs `unknown` * - `{ readonly a: string }` vs `{ a: string }` * - `{ a?: string }` vs `{ a: string | undefined }` */ declare type DeepBrand = IsNever extends true ? { type: 'never'; } : IsAny extends true ? { type: 'any'; } : IsUnknown extends true ? { type: 'unknown'; } : T extends string | number | boolean | symbol | bigint | null | undefined | void ? { type: 'primitive'; value: T; } : T extends new (...args: any[]) => any ? { type: 'constructor'; params: ConstructorParams; instance: DeepBrand any>>>; } : T extends (...args: infer P) => infer R ? { type: 'function'; params: DeepBrand

; return: DeepBrand; this: DeepBrand>; } : T extends any[] ? { type: 'array'; items: { [K in keyof T]: T[K]; }; } : { type: 'object'; properties: { [K in keyof T]: DeepBrand; }; readonly: ReadonlyKeys; required: RequiredKeys; optional: OptionalKeys; constructorParams: DeepBrand>; }; declare type RequiredKeys = Extract<{ [K in keyof T]-?: {} extends Pick ? never : K; }[keyof T], keyof T>; declare type OptionalKeys = Exclude>; declare type ReadonlyKeys = Extract<{ [K in keyof T]-?: ReadonlyEquivalent<{ [_K in K]: T[K]; }, { -readonly [_K in K]: T[K]; }> extends true ? never : K; }[keyof T], keyof T>; declare type ReadonlyEquivalent = Extends<(() => T extends X ? true : false), (() => T extends Y ? true : false)>; declare type Extends = IsNever extends true ? IsNever : [L] extends [R] ? true : false; declare type StrictExtends = Extends, DeepBrand>; declare type StrictEqual = (() => T extends (L & T) | T ? true : false) extends () => T extends (R & T) | T ? true : false ? IsNever extends IsNever ? true : false : false; declare type Equal = Branded extends true ? And<[StrictExtends, StrictExtends]> : StrictEqual; declare type Params = Actual extends (...args: infer P) => any ? P : never; declare type ConstructorParams = Actual extends new (...args: infer P) => any ? Actual extends new () => any ? P | [] : P : never; declare type MismatchArgs = Eq extends true ? [] : [never]; interface ExpectTypeOfOptions { positive: boolean; branded: boolean; } interface ExpectTypeOf { toBeAny: (...MISMATCH: MismatchArgs, Options['positive']>) => true; toBeUnknown: (...MISMATCH: MismatchArgs, Options['positive']>) => true; toBeNever: (...MISMATCH: MismatchArgs, Options['positive']>) => true; toBeFunction: (...MISMATCH: MismatchArgs any>, Options['positive']>) => true; toBeObject: (...MISMATCH: MismatchArgs, Options['positive']>) => true; toBeArray: (...MISMATCH: MismatchArgs, Options['positive']>) => true; toBeNumber: (...MISMATCH: MismatchArgs, Options['positive']>) => true; toBeString: (...MISMATCH: MismatchArgs, Options['positive']>) => true; toBeBoolean: (...MISMATCH: MismatchArgs, Options['positive']>) => true; toBeVoid: (...MISMATCH: MismatchArgs, Options['positive']>) => true; toBeSymbol: (...MISMATCH: MismatchArgs, Options['positive']>) => true; toBeNull: (...MISMATCH: MismatchArgs, Options['positive']>) => true; toBeUndefined: (...MISMATCH: MismatchArgs, Options['positive']>) => true; toBeNullable: (...MISMATCH: MismatchArgs, Options['branded']>>, Options['positive']>) => true; toMatchTypeOf: { (...MISMATCH: MismatchArgs, Options['positive']>): true; (expected: Expected, ...MISMATCH: MismatchArgs, Options['positive']>): true; }; toEqualTypeOf: { (...MISMATCH: MismatchArgs, Options['positive']>): true; (expected: Expected, ...MISMATCH: MismatchArgs, Options['positive']>): true; }; toBeCallableWith: Options['positive'] extends true ? (...args: Params) => true : never; toBeConstructibleWith: Options['positive'] extends true ? (...args: ConstructorParams) => true : never; toHaveProperty: (key: K, ...MISMATCH: MismatchArgs, Options['positive']>) => K extends keyof Actual ? ExpectTypeOf : true; extract: (v?: V) => ExpectTypeOf, Options>; exclude: (v?: V) => ExpectTypeOf, Options>; parameter: >(number: K) => ExpectTypeOf[K], Options>; parameters: ExpectTypeOf, Options>; constructorParameters: ExpectTypeOf, Options>; thisParameter: ExpectTypeOf, Options>; instance: Actual extends new (...args: any[]) => infer I ? ExpectTypeOf : never; returns: Actual extends (...args: any[]) => infer R ? ExpectTypeOf : never; resolves: Actual extends PromiseLike ? ExpectTypeOf : never; items: Actual extends ArrayLike ? ExpectTypeOf : never; guards: Actual extends (v: any, ...args: any[]) => v is infer T ? ExpectTypeOf : never; asserts: Actual extends (v: any, ...args: any[]) => asserts v is infer T ? unknown extends T ? never : ExpectTypeOf : never; branded: Omit, 'branded'>; not: Omit; branded: Options['branded']; }>, 'not'>; } declare type _ExpectTypeOf = { (actual: Actual): ExpectTypeOf; (): ExpectTypeOf; }; /** * Similar to Jest's `expect`, but with type-awareness. * Gives you access to a number of type-matchers that let you make assertions about the * form of a reference or generic type parameter. * * @example * import {foo, bar} from '../foo' * import {expectTypeOf} from 'expect-type' * * test('foo types', () => { * // make sure `foo` has type {a: number} * expectTypeOf(foo).toMatchTypeOf({a: 1}) * expectTypeOf(foo).toHaveProperty('a').toBeNumber() * * // make sure `bar` is a function taking a string: * expectTypeOf(bar).parameter(0).toBeString() * expectTypeOf(bar).returns.not.toBeAny() * }) * * @description * See the [full docs](https://npmjs.com/package/expect-type#documentation) for lots more examples. */ declare const expectTypeOf: _ExpectTypeOf; interface AssertType { (value: T): void; } declare const assertType: AssertType; declare const bench: BenchmarkAPI; /** * This utils allows computational intensive tasks to only be ran once * across test reruns to improve the watch mode performance. * * Currently only works with `isolate: false` * * @experimental */ declare function runOnce(fn: (() => T), key?: string): T; /** * Get a boolean indicates whether the task is running in the first time. * Could only be `false` in watch mode. * * Currently only works with `isolate: false` * * @experimental */ declare function isFirstRun(): boolean; interface VitestUtils { useFakeTimers(config?: FakeTimerInstallOpts): this; useRealTimers(): this; runOnlyPendingTimers(): this; runOnlyPendingTimersAsync(): Promise; runAllTimers(): this; runAllTimersAsync(): Promise; runAllTicks(): this; advanceTimersByTime(ms: number): this; advanceTimersByTimeAsync(ms: number): Promise; advanceTimersToNextTimer(): this; advanceTimersToNextTimerAsync(): Promise; getTimerCount(): number; setSystemTime(time: number | string | Date): this; getMockedSystemTime(): Date | null; getRealSystemTime(): number; clearAllTimers(): this; spyOn: typeof spyOn; fn: typeof fn; /** * Run the factory before imports are evaluated. You can return a value from the factory * to reuse it inside your `vi.mock` factory and tests. */ hoisted(factory: () => T): T; /** * Makes all `imports` to passed module to be mocked. * - If there is a factory, will return it's result. 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, if you didn't put them before imports! * - If `__mocks__` folder with file of the same name exist, all imports will * return it. * - If there is no `__mocks__` folder or a file with the same name inside, will call original * module and mock it. * @param path Path to the module. Can be aliased, if your config supports it * @param factory Factory for the mocked module. Has the highest priority. */ mock(path: string, factory?: MockFactoryWithHelper): void; /** * Removes module from mocked registry. All subsequent calls to import will * return original module even if it was mocked. * @param path Path to the module. Can be aliased, if your config supports it */ unmock(path: string): void; doMock(path: string, factory?: () => any): void; doUnmock(path: string): void; /** * Imports module, bypassing all checks if it should be mocked. * Can be useful if you want to mock module partially. * @example * vi.mock('./example', async () => { * const axios = await vi.importActual('./example') * * return { ...axios, get: vi.fn() } * }) * @param path Path to the module. Can be aliased, if your config supports it * @returns Actual module without spies */ importActual(path: string): Promise; /** * Imports a module with all of its properties and nested properties mocked. * For the rules applied, see docs. * @param path Path to the module. Can be aliased, if your config supports it * @returns Fully mocked module */ importMock(path: string): Promise>; /** * Type helpers for TypeScript. In reality just returns the object that was passed. * * When `partial` is `true` it will expect a `Partial` as a return value. * @example * import example from './example' * vi.mock('./example') * * test('1+1 equals 2' async () => { * vi.mocked(example.calc).mockRestore() * * const res = example.calc(1, '+', 1) * * expect(res).toBe(2) * }) * @param item Anything that can be mocked * @param deep If the object is deeply mocked * @param options If the object is partially or deeply mocked */ mocked(item: T, deep?: false): MaybeMocked; mocked(item: T, deep: true): MaybeMockedDeep; mocked(item: T, options: { partial?: false; deep?: false; }): MaybeMocked; mocked(item: T, options: { partial?: false; deep: true; }): MaybeMockedDeep; mocked(item: T, options: { partial: true; deep?: false; }): MaybePartiallyMocked; mocked(item: T, options: { partial: true; deep: true; }): MaybePartiallyMockedDeep; mocked(item: T): MaybeMocked; isMockFunction(fn: any): fn is EnhancedSpy; clearAllMocks(): this; resetAllMocks(): this; restoreAllMocks(): this; /** * Makes value available on global namespace. * Useful, if you want to have global variables available, like `IntersectionObserver`. * You can return it back to original value with `vi.unstubGlobals`, or by enabling `unstubGlobals` config option. */ stubGlobal(name: string | symbol | number, value: unknown): this; /** * Changes the value of `import.meta.env` and `process.env`. * You can return it back to original value with `vi.unstubEnvs`, or by enabling `unstubEnvs` config option. */ stubEnv(name: string, value: string): this; /** * Reset the value to original value that was available before first `vi.stubGlobal` was called. */ unstubAllGlobals(): this; /** * Reset environmental variables to the ones that were available before first `vi.stubEnv` was called. */ unstubAllEnvs(): this; resetModules(): this; /** * Wait for all imports to load. Useful, if you have a synchronous call that starts * importing a module that you cannot await otherwise. * Will also wait for new imports, started during the wait. */ dynamicImportSettled(): Promise; /** * Updates runtime config. You can only change values that are used when executing tests. */ setConfig(config: RuntimeConfig): void; /** * If config was changed with `vi.setConfig`, this will reset it to the original state. */ resetConfig(): void; } declare const vitest: VitestUtils; declare const vi: VitestUtils; declare function getRunningMode(): "run" | "watch"; declare function isWatchMode(): boolean; interface TransformResultWithSource extends TransformResult { source?: string; } interface WebSocketHandlers { onCollected(files?: File[]): Promise; onTaskUpdate(packs: TaskResultPack[]): void; onAfterSuiteRun(meta: AfterSuiteRunMeta): void; onDone(name: string): void; onCancel(reason: CancelReason): void; getCountOfFailedTests(): number; sendLog(log: UserConsoleLog): void; getFiles(): File[]; getPaths(): string[]; getConfig(): ResolvedConfig; resolveSnapshotPath(testPath: string): string; resolveSnapshotRawPath(testPath: string, rawPath: string): string; getModuleGraph(id: string): Promise; getTransformResult(id: string): Promise; readFile(id: string): Promise; writeFile(id: string, content: string, ensureDir?: boolean): Promise; removeFile(id: string): Promise; createDirectory(id: string): Promise; snapshotSaved(snapshot: SnapshotResult): void; rerun(files: string[]): Promise; updateSnapshot(file?: File): Promise; } interface WebSocketEvents extends Pick { onCancel(reason: CancelReason): void; } export { AfterSuiteRunMeta, AssertType, BenchmarkAPI, ExpectTypeOf, ModuleGraphData, Reporter, ResolvedConfig, RuntimeConfig, TransformResultWithSource, UserConsoleLog, WebSocketEvents, WebSocketHandlers, assertType, bench, expectTypeOf, getRunningMode, isFirstRun, isWatchMode, runOnce, vi, vitest };