JSDOM error in attribute.js

144 views Asked by At

I'm using mocha for unit tests and trying to use jsdom for html elements on my unit tests.

I downloaded the jsdom.zip and imported the library for my tests, and get stuck on this error:

jsdom/living/attributes.js:114 for (const name of Object.getOwnPropertyNames(prototype)) { ^^ SyntaxError: Unexpected identifier

I tried to find the cause of this error message on Google but unfortunately I wasn't able to find an answer.

1

There are 1 answers

0
Daff On BEST ANSWER

The latest JSDOM does not work with older versions of Node (the syntax error is probably the ES6 const). As the readme says:

Note that as of our 4.0.0 release, jsdom no longer works with Node.js™, and instead requires io.js. You are still welcome to install a release in the 3.x series if you use Node.js™.

Try upgrading to latest Node or downloading version 3.x (also, NPM might make this much easier than downloading ZIP files :)