Skip to content

Instantly share code, notes, and snippets.

@Julianhm9612
Created February 2, 2024 19:44
Show Gist options
  • Save Julianhm9612/c727cedaae76d8eec31435f7a55bcf6f to your computer and use it in GitHub Desktop.
Save Julianhm9612/c727cedaae76d8eec31435f7a55bcf6f to your computer and use it in GitHub Desktop.
Jest - Spy useState
const setState = jest.fn();
const useStateSpy = jest.spyOn(React, 'useState');
useStateSpy.mockImplementation(() => [init, setState]);
expect(setState).toHaveBeenCalledWith('S');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment