mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-01 12:42:50 +08:00
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.
This commit is contained in:
committed by
Dan Abramov
parent
15f65a0a4e
commit
aaa615f6fa
@@ -27,6 +27,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
|
||||
setupTestFrameworkScriptFile: setupTestsFile,
|
||||
testPathIgnorePatterns: ['<rootDir>/(build|docs|node_modules)/'],
|
||||
testEnvironment: 'node',
|
||||
testURL: 'http://localhost',
|
||||
};
|
||||
if (rootDir) {
|
||||
config.rootDir = rootDir;
|
||||
|
||||
Reference in New Issue
Block a user