Skip to content

Commit

Permalink
chore(jest): create axios mock
Browse files Browse the repository at this point in the history
improves #26
  • Loading branch information
aneurysmjs committed Aug 22, 2019
1 parent f6e3076 commit 0b7c442
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/app/__mocks__/axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @link https://medium.com/@kilgarenone/use-jest-to-test-redux-async-action-creator-with-axios-in-a-create-react-app-app-d9c9b52eba5e
*/
const mockAxios = jest.genMockFromModule('axios');

// this is the key to fix the axios.create() undefined error!
mockAxios.create = jest.fn(() => mockAxios);

export default mockAxios;

0 comments on commit 0b7c442

Please sign in to comment.