This commit is contained in:
2026-08-14 16:03:47 +01:00
parent fd53e3f4fb
commit dfdc3b2840
2463 changed files with 186456 additions and 111315 deletions
+163 -31
View File
@@ -1,28 +1,32 @@
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.ChKACdzH.js';
export { B as BrowserTesterOptions } from './chunks/browser.d.ChKACdzH.js';
import './chunks/global.d.B15mdLcR.js';
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.BcoexmFG.js';
export { B as BrowserTesterOptions } from './chunks/browser.d.BcoexmFG.js';
import './chunks/global.d.DVsSRdQ5.js';
import { File, TestAnnotation, TestArtifact, TaskResultPack, TaskEventPack, Test, TaskPopulated } from '@vitest/runner';
export { CancelReason, ImportDuration, OnTestFailedHandler, OnTestFinishedHandler, RunMode, Task as RunnerTask, TaskBase as RunnerTaskBase, TaskEventPack as RunnerTaskEventPack, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SuiteAPI, SuiteCollector, SuiteFactory, TaskCustomOptions, TaskMeta, TaskState, TestAPI, TestAnnotation, TestAnnotationArtifact, TestArtifact, TestArtifactBase, TestArtifactLocation, TestArtifactRegistry, TestAttachment, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, recordArtifact, suite, test } from '@vitest/runner';
export { CancelReason, ImportDuration, OnTestFailedHandler, OnTestFinishedHandler, RunMode, Task as RunnerTask, TaskBase as RunnerTaskBase, TaskEventPack as RunnerTaskEventPack, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteOptions, TaskCustomOptions, TaskMeta, TaskState, TestAPI, TestAnnotation, TestAnnotationArtifact, TestArtifact, TestArtifactBase, TestArtifactLocation, TestArtifactRegistry, TestAttachment, TestContext, TestFunction, TestOptions, VitestRunnerConfig as TestRunnerConfig, TestTags, VitestRunner as VitestTestRunner, afterAll, afterEach, aroundAll, aroundEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, recordArtifact, suite, test } from '@vitest/runner';
import { Awaitable } from '@vitest/utils';
export { ParsedStack, SerializedError, TestError } from '@vitest/utils';
import { b as BirpcReturn } from './chunks/worker.d.Dyxm8DEL.js';
export { C as ContextRPC, c as ContextTestEnvironment, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.Dyxm8DEL.js';
import { S as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.Cy95HiCx.js';
export { b as RuntimeConfig, a as SerializedCoverageConfig } from './chunks/config.d.Cy95HiCx.js';
import { U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, P as ProvidedContext } from './chunks/rpc.d.RH3apGEf.js';
export { A as AfterSuiteRunMeta, a as RunnerRPC, R as RuntimeRPC } from './chunks/rpc.d.RH3apGEf.js';
import { ExpectStatic } from '@vitest/expect';
export { Assertion, AsymmetricMatchersContaining, DeeplyAllowMatchers, ExpectPollOptions, ExpectStatic, JestAssertion, Matchers, chai } from '@vitest/expect';
import { b as BirpcReturn } from './chunks/worker.d.ZpHpO4yb.js';
export { C as ContextRPC, c as ContextTestEnvironment, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.ZpHpO4yb.js';
import { b as SerializedRootConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.A1h_Y6Jt.js';
export { c as RuntimeConfig, S as SerializedConfig, a as SerializedCoverageConfig } from './chunks/config.d.A1h_Y6Jt.js';
import { U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, P as ProvidedContext } from './chunks/traces.d.D2T_R8rx.js';
export { a as AfterSuiteRunMeta } from './chunks/traces.d.D2T_R8rx.js';
import { ExpectStatic, MatcherState, SyncExpectationResult, AsyncExpectationResult, ExpectationResult } from '@vitest/expect';
export { Assertion, AsymmetricMatchersContaining, DeeplyAllowMatchers, ExpectPollOptions, ExpectStatic, JestAssertion, RawMatcherFn as Matcher, ExpectationResult as MatcherResult, MatcherState, Matchers, chai } from '@vitest/expect';
import { DomainSnapshotAdapter } from '@vitest/snapshot';
export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotSerializer, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
export { Mock, MockContext, MockInstance, MockResult, MockResultIncomplete, MockResultReturn, MockResultThrow, MockSettledResult, MockSettledResultFulfilled, MockSettledResultIncomplete, MockSettledResultRejected, Mocked, MockedClass, MockedFunction, MockedObject } from '@vitest/spy';
export { b as bench } from './chunks/suite.d.BJWk38HB.js';
import { Disposable } from 'vitest/optional-runtime-types.js';
import { ModuleMockFactoryWithHelper, ModuleMockOptions } from '@vitest/mocker';
export { b as bench } from './chunks/suite.d.udJtyAgw.js';
export { V as EvaluatedModules } from './chunks/evaluatedModules.d.BxJ5omdx.js';
export { NodeBenchmarkRunner as BenchmarkRunner, VitestTestRunner as TestRunner } from './runners.js';
export { a as BenchFunction, b as Benchmark, c as BenchmarkAPI, B as BenchmarkResult } from './chunks/benchmark.d.DAaHLpsq.js';
export { ExpectTypeOf, expectTypeOf } from 'expect-type';
export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotSerializer, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
export { a as RunnerRPC, R as RuntimeRPC } from './chunks/rpc.d.B_8sPU0w.js';
export { DiffOptions } from '@vitest/utils/diff';
export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
import './chunks/traces.d.402V_yFI.js';
import '@vitest/pretty-format';
import 'vite/module-runner';
import './chunks/environment.d.CrsxCzP1.js';
@@ -55,11 +59,13 @@ interface TransformResultWithSource {
untrackedModules?: UntrackedModuleDefinitionDiagnostic[];
}
interface WebSocketHandlers {
onTaskUpdate: (packs: TaskResultPack[], events: TaskEventPack[]) => void;
getFiles: () => File[];
getTestFiles: () => Promise<SerializedTestSpecification[]>;
getPaths: () => string[];
getConfig: () => SerializedConfig;
getConfig: () => SerializedRootConfig;
/**
* @deprecated Use `getConfig().projects` instead.
*/
getResolvedProjectLabels: () => {
name: string;
color?: LabelColor;
@@ -98,11 +104,93 @@ declare const should: () => Chai.Should;
*/
declare function inject<T extends keyof ProvidedContext & string>(key: T): ProvidedContext[T];
type Promisable<T> = T | Promise<T>;
type MockFactoryWithHelper<M = unknown> = (importOriginal: <T extends M = M>() => Promise<T>) => Promisable<Partial<M>>;
interface MockOptions {
spy?: boolean;
}
/**
* Composable snapshot matcher helpers for building custom snapshot matchers
* with `expect.extend`.
*
* @experimental
* @see https://vitest.dev/guide/snapshot.html#custom-snapshot-matchers
*/
declare const Snapshots: {
/**
* Composable for building custom snapshot matchers via `expect.extend`.
* Call with `this` bound to the matcher state. Returns `{ pass, message }`
* compatible with the custom matcher return contract.
*
* @example
* ```ts
* import { Snapshots } from 'vitest/runtime'
*
* expect.extend({
* toMatchTrimmedSnapshot(received: string) {
* return Snapshots.toMatchSnapshot.call(this, received.slice(0, 10))
* },
* })
* ```
*
* @experimental
* @see https://vitest.dev/guide/snapshot.html#custom-snapshot-matchers
*/
toMatchSnapshot(this: MatcherState, received: unknown, propertiesOrHint?: object | string, hint?: string): SyncExpectationResult;
/**
* Composable for building custom inline snapshot matchers via `expect.extend`.
* Call with `this` bound to the matcher state. Returns `{ pass, message }`
* compatible with the custom matcher return contract.
*
* @example
* ```ts
* import { Snapshots } from 'vitest/runtime'
*
* expect.extend({
* toMatchTrimmedInlineSnapshot(received: string, inlineSnapshot?: string) {
* return Snapshots.toMatchInlineSnapshot.call(this, received.slice(0, 10), inlineSnapshot)
* },
* })
* ```
*
* @experimental
* @see https://vitest.dev/guide/snapshot.html#custom-snapshot-matchers
*/
toMatchInlineSnapshot(this: MatcherState, received: unknown, propertiesOrInlineSnapshot?: object | string, inlineSnapshotOrHint?: string, hint?: string): SyncExpectationResult;
/**
* Composable for building custom file snapshot matchers via `expect.extend`.
* Call with `this` bound to the matcher state. Returns a `Promise<{ pass, message }>`
* compatible with the custom matcher return contract.
*
* @example
* ```ts
* import { Snapshots } from 'vitest/runtime'
*
* expect.extend({
* async toMatchTrimmedFileSnapshot(received: string, file: string) {
* return Snapshots.toMatchFileSnapshot.call(this, received.slice(0, 10), file)
* },
* })
* ```
*
* @experimental
* @see https://vitest.dev/guide/snapshot.html#custom-snapshot-matchers
*/
toMatchFileSnapshot(this: MatcherState, received: unknown, filepath: string, hint?: string): AsyncExpectationResult;
/**
* Composable for building custom domain-based snapshot matchers via `expect.extend`.
*
* Call this from a matcher and pass the domain adapter that defines capture,
* rendering, parsing, and semantic matching behavior.
*
* @experimental
*/
toMatchDomainSnapshot(this: MatcherState, domain: DomainSnapshotAdapter<any, any>, received: unknown): ExpectationResult;
/**
* Composable for building custom domain-based inline snapshot matchers via `expect.extend`.
*
* Call this from a matcher and pass the domain adapter that defines capture,
* rendering, parsing, and semantic matching behavior.
*
* @experimental
*/
toMatchDomainInlineSnapshot(this: MatcherState, domain: DomainSnapshotAdapter<any, any>, received: unknown, inlineSnapshot?: string): ExpectationResult;
};
type WaitForCallback<T> = () => T | Promise<T>;
interface WaitForOptions {
@@ -149,12 +237,12 @@ interface VitestUtils {
runOnlyPendingTimersAsync: () => Promise<VitestUtils>;
/**
* This method will invoke every initiated timer until the timer queue is empty. It means that every timer called during `runAllTimers` will be fired.
* 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)).
* If you have an infinite interval, it will throw after 10,000 tries (can be configured with [`fakeTimers.loopLimit`](https://vitest.dev/config/faketimers#faketimers-looplimit)).
*/
runAllTimers: () => VitestUtils;
/**
* 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.
* 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)).
* If you have an infinite interval, it will throw after 10 000 tries (can be configured with [`fakeTimers.loopLimit`](https://vitest.dev/config/faketimers#faketimers-looplimit)).
*/
runAllTimersAsync: () => Promise<VitestUtils>;
/**
@@ -203,6 +291,15 @@ interface VitestUtils {
*/
clearAllTimers: () => VitestUtils;
/**
* Controls how fake timers are advanced.
* @param mode The mode to use for advancing timers.
* - `manual`: The default behavior. Timers will only advance when you call one of `vi.advanceTimers...()` methods.
* - `nextTimerAsync`: Timers will be advanced automatically to the next available timer after each macrotask.
* - `interval`: Timers are advanced automatically by a specified interval.
* @param interval The interval in milliseconds to use when `mode` is `'interval'`.
*/
setTimerTickMode: ((mode: "manual" | "nextTimerAsync") => VitestUtils) & ((mode: "interval", interval?: number) => VitestUtils);
/**
* 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).
* @example
* ```ts
@@ -261,6 +358,39 @@ interface VitestUtils {
*/
waitFor: typeof waitFor;
/**
* Wraps a function to create an assertion helper. When an assertion fails inside the helper,
* the error stack trace will point to where the helper was called, not inside the helper itself.
* Works with both synchronous and asynchronous functions, and supports `expect.soft()`.
*
* @example
* ```ts
* const myEqual = vi.defineHelper((x, y) => {
* expect(x).toEqual(y)
* })
*
* test('example', () => {
* myEqual('left', 'right') // Error points to this line
* })
* ```
* Example output:
* ```
* FAIL example.test.ts > example
* AssertionError: expected 'left' to deeply equal 'right'
*
* Expected: "right"
* Received: "left"
*
* ❯ example.test.ts:6:3
* 4| test('example', () => {
* 5| myEqual('left', 'right')
* | ^
* 6| })
* ```
* @param fn The assertion function to wrap
* @returns A wrapped function with the same signature
*/
defineHelper: <F extends (...args: any) => any>(fn: F) => F;
/**
* 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.
*
* 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.
@@ -296,8 +426,8 @@ interface VitestUtils {
* @param path Path to the module. Can be aliased, if your Vitest config supports it
* @param factory Mocked module factory. The result of this function will be an exports object
*/
mock(path: string, factory?: MockFactoryWithHelper | MockOptions): void;
mock<T>(module: Promise<T>, factory?: MockFactoryWithHelper<T> | MockOptions): void;
mock(path: string, factory?: ModuleMockFactoryWithHelper | ModuleMockOptions): void;
mock<T>(module: Promise<T>, factory?: ModuleMockFactoryWithHelper<T> | ModuleMockOptions): void;
/**
* Removes module from mocked registry. All calls to import will return the original module even if it was mocked before.
*
@@ -314,9 +444,11 @@ interface VitestUtils {
* Mocking algorithm is described in [documentation](https://vitest.dev/guide/mocking/modules).
* @param path Path to the module. Can be aliased, if your Vitest config supports it
* @param factory Mocked module factory. The result of this function will be an exports object
*
* @returns A disposable object that calls {@link doUnmock()} when disposed
*/
doMock(path: string, factory?: MockFactoryWithHelper | MockOptions): void;
doMock<T>(module: Promise<T>, factory?: MockFactoryWithHelper<T> | MockOptions): void;
doMock(path: string, factory?: ModuleMockFactoryWithHelper | ModuleMockOptions): Disposable;
doMock<T>(module: Promise<T>, factory?: ModuleMockFactoryWithHelper<T> | ModuleMockOptions): Disposable;
/**
* Removes module from mocked registry. All subsequent calls to import will return original module.
*
@@ -387,12 +519,12 @@ interface VitestUtils {
* @param value - The object to be mocked
* @returns A deeply mocked version of the input object
*/
mockObject: <T>(value: T, options?: MockOptions) => MaybeMockedDeep<T>;
mockObject: <T>(value: T, options?: ModuleMockOptions) => MaybeMockedDeep<T>;
/**
* Type helper for TypeScript. Just returns the object that was passed.
*
* When `partial` is `true` it will expect a `Partial<T>` as a return value. By default, this will only make TypeScript believe that
* 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.
* the first level values are mocked. You can pass down `{ partial: true, deep: true }` to make nested objects also partial recursively.
* @example
* ```ts
* import example from './example.js'
@@ -506,5 +638,5 @@ declare namespace Experimental {
export { ModuleDefinitionDiagnostic, ModuleDefinitionDurationsDiagnostic, ModuleDefinitionLocation, SourceModuleDiagnostic, SourceModuleLocations, UntrackedModuleDefinitionDiagnostic };
}
export { Experimental, LabelColor, ModuleGraphData, ProvidedContext, SerializedConfig, SerializedTestSpecification, UserConsoleLog, assert, assertType, createExpect, globalExpect as expect, inject, should, vi, vitest };
export { Experimental, LabelColor, ModuleGraphData, ProvidedContext, SerializedRootConfig, SerializedTestSpecification, Snapshots, UserConsoleLog, assert, assertType, createExpect, globalExpect as expect, inject, should, vi, vitest };
export type { AssertType, BrowserUI, ExternalResult, TransformResultWithSource, VitestUtils, WebSocketEvents, WebSocketHandlers, WebSocketRPC };