Created
February 2, 2024 19:44
-
-
Save Julianhm9612/c727cedaae76d8eec31435f7a55bcf6f to your computer and use it in GitHub Desktop.
Jest - Spy useState
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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