You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to mock a standalone function (i.e. a function that's not a method of some object) but I can't find information on that in the readme.
Here is a simplified version of what I'm trying to do:
typeCallback=(x: number)=>void;constcaller=(callback: Callback)=>{callback(Math.random())}letmockCallback: Callback=mock<Callback>();caller(mockCallback);// fails when using mock without instancecaller(instance(mockCallback));// fails when using mock with instancecaller(x=>console.log(x))// works when not using a mock
As shown above, the first two caller(...) calls that use the mock would fail. They fail with the error:
TypeError: callback is not a function
❯ caller src/test.test.ts:7:5
5|
6| const caller = (callback: Callback) => {
7| callback(Math.random())
| ^
8| }
I want to mock a standalone function so that I can capture its arguments and do stuff with them. Could you please help me out? Thanks
The text was updated successfully, but these errors were encountered:
@mebble Hey,
This project is in maintenance mode as the original upstream isn't maintained at all, so in general there's no plan of adding new features (especially functionalities which are available in jest/vitest) but there's a PR we can merge on that.
I want to mock a standalone function (i.e. a function that's not a method of some object) but I can't find information on that in the readme.
Here is a simplified version of what I'm trying to do:
As shown above, the first two
caller(...)
calls that use the mock would fail. They fail with the error:I want to mock a standalone function so that I can capture its arguments and do stuff with them. Could you please help me out? Thanks
The text was updated successfully, but these errors were encountered: