histoire
Version:
A fast story book powered by Vite
504 lines • 19.6 kB
TypeScript
type AnyFn = (...args: any[]) => any;
declare function createMockFunction<T extends AnyFn | undefined>(implementation?: T): AnyFn & {
mock: {
calls: any[][];
};
};
export declare const vi: {
fn: typeof createMockFunction;
mocked<T>(value: T): T;
mock(): void;
unmock(): void;
doMock(): void;
doUnmock(): void;
importActual: <T>(path: string) => Promise<T>;
importMock: <T>(path: string) => Promise<T>;
resetAllMocks(): void;
clearAllMocks(): void;
restoreAllMocks(): void;
isMockFunction(value: unknown): boolean;
/** Replaces the target method with a chainable mock for collection. */
spyOn(target: any, key: PropertyKey): AnyFn & {
mock: {
calls: any[][];
};
};
stubGlobal(name: PropertyKey, value: unknown): {
fn: typeof createMockFunction;
mocked<T>(value: T): T;
mock(): void;
unmock(): void;
doMock(): void;
doUnmock(): void;
importActual: <T>(path: string) => Promise<T>;
importMock: <T>(path: string) => Promise<T>;
resetAllMocks(): void;
clearAllMocks(): void;
restoreAllMocks(): void;
isMockFunction(value: unknown): boolean;
/** Replaces the target method with a chainable mock for collection. */
spyOn(target: any, key: PropertyKey): AnyFn & {
mock: {
calls: any[][];
};
};
stubGlobal(name: PropertyKey, value: unknown): /*elided*/ any;
stubEnv(): /*elided*/ any;
unstubAllGlobals(): /*elided*/ any;
unstubAllEnvs(): /*elided*/ any;
useFakeTimers(): /*elided*/ any;
useRealTimers(): /*elided*/ any;
setSystemTime(): /*elided*/ any;
advanceTimersByTime(): /*elided*/ any;
runAllTimers(): /*elided*/ any;
/** Executes the factory immediately — hoisting is irrelevant at collection time. */
hoisted<T>(factory: () => T): T;
waitFor: <T>(callback: () => T | Promise<T>) => Promise<T>;
waitUntil: <T>(callback: () => T | Promise<T>) => Promise<T>;
};
stubEnv(): {
fn: typeof createMockFunction;
mocked<T>(value: T): T;
mock(): void;
unmock(): void;
doMock(): void;
doUnmock(): void;
importActual: <T>(path: string) => Promise<T>;
importMock: <T>(path: string) => Promise<T>;
resetAllMocks(): void;
clearAllMocks(): void;
restoreAllMocks(): void;
isMockFunction(value: unknown): boolean;
/** Replaces the target method with a chainable mock for collection. */
spyOn(target: any, key: PropertyKey): AnyFn & {
mock: {
calls: any[][];
};
};
stubGlobal(name: PropertyKey, value: unknown): /*elided*/ any;
stubEnv(): /*elided*/ any;
unstubAllGlobals(): /*elided*/ any;
unstubAllEnvs(): /*elided*/ any;
useFakeTimers(): /*elided*/ any;
useRealTimers(): /*elided*/ any;
setSystemTime(): /*elided*/ any;
advanceTimersByTime(): /*elided*/ any;
runAllTimers(): /*elided*/ any;
/** Executes the factory immediately — hoisting is irrelevant at collection time. */
hoisted<T>(factory: () => T): T;
waitFor: <T>(callback: () => T | Promise<T>) => Promise<T>;
waitUntil: <T>(callback: () => T | Promise<T>) => Promise<T>;
};
unstubAllGlobals(): {
fn: typeof createMockFunction;
mocked<T>(value: T): T;
mock(): void;
unmock(): void;
doMock(): void;
doUnmock(): void;
importActual: <T>(path: string) => Promise<T>;
importMock: <T>(path: string) => Promise<T>;
resetAllMocks(): void;
clearAllMocks(): void;
restoreAllMocks(): void;
isMockFunction(value: unknown): boolean;
/** Replaces the target method with a chainable mock for collection. */
spyOn(target: any, key: PropertyKey): AnyFn & {
mock: {
calls: any[][];
};
};
stubGlobal(name: PropertyKey, value: unknown): any;
stubEnv(): any;
unstubAllGlobals(): any;
unstubAllEnvs(): any;
useFakeTimers(): any;
useRealTimers(): any;
setSystemTime(): any;
advanceTimersByTime(): any;
runAllTimers(): any;
/** Executes the factory immediately — hoisting is irrelevant at collection time. */
hoisted<T>(factory: () => T): T;
waitFor: <T>(callback: () => T | Promise<T>) => Promise<T>;
waitUntil: <T>(callback: () => T | Promise<T>) => Promise<T>;
};
unstubAllEnvs(): {
fn: typeof createMockFunction;
mocked<T>(value: T): T;
mock(): void;
unmock(): void;
doMock(): void;
doUnmock(): void;
importActual: <T>(path: string) => Promise<T>;
importMock: <T>(path: string) => Promise<T>;
resetAllMocks(): void;
clearAllMocks(): void;
restoreAllMocks(): void;
isMockFunction(value: unknown): boolean;
/** Replaces the target method with a chainable mock for collection. */
spyOn(target: any, key: PropertyKey): AnyFn & {
mock: {
calls: any[][];
};
};
stubGlobal(name: PropertyKey, value: unknown): any;
stubEnv(): any;
unstubAllGlobals(): any;
unstubAllEnvs(): any;
useFakeTimers(): any;
useRealTimers(): any;
setSystemTime(): any;
advanceTimersByTime(): any;
runAllTimers(): any;
/** Executes the factory immediately — hoisting is irrelevant at collection time. */
hoisted<T>(factory: () => T): T;
waitFor: <T>(callback: () => T | Promise<T>) => Promise<T>;
waitUntil: <T>(callback: () => T | Promise<T>) => Promise<T>;
};
useFakeTimers(): {
fn: typeof createMockFunction;
mocked<T>(value: T): T;
mock(): void;
unmock(): void;
doMock(): void;
doUnmock(): void;
importActual: <T>(path: string) => Promise<T>;
importMock: <T>(path: string) => Promise<T>;
resetAllMocks(): void;
clearAllMocks(): void;
restoreAllMocks(): void;
isMockFunction(value: unknown): boolean;
/** Replaces the target method with a chainable mock for collection. */
spyOn(target: any, key: PropertyKey): AnyFn & {
mock: {
calls: any[][];
};
};
stubGlobal(name: PropertyKey, value: unknown): any;
stubEnv(): any;
unstubAllGlobals(): any;
unstubAllEnvs(): any;
useFakeTimers(): any;
useRealTimers(): any;
setSystemTime(): any;
advanceTimersByTime(): any;
runAllTimers(): any;
/** Executes the factory immediately — hoisting is irrelevant at collection time. */
hoisted<T>(factory: () => T): T;
waitFor: <T>(callback: () => T | Promise<T>) => Promise<T>;
waitUntil: <T>(callback: () => T | Promise<T>) => Promise<T>;
};
useRealTimers(): {
fn: typeof createMockFunction;
mocked<T>(value: T): T;
mock(): void;
unmock(): void;
doMock(): void;
doUnmock(): void;
importActual: <T>(path: string) => Promise<T>;
importMock: <T>(path: string) => Promise<T>;
resetAllMocks(): void;
clearAllMocks(): void;
restoreAllMocks(): void;
isMockFunction(value: unknown): boolean;
/** Replaces the target method with a chainable mock for collection. */
spyOn(target: any, key: PropertyKey): AnyFn & {
mock: {
calls: any[][];
};
};
stubGlobal(name: PropertyKey, value: unknown): any;
stubEnv(): any;
unstubAllGlobals(): any;
unstubAllEnvs(): any;
useFakeTimers(): any;
useRealTimers(): any;
setSystemTime(): any;
advanceTimersByTime(): any;
runAllTimers(): any;
/** Executes the factory immediately — hoisting is irrelevant at collection time. */
hoisted<T>(factory: () => T): T;
waitFor: <T>(callback: () => T | Promise<T>) => Promise<T>;
waitUntil: <T>(callback: () => T | Promise<T>) => Promise<T>;
};
setSystemTime(): {
fn: typeof createMockFunction;
mocked<T>(value: T): T;
mock(): void;
unmock(): void;
doMock(): void;
doUnmock(): void;
importActual: <T>(path: string) => Promise<T>;
importMock: <T>(path: string) => Promise<T>;
resetAllMocks(): void;
clearAllMocks(): void;
restoreAllMocks(): void;
isMockFunction(value: unknown): boolean;
/** Replaces the target method with a chainable mock for collection. */
spyOn(target: any, key: PropertyKey): AnyFn & {
mock: {
calls: any[][];
};
};
stubGlobal(name: PropertyKey, value: unknown): any;
stubEnv(): any;
unstubAllGlobals(): any;
unstubAllEnvs(): any;
useFakeTimers(): any;
useRealTimers(): any;
setSystemTime(): any;
advanceTimersByTime(): any;
runAllTimers(): any;
/** Executes the factory immediately — hoisting is irrelevant at collection time. */
hoisted<T>(factory: () => T): T;
waitFor: <T>(callback: () => T | Promise<T>) => Promise<T>;
waitUntil: <T>(callback: () => T | Promise<T>) => Promise<T>;
};
advanceTimersByTime(): {
fn: typeof createMockFunction;
mocked<T>(value: T): T;
mock(): void;
unmock(): void;
doMock(): void;
doUnmock(): void;
importActual: <T>(path: string) => Promise<T>;
importMock: <T>(path: string) => Promise<T>;
resetAllMocks(): void;
clearAllMocks(): void;
restoreAllMocks(): void;
isMockFunction(value: unknown): boolean;
/** Replaces the target method with a chainable mock for collection. */
spyOn(target: any, key: PropertyKey): AnyFn & {
mock: {
calls: any[][];
};
};
stubGlobal(name: PropertyKey, value: unknown): any;
stubEnv(): any;
unstubAllGlobals(): any;
unstubAllEnvs(): any;
useFakeTimers(): any;
useRealTimers(): any;
setSystemTime(): any;
advanceTimersByTime(): any;
runAllTimers(): any;
/** Executes the factory immediately — hoisting is irrelevant at collection time. */
hoisted<T>(factory: () => T): T;
waitFor: <T>(callback: () => T | Promise<T>) => Promise<T>;
waitUntil: <T>(callback: () => T | Promise<T>) => Promise<T>;
};
runAllTimers(): {
fn: typeof createMockFunction;
mocked<T>(value: T): T;
mock(): void;
unmock(): void;
doMock(): void;
doUnmock(): void;
importActual: <T>(path: string) => Promise<T>;
importMock: <T>(path: string) => Promise<T>;
resetAllMocks(): void;
clearAllMocks(): void;
restoreAllMocks(): void;
isMockFunction(value: unknown): boolean;
/** Replaces the target method with a chainable mock for collection. */
spyOn(target: any, key: PropertyKey): AnyFn & {
mock: {
calls: any[][];
};
};
stubGlobal(name: PropertyKey, value: unknown): any;
stubEnv(): any;
unstubAllGlobals(): any;
unstubAllEnvs(): any;
useFakeTimers(): any;
useRealTimers(): any;
setSystemTime(): any;
advanceTimersByTime(): any;
runAllTimers(): any;
/** Executes the factory immediately — hoisting is irrelevant at collection time. */
hoisted<T>(factory: () => T): T;
waitFor: <T>(callback: () => T | Promise<T>) => Promise<T>;
waitUntil: <T>(callback: () => T | Promise<T>) => Promise<T>;
};
/** Executes the factory immediately — hoisting is irrelevant at collection time. */
hoisted<T>(factory: () => T): T;
waitFor: <T>(callback: () => T | Promise<T>) => Promise<T>;
waitUntil: <T>(callback: () => T | Promise<T>) => Promise<T>;
};
export declare const vitest: {
fn: typeof createMockFunction;
mocked<T>(value: T): T;
mock(): void;
unmock(): void;
doMock(): void;
doUnmock(): void;
importActual: <T>(path: string) => Promise<T>;
importMock: <T>(path: string) => Promise<T>;
resetAllMocks(): void;
clearAllMocks(): void;
restoreAllMocks(): void;
isMockFunction(value: unknown): boolean;
/** Replaces the target method with a chainable mock for collection. */
spyOn(target: any, key: PropertyKey): AnyFn & {
mock: {
calls: any[][];
};
};
stubGlobal(name: PropertyKey, value: unknown): /*elided*/ any;
stubEnv(): /*elided*/ any;
unstubAllGlobals(): /*elided*/ any;
unstubAllEnvs(): /*elided*/ any;
useFakeTimers(): /*elided*/ any;
useRealTimers(): /*elided*/ any;
setSystemTime(): /*elided*/ any;
advanceTimersByTime(): /*elided*/ any;
runAllTimers(): /*elided*/ any;
/** Executes the factory immediately — hoisting is irrelevant at collection time. */
hoisted<T>(factory: () => T): T;
waitFor: <T>(callback: () => T | Promise<T>) => Promise<T>;
waitUntil: <T>(callback: () => T | Promise<T>) => Promise<T>;
};
export declare const expect: ((value?: unknown) => any) & {
extend(): void;
anything: () => () => any;
any: () => () => any;
stringContaining: () => () => any;
stringMatching: () => () => any;
objectContaining: () => () => any;
arrayContaining: () => () => any;
closeTo: () => () => any;
assertions(): void;
hasAssertions(): void;
/** `expect.soft(value)` — same noop matcher as `expect(value)`. */
soft: (_value?: unknown) => () => any;
/** `expect.poll(() => value)` — retrying matcher, noop at collection time. */
poll: (_value?: unknown) => () => any;
unreachable(message?: string): never;
addSnapshotSerializer(): void;
addEqualityTesters(): void;
readonly not: () => any;
};
/** Returns collection-only expect facade. */
export declare function createExpect(): ((value?: unknown) => any) & {
extend(): void;
anything: () => () => any;
any: () => () => any;
stringContaining: () => () => any;
stringMatching: () => () => any;
objectContaining: () => () => any;
arrayContaining: () => () => any;
closeTo: () => () => any;
assertions(): void;
hasAssertions(): void;
/** `expect.soft(value)` — same noop matcher as `expect(value)`. */
soft: (_value?: unknown) => () => any;
/** `expect.poll(() => value)` — retrying matcher, noop at collection time. */
poll: (_value?: unknown) => () => any;
unreachable(message?: string): never;
addSnapshotSerializer(): void;
addEqualityTesters(): void;
readonly not: () => any;
};
/** Base for runner classes unavailable during story collection. */
declare class UnsupportedVitestRuntime {
constructor();
}
/** Collection placeholder for Vitest benchmark runner. */
export declare class BenchmarkRunner extends UnsupportedVitestRuntime {
}
/** Collection placeholder for Vitest evaluated-module registry. */
export declare class EvaluatedModules extends UnsupportedVitestRuntime {
}
/** Collection placeholder for Vitest test runner. */
export declare class TestRunner extends UnsupportedVitestRuntime {
}
/**
* Chai-style assertions. Every method is a noop except `fail`, which a story
* may legitimately use to abort its own setup.
*/
export declare const assert: any;
export declare const should: () => () => any;
export declare const chai: {
assert: any;
expect: ((value?: unknown) => any) & {
extend(): void;
anything: () => () => any;
any: () => () => any;
stringContaining: () => () => any;
stringMatching: () => () => any;
objectContaining: () => () => any;
arrayContaining: () => () => any;
closeTo: () => () => any;
assertions(): void;
hasAssertions(): void;
/** `expect.soft(value)` — same noop matcher as `expect(value)`. */
soft: (_value?: unknown) => () => any;
/** `expect.poll(() => value)` — retrying matcher, noop at collection time. */
poll: (_value?: unknown) => () => any;
unreachable(message?: string): never;
addSnapshotSerializer(): void;
addEqualityTesters(): void;
readonly not: () => any;
};
should: typeof should;
};
export declare const expectTypeOf: () => () => any;
/** No-op type assertion helper for browser story collection. */
export declare function assertType(): void;
/** No-op context injection helper for browser story collection. */
export declare function inject(): void;
export declare const describe: import("@histoire/shared").HistoireSuiteCollector;
export declare const it: import("@histoire/shared").HistoireTestCollector;
export declare const test: import("@histoire/shared").HistoireTestCollector;
export declare const suite: import("@histoire/shared").HistoireSuiteCollector;
/**
* Benchmarks are not Histoire tests: registering them like `test` would list
* them in the Tests panel and run them as if they asserted something. They are
* collected as nothing at all.
*/
export declare const bench: ((_name: string, _fn?: AnyFn) => void) & {
only(_name: string, _fn?: AnyFn): void;
skip(_name: string, _fn?: AnyFn): void;
todo(_name: string, _fn?: AnyFn): void;
};
/** Registers a suite-level setup hook. */
export declare function beforeAll(handler: AnyFn, timeout?: number): void;
/** Registers a per-test setup hook. */
export declare function beforeEach(handler: AnyFn, timeout?: number): void;
/** Registers a suite-level cleanup hook. */
export declare function afterAll(handler: AnyFn, timeout?: number): void;
/** Registers a per-test cleanup hook. */
export declare function afterEach(handler: AnyFn, timeout?: number): void;
/** Registers a Vitest 4.1 suite lifecycle wrapper. */
export declare function aroundAll(handler: AnyFn, timeout?: number): void;
/** Registers a Vitest 4.1 per-test lifecycle wrapper. */
export declare function aroundEach(handler: AnyFn, timeout?: number): void;
/** No-op failure hook for browser story collection. */
export declare function onTestFailed(): void;
/** No-op finished hook for browser story collection. */
export declare function onTestFinished(): void;
/** No-op artifact recorder for browser story collection. */
export declare function recordArtifact(): void;
/**
* Snapshot namespace placeholder. Vitest's browser runtime imports this public
* export internally; story collection never executes snapshot operations.
*/
export declare const Snapshots: Readonly<{
/** Collection-only snapshot matcher placeholder. */
toMatchSnapshot: () => {
pass: boolean;
message: () => "";
};
/** Collection-only inline snapshot matcher placeholder. */
toMatchInlineSnapshot: () => {
pass: boolean;
message: () => "";
};
/** Collection-only file snapshot matcher placeholder. */
toMatchFileSnapshot: () => {
pass: boolean;
message: () => "";
};
}>;
export {};
//# sourceMappingURL=vitest-collect.d.ts.map