type Callable = (...args: any[]) => unknown export type Mock = jest.Mock, Parameters> export function asMock (fn: F): Mock { if (jest.isMockFunction(fn)) { return fn } throw TypeError('not a mocked function') } export function mockResults (fn: F): Array> { return asMock(fn).mock.results .filter(x => x.type === 'return') .map(x => x.value as ReturnType) } export function mockLastResult (fn: F): ReturnType | undefined { return mockResults(fn).pop() }