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

jsdom is not a function + SecurityError localStorage workaround #324

Open
Phhofm opened this issue Nov 21, 2019 · 0 comments
Open

jsdom is not a function + SecurityError localStorage workaround #324

Phhofm opened this issue Nov 21, 2019 · 0 comments

Comments

@Phhofm
Copy link

Phhofm commented Nov 21, 2019

I was just going thorugh the docs, setting up the environment for my project.
In section Guides - JSDOM, when using the code provided for the helper script 'setup.js', i ran into 'jsdom('') is not a function' and localStorage SecurityError.
I just wanted to post a workaround that worked for me, in case others run into the same problem:

Replace
const jsdom = require('jsdom'),jsdom;
global.document = jsdom('');

with
const jsdom = require('jsdom');
const {JSDOM} = jsdom;
const {document} = (new JSDOM('',{url: "http://localhost"})).window;
global.document = document;

This worked for me :)

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

1 participant