【发布时间】:2018-06-26 08:16:12
【问题描述】:
我想使用 Chai 测试 HTML eemnet 的属性,如下所示:
const chai = require('chai');
const expect = chai.expect;
expect(document.getElementById('ref_button')).to.have.attr('disabled');
我把这行放在 fr chai-dom chai.use(require('chai-dom'))
它引发了错误:
Unhandled rejection ReferenceError: document is not defined at
C:\Users\67563478\new_workspace\onconsup\node_modules\chai-dom\chai-dom.js:69:53 at Object.exports.use
(C:\Users\67563478\new_workspace\onconsup\node_modules\chai\lib\chai.js:39:5)
NODE_LIST_STRING = Object.prototype.toString.call(document.childNodes),
我删除了这条线,并且该错误不再存在。现在,document.getElementById 行的错误是document is not defined。
我该怎么办?也许图书馆 chai-dom 已被弃用?
【问题讨论】:
标签: javascript html angular testing chai