From 4c6fb1e943c58f64ea046401c5a073e36cb9bc56 Mon Sep 17 00:00:00 2001 From: Stephen John Sorensen Date: Wed, 30 Nov 2016 08:17:57 -0500 Subject: [PATCH] Add testURL to jest config In my tests, jsdom was throwing a "SecurityError" at HistoryImpl._sharedPushAndReplaceState (node_modules/react-scripts/node_modules/jsdom/lib/jsdom/living/window/History-impl.js:87:15) This happens because document.URL defaults to "about:blank". Unfortunately, if you interact with the History object it tries and fails to parse the URL, causing a "SecurityError" to be thrown. Setting the default URL to "http://localhost" fixes this issue. --- packages/react-scripts/utils/createJestConfig.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-scripts/utils/createJestConfig.js b/packages/react-scripts/utils/createJestConfig.js index 46f3a1da1a..8361e45c0e 100644 --- a/packages/react-scripts/utils/createJestConfig.js +++ b/packages/react-scripts/utils/createJestConfig.js @@ -27,6 +27,7 @@ module.exports = (resolve, rootDir, isEjecting) => { setupTestFrameworkScriptFile: setupTestsFile, testPathIgnorePatterns: ['/(build|docs|node_modules)/'], testEnvironment: 'node', + testURL: 'http://localhost', }; if (rootDir) { config.rootDir = rootDir;