Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOMException.SECURITY_ERR with react router #1378

Closed
kilianc opened this issue Feb 6, 2016 · 4 comments
Closed

DOMException.SECURITY_ERR with react router #1378

kilianc opened this issue Feb 6, 2016 · 4 comments

Comments

@kilianc
Copy link

kilianc commented Feb 6, 2016

/../app/node_modules/jsdom/lib/jsdom/living/window/History-impl.js:87
        throw new DOMException(DOMException.SECURITY_ERR, `Could not parse url argument "${url}" to ${methodName} ` +
        ^
SecurityError
    at HistoryImpl._sharedPushAndReplaceState (/../app/node_modules/jsdom/lib/jsdom/living/window/History-impl.js:87:15)
    at HistoryImpl.replaceState (/../app/node_modules/jsdom/lib/jsdom/living/window/History-impl.js:72:10)
    at History.replaceState (/../app/node_modules/jsdom/lib/jsdom/living/generated/History.js:89:58)
    at getCurrentLocation (/../app/node_modules/history/lib/createBrowserHistory.js:60:39)
    at Object.listen (/../app/node_modules/history/lib/createHistory.js:106:23)
    at Object.listen (/../app/node_modules/history/lib/createDOMHistory.js:31:20)
    at Object.listen (/../app/node_modules/history/lib/createBrowserHistory.js:144:28)
    at Object.listen (/../app/node_modules/history/lib/useBasename.js:78:22)
    at Object.listen (/../app/node_modules/history/lib/useQueries.js:111:22)
    at syncHistory (/../app/node_modules/react-router-redux/lib/index.js:78:11)

ref: remix-run/history#224

@Sebmaster
Copy link
Member

See #1372.

@kilianc
Copy link
Author

kilianc commented Feb 6, 2016

@Sebmaster I confirm this fixes it:

const jsdom = require('jsdom').jsdom

global.document = jsdom('<!doctype html><html><body><div id="app"></div></body></html>', {
  url: 'http://localhost'
})
global.window = document.defaultView
global.navigator = global.window.navigator

@marlonicus
Copy link

marlonicus commented Mar 2, 2017

Just in case anyone was led here via the same stack trace I was:

If you're using Jest, don't forget to add a testURL property to your Jest config. This fixed the issue for me 👍

@ianlyons
Copy link

@marlonicus would you mind updating that to testURL (all-caps URL)? Thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants