on-internet
← Community

How to unit test API calls with mocked fetch() in react-native with Jest

Stack Overflow ·

In React Native I use fetch to perform network requests, however fetch is not an explicitly required module, so it is seemingly impossible to mock in Jest. Even trying to call a method which uses fetch in a test will result in: ReferenceError: fetch is not defined Is there a way to test such API requests in react native with Jest?

Comments

Sign in or sign up to comment and upvote.

No comments yet.