From a7f00adc70a37a5bd864bb640e818528b3514474 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Thu, 27 Sep 2018 09:17:21 -0400 Subject: [PATCH] Don't polyfill fetch for Node --- packages/react-app-polyfill/jsdom.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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'); +}