Created
November 20, 2019 16:14
-
-
Save mikaelhadler/8d7ef309a8e9e79418f8c8325ed89c7d to your computer and use it in GitHub Desktop.
Testing requests with jest and axios using a custom instance
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
| const mockAxios = jest.genMockFromModule('axios') | |
| mockAxios.get = jest.fn(() => Promise.resolve({ data: {} })) | |
| mockAxios.post = jest.fn(() => Promise.resolve({ data: {} })) | |
| mockAxios.put = jest.fn(() => Promise.resolve({ data: {} })) | |
| mockAxios.patch = jest.fn(() => Promise.resolve({ data: {} })) | |
| mockAxios.create = jest.fn(() => mockAxios) | |
| export default mockAxios |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment