Skip to content

Instantly share code, notes, and snippets.

@sethdavis512
Created December 12, 2023 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sethdavis512/f8bc0ee09f643f0dbb720b0d6227bcd5 to your computer and use it in GitHub Desktop.
Save sethdavis512/f8bc0ee09f643f0dbb720b0d6227bcd5 to your computer and use it in GitHub Desktop.
The Typescript way to mock custom hooks
jest.mock('../path/to/hooks/useMyHook', () => ({
__esModule: true,
default: jest.fn(() => ({
isLoading: false
}))
}));
(useMyHook as jest.MockedFunction<any>).mockReturnValue({ isLoading: true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment