Connectum API Reference / @connectum/testing / index / createMockFn
Function: createMockFn()
createMockFn<
F>(impl):MockFn<F>
Defined in: mock-compat.ts:54
Create a portable mock function that wraps impl and records every call.
Type Parameters
F
F extends (...args) => any
Parameters
impl
F
The underlying implementation to delegate to.
Returns
MockFn<F>
A spy-enabled wrapper whose .mock property exposes call metadata.
Example
ts
const add = createMockFn((a: number, b: number) => a + b);
add(1, 2);
add(3, 4);
add.mock.callCount(); // 2
add.mock.calls[0].arguments; // [1, 2]