Skip to content

How to define a type for mocked function in node test? #51176

Closed Answered by varunkamra
varunkamra asked this question in General
Discussion options

You must be logged in to vote

Found a solution on stackoverflow. I had to define a custom type like this:

type GenericFunction {
  (): any,
  mock: any
}

then use the type to typecast like following:

assert.equal((<GenericFunction>Base.prototype.call).mock.callCount(), 1);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by varunkamra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant