-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Added jest.mock line remaining in the main example #180
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
Conversation
Well, I was struggling to mock the axios response following the main example here. After hours searching, I've discovered that I needed to mock the axios to be able to access the mock functions inside of it. So, I've added a small line of code to not break the example and stop new learners.
@@ -272,34 +276,6 @@ module.exports = { | |||
} | |||
``` | |||
|
|||
|
|||
#### Export Issue with Babel Versions Lower Than 7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rebase your PR (or just make a new one) that doesn't remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Ok! I'll create another one!
@@ -89,6 +89,10 @@ import 'jest-dom/extend-expect' | |||
import axiosMock from 'axios' // the mock lives in a __mocks__ directory | |||
import Fetch from '../fetch' // see the tests for a full implementation | |||
|
|||
// Once we mock the module we can provide a mockResolvedValueOnce for .get | |||
// that returns the fake data we want our test to assert against. | |||
jest.mock('axios'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessary because the comment on line 89 indicates that there's a mock in the __mocks__
directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, but I don't think this change is necessary.
Would you like to change this PR to add a link to the jest docs about the |
What:
Well, I was struggling to mock the axios response following the main example here. After hours searching it, I've discovered that I needed to mock the axios to be able to access the mock functions inside of it.
Why:
I've added a small line of code to not break the example and stop new learners.
How:
I followed the example inside the jest documentation.
Checklist: