Skip to content

Commit

Permalink
Add testURL to jest config (facebook#1120)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
spudly authored and randycoulman committed May 8, 2017
1 parent baf9a2c commit 3a8a7b3
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/react-scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
setupTestFrameworkScriptFile: setupTestsFile,
testPathIgnorePatterns: ['<rootDir>/(build|docs|node_modules)/'],
testEnvironment: 'node',
testURL: 'http://localhost',
};
if (rootDir) {
config.rootDir = rootDir;
Expand Down

0 comments on commit 3a8a7b3

Please sign in to comment.