Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about mocking axios: What if i also want to return error from async call? #16

Open
dmngu9 opened this issue Jul 19, 2018 · 0 comments

Comments

@dmngu9
Copy link

dmngu9 commented Jul 19, 2018

So for your mock, axios return a promise with value which is a happy path. However, what if i want to mock it to return an error.

Wonder if i can do like this

const func = jest.fn();
jest.mock('axios', () => {
    get: func
});

then in each test case, can i do func.mockReturnValue for happy and error case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant