diff --git a/packages/react-app-polyfill/jsdom.js b/packages/react-app-polyfill/jsdom.js index 5ad61e54923..1fa4c99623c 100644 --- a/packages/react-app-polyfill/jsdom.js +++ b/packages/react-app-polyfill/jsdom.js @@ -6,5 +6,9 @@ */ 'use strict'; -// fetch() polyfill for making API calls. -require('whatwg-fetch'); +// Make sure we're in a Browser-like environment before importing polyfills +// This prevents `fetch()` from being imported in a Node test environment +if (typeof window !== 'undefined') { + // fetch() polyfill for making API calls. + require('whatwg-fetch'); +}