Skip to content
GitHub

MockedFunction

type alias in meocord/testing Since 4.0.0

type MockedFunction<T extends (...args: any[]) => any> = ((
  ...args: Parameters<T>
) => ReturnType<T>) &
  MockInstance<T>

A mock function with the signature of T, and the mock API of MockInstance.

It takes the place of jest's MockedFunction<T> and Vitest's MockedFunction<T>. The mock factories type each method of a mock with it, so interaction.reply.mockResolvedValue(...) type-checks. For an overloaded method, such as a manager's fetch, the mock API takes what any of its overloads takes or returns.

See also