我正在尝试使用 Ember、Brunch 和 JSDom 进行 headless 测试。我正在使用 ember-brunch-sculpture 来生成应用程序。
https://github.com/fuseelements/ember-brunch-skeleton
我已经安装了所有依赖项。
当我尝试运行“早午餐测试”时,出现以下错误。似乎我在这里缺少一些基本的东西,但这是我第一次使用 node.js/jsdom/mocha 等。我缺少什么?
TypeError: Object [ jsdom NodeList ]: contains 3 items has no method 'map'
at getScriptFilesPath (/usr/local/lib/node_modules/brunch/lib/commands/test.js:62:60)
at readTestFiles (/usr/local/lib/node_modules/brunch/lib/commands/test.js:80:25)
at fs.readFile (fs.js:176:14)
at fs.close (/usr/local/lib/node_modules/brunch/node_modules/rimraf/node_modules/graceful-fs/graceful-fs.js:90:5)
at Object.oncomplete (fs.js:297:15)
最佳答案
看起来这与 jsdom 0.4.0 版本有关。具体来自changelog :
- Change: NodeLists no longer inconsistently have array methods. Previously, live node lists would have indexOf, while static node lists would have them all. Now, they have no array methods at all, as is correct per the specification.
如果您正在寻找快速修复方法,恢复到 jsdom 0.3.4 应该可以解决问题:
npm uninstall jsdom
npm install <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bbd1c8dfd4d6fb8b9588958f" rel="noreferrer noopener nofollow">[email protected]</a>
brunch test
关于ember.js - 早午餐,JSDom : Object [ jsdom NodeList ]: contains 3 items has no method 'map' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14758477/