2015-06-22 30 views
0

我在单元测试中使用mocha进行单元测试,并尝试使用jsdom代替html元素。attribute.js中的JSDOM错误

我下载了jsdom.zip和进口图书馆为我的测试,并获得被困在此错误:

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

我试图找到在谷歌此错误消息的原因,但遗憾的是我没能找到答案。

回答

2

最新的JSDOM不适用于旧版本的节点(语法错误可能是ES6 const)。正如readme说:

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™.

尝试升级到latest Node或下载3.x版本(也可能NPM比下载ZIP文件,使这更容易:)