Fetch undefined Jest testing

  1. SDK Version: 35
  2. Platforms(Android/iOS/web/all): Android/iOS

I’m trying to run a very simple Jest test:

TypeError: Cannot read property 'fetch' of undefined

      at node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:38:12
      at Object.<anonymous> (node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:35:1)
      at Object.<anonymous> (node_modules/firebase/node_modules/@firebase/polyfill/dist/index.cjs.js:3:1)

and I keep getting this whatwg-fetch error. I’ve tried explicitly setting globals to make fetch available in setup.js of jest-expo and the test itself. No luck. Any tips?

TypeError: Cannot read property 'fetch' of undefined

      at node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:38:12
      at Object.<anonymous> (node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:35:1)
      at Object.<anonymous> (node_modules/firebase/node_modules/@firebase/polyfill/dist/index.cjs.js:3:1)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.