Last active
          November 12, 2019 00:46 
        
      - 
      
- 
        Save andiwinata/e047d237637bf5968c10076e062a05e2 to your computer and use it in GitHub Desktop. 
    Mock specific function in jest
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | import { useCallback } from 'react'; | |
| jest.mock('react', () => ({ | |
| ...require.requireActual('react'), | |
| useCallback: jest.fn(), | |
| })); | |
| const useCallbackSpy = useCallback as jest.Mock<typeof useCallback>; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment