Error using jsdom with Node 7.4.0
See original GitHub issueI am working on a project that uses mocha with jsdom and enzyme to run our integration tests within a virtual dom in Node. Right now I am using node 6.9.2, and everything works fine. I tried using 7.4.0, however running the tests I got the error
SyntaxError
at XMLHttpRequest.open (/Users/jake/metamason/react-frontend/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:458:15)
at XMLHttpRequest.tryCatcher (/Users/jake/metamason/react-frontend/node_modules/rxjs/src/util/tryCatch.ts:7:27)
at AjaxSubscriber.send (/Users/jake/metamason/react-frontend/node_modules/rxjs/src/observable/dom/AjaxObservable.ts:232:37)
at new AjaxSubscriber (/Users/jake/metamason/react-frontend/node_modules/rxjs/src/observable/dom/AjaxObservable.ts:203:10)
at AjaxObservable._subscribe (/Users/jake/metamason/react-frontend/node_modules/rxjs/src/observable/dom/AjaxObservable.ts:172:12)
I haven’t really done any investigation into the root cause of this, but I thought I’d let you know what I saw. Here’s the testHelper file that I use to set things up:
const chai = require('chai');
const chaiImmutable = require('chai-immutable');
const jsdom = require('jsdom').jsdom;
// Set Chai Immutable
chai.use(chaiImmutable);
// Set up jsdom
global.document = jsdom('<html><body><div id="app"></div></body></html>', {
url: 'http://example.com',
});
global.window = document.defaultView;
Object.keys(document.defaultView).forEach((property) => {
if (typeof global[property] === 'undefined') {
global[property] = document.defaultView[property];
}
});
global.navigator = {
userAgent: 'node.js',
};
window.sessionStorage = window.localStorage = {
getItem() {},
setItem() {},
removeItem() {},
};
// jsdom doesn't have an implementation for this because they don't do layout.
// I opened an issue, and they might add a stub in the future with a warning
// Needed because the grommet Drop util was calling it for Menu components
window.HTMLElement.prototype.scrollIntoView = function() {};
window.performance = require('./helpers/performanceNowPolyfill')();
Let me know if you need any more info!
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
jsdom - npm
jsdom. jsdom is a pure-JavaScript implementation of many web standards, notably the WHATWG DOM and HTML Standards, for use with Node.js.
Read more >How to import d3.js in a node and typescript project ...
I made the function that generates the document async and added that line at the start but nope. Anyway, if I believe the...
Read more >require is not defined babel | The AI Search Engine You Control
Issue npm run start to bring up webpack-dev-server at port 9000. ... If you are using Babel 7.4.0 or newer, then @babel/polyfill has...
Read more >CLI install on Linux Mint 19.3 - Support - Joplin Forum
I tried installing the CLI, but failed. On my desktop I already have Joplin 1.3.18 working. I was not sure if it is...
Read more >Release Notes | Firebase - Google
This release includes a bug fix in Crashlytics. October 17, 2022. SDK Releases. The Firebase Admin Node.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not working on 7.9.0! 😦
Yeah, there was a regression in v7.4.0. There are still some issues left, but maybe you’re not hitting them as much. In general see https://github.com/nodejs/node/issues/6283 for a list of all the potential issues.