Last active
January 14, 2020 23:44
-
-
Save marco-souza/ac413052ec18dc75f16a447193c511a4 to your computer and use it in GitHub Desktop.
mock a react hook
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 { useLoadingMocked } from 'assets/__mocks__/useLoading'; | |
// mock module as a function | |
jest.mock('src/redux/loading', () => jest.fn()); | |
import methodToMock from 'src/redux/loading'; | |
const mockedMethod = methodToMock as jest.Mock; | |
describe('testing a hook', () => { | |
it('my test', () => { | |
const mockObject = useLoadingMocked(); | |
mockedMethod.mockImplementation(() => mockObject); | |
// ... | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment