Skip to content

Instantly share code, notes, and snippets.

@devxoul
Created February 12, 2021 12:24
Show Gist options
  • Save devxoul/2470473d8df4d0db9f20c2fa0aaa8fa3 to your computer and use it in GitHub Desktop.
Save devxoul/2470473d8df4d0db9f20c2fa0aaa8fa3 to your computer and use it in GitHub Desktop.
Jest Spy type
type Spy<T extends {}, M extends jest.FunctionPropertyNames<Required<T>>> = Required<T>[M] extends (...args: any[]) => any
? jest.SpyInstance<ReturnType<Required<T>[M]>, jest.ArgsType<Required<T>[M]>>
: never;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment