Created
June 23, 2021 14:36
-
-
Save akinncar/e07a0a6ccf104667c9935a09dee5b41a to your computer and use it in GitHub Desktop.
Mock custom hooks on 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
// outside component (after imports) | |
const useAuth = jest.spyOn(require('contexts/AuthContext'), 'useAuth') | |
const user = { | |
user: { | |
name: 'Roberto Firmino', | |
}, | |
} | |
// inside describe | |
useAuth.mockReturnValue(user) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment