Replace our fetch and Response mocking with fetch-mock-jest
See original GitHub issueWe have some places where we mock fetch
and Response
and this is easily messy.
Instead we should use fetch-mock-jest
Use git grep '\.fetch' src/test/
to see all usages.
It’s probably possible to migrate step by step, with several PRs.
Step 1: install and set up the package Step 2: use it in test files. This could be split in different PRs for an easier review.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:14 (6 by maintainers)
Top Results From Across the Web
How To Mock Fetch in Jest | Leigh Halliday
One option when manually mocking a module is to create a folder named __mocks__ and place a file in it with the same...
Read more >jefflau/jest-fetch-mock - GitHub
Jest Fetch Mock allows you to easily mock your fetch calls and return the response you need to fake the HTTP requests. It's...
Read more >How to mock fetch calls with jest | Medium | Fernando Ferreira
The solution is to use jest to mock the fetch function globally. ... any following calls will return the default mocked response.
Read more >Mocking Fetch Using jest-fetch-mock - YouTube
This video focuses on testing a function which makes a fetch call, mocking fetch using the jest - fetch - mock package rather...
Read more >A Beginners Guide to Learn Mock Fetching in jest - HackerNoon
I am writing this post to show how to mock and test fetch with jest-fetch-mock. let's suppose that you are using Jest and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hey @ryotabs, sure! Please report your progress within 1 week so that we know you’re still working on this. Thanks!
I updated the description to reflect the current work needed here. Indeed thanks to the work of @ryotabs we identified another npm package that we’d like to use, different than the one we considered initially.