UNPKG

strong-mock

Version:

Type safe mocking library for TypeScript

49 lines (48 loc) 1.01 kB
import type { Mock } from './mock/mock'; export type Property = string | symbol; export interface ProxyTraps { /** * Called when accessing any property on an object, except for * `.call`, `.apply` and `.bind`. */ property: (property: Property) => unknown; /** * Called when calling a function. * * @example * ``` * fn(...args) * ``` * * @example * ``` * fn.call(this, ...args) * ``` * * @example * ``` * fn.apply(this, [...args]) * ``` * * @example * ``` * Reflect.apply(fn, this, [...args]) * ``` */ apply: (args: unknown[]) => unknown; /** * Called when getting the proxy's own enumerable keys. * * @example * ``` * Object.keys(proxy); * ``` * * @example * ``` * const foo = { ...proxy }; * ``` */ ownKeys: () => Property[]; } export declare const createProxy: <T>(traps: ProxyTraps) => Mock<T>;