Skip to content

Instantly share code, notes, and snippets.

@nurmuhammadsirat
Last active February 19, 2020 06:55
Show Gist options
  • Save nurmuhammadsirat/3b92a5b4c81554ce07ace918f4f98f91 to your computer and use it in GitHub Desktop.
Save nurmuhammadsirat/3b92a5b4c81554ce07ace918f4f98f91 to your computer and use it in GitHub Desktop.
// Put this whole file in __mocks__ folder as a sibling to __tests__
// In the xxxx.test.js, you can do an import 'mockAxios' from 'axios'
const mockAxios = jest.genMockFromModule("axios");
// @ts-ignore
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