UNPKG

stubfn

Version:

A minimal, zero-dependency stub utility for JavaScript testing. Simple API, predictable behavior, and no magic—perfect for replacing Sinon in modern test setups.

16 lines (15 loc) • 434 B
export type Stub = ((...args: any[]) => any) & { getCalls: () => any[]; getNumCalls: () => number; expects: (...expected: any[]) => Stub; returns: (value: any) => Stub; throws: (error: any) => Stub; when: (args: any[], returns: any) => Stub; clearCalls: () => Stub; reset: () => Stub; }; export type WhenArgs = { args: any[]; returns: any; }; export declare function stub(name?: string): Stub;