Commit aaa615f6 authored by Stephen John Sorensen's avatar Stephen John Sorensen Committed by Dan Abramov
Browse files

Add testURL to jest config (#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.
parent 15f65a0a
Showing with 1 addition and 0 deletions
+1 -0
...@@ -27,6 +27,7 @@ module.exports = (resolve, rootDir, isEjecting) => { ...@@ -27,6 +27,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
setupTestFrameworkScriptFile: setupTestsFile, setupTestFrameworkScriptFile: setupTestsFile,
testPathIgnorePatterns: ['<rootDir>/(build|docs|node_modules)/'], testPathIgnorePatterns: ['<rootDir>/(build|docs|node_modules)/'],
testEnvironment: 'node', testEnvironment: 'node',
testURL: 'http://localhost',
}; };
if (rootDir) { if (rootDir) {
config.rootDir = rootDir; config.rootDir = rootDir;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment