Support for jsdom ~v10.0.0
Closed this issue ยท 7 comments
dancio commented
New release of jsdom has a different pattern for initialization:
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
which causes such error:
.../node_modules/jsdom-global/index.js:29
var document = jsdom.jsdom(html, options)
^
TypeError: jsdom.jsdom is not a function
at globalJsdom (.../node_modules/jsdom-global/index.js:29:24)
at Object.<anonymous> (../node_modules/jsdom-global/register.js:1:19)
at Module._compile (module.js:570:32)
at Module._extensions..js (module.js:579:10)
at Object.require.extensions.(anonymous function) [as .js] (.../node_modules/babel-register/lib/node.js:152:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at ../node_modules/mocha/bin/_mocha:345:3
at Array.forEach (native)
at Object.<anonymous> (../node_modules/mocha/bin/_mocha:344:10)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:393:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:508:3
brenwell commented
+1
mxschumacher commented
I ended up just specifying the version number of the last release pre 10.0.0. You can find it here:
https://github.com/tmpvar/jsdom/releases/tag/9.12.0
in package.json: "jsdom": "9.12.0"
dancio commented
@MaxSchumacher yeah did the same, downgraded to the 9.12.x
for now
thibautsabot commented
I made a PR here : #23
rstacruz commented
Thank you all for your hard work, and thanks @GinjiBan for the implementation! ๐
trollkotze commented
It seems there is still almost the same problem in 11.5.1.
I get: TypeError: JsDOM is not a constructor
using this pattern:
const jsdom = require('jsdom');
const {JsDOM} = jsdom;
let dom = new JsDOM(body); // body should be the complete content of some html page as string
trollkotze commented
Okay, I got it now.
I did this instead.
const JsDOM = require('jsdom').JSDOM;
let dom = new JsDOM(body);
The code intro on the NPM package site seems misleading.