jsdom is not a function + SecurityError localStorage workaround
Opened this issue · 0 comments
Phhofm commented
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 :)