Skip to content

Commit 1716424

Browse files
spudlyalexdriaguine
authored andcommitted
Add testURL to jest config (facebook#1120)
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.
1 parent 704ac03 commit 1716424

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Diff for: packages/react-scripts/utils/createJestConfig.js

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
2727
setupTestFrameworkScriptFile: setupTestsFile,
2828
testPathIgnorePatterns: ['<rootDir>/(build|docs|node_modules)/'],
2929
testEnvironment: 'node',
30+
testURL: 'http://localhost',
3031
};
3132
if (rootDir) {
3233
config.rootDir = rootDir;

0 commit comments

Comments
 (0)