Closed regevbr closed 4 years ago
Hey. I'm in 2 minds about this. I feel that jest already provides this functionality already. I haven't checked, but assume jest.fn does not have a generic Param for doing this?
Hi @marchaos,
your calledWithFn
also have generic params, same as jest.fn
but I want your library capabilities, and I want auto inference of types and not passing them manually...
The following example can't be achieved by jest
type MyFn = (x: number, y: number) => Promise<string>;
const fn = mockFn<MyFn>();
fn.calledWith(1, 2).mockReturnValue('str');
Yep. Makes sense. I'll merge this in for now, but am planning on adding "mock" to the best object as "mockType" so might need to do something similar with this at that point. I will keep it backwards compatible!
Example of the feature: