【发布时间】:2018-06-26 12:07:50
【问题描述】:
我在 html 中有这个按钮
const dom = new JSDOM(`
<button id="ref_button" type="submit" [disabled]="editForm.form.invalid || isSaving" class="btn btn-primary">`)
我正在使用 Chai 进行这样的测试:
dom.window.document.getElementById("ref_button").should.have.attr('type');
而且效果很好。 但是,如果我想以相同的方式测试 disabled 属性,则测试不起作用:
dom.window.document.getElementById("ref_button").should.have.attr('[disabled]');
它总是说属性存在。这是不正常的,因为根据条件它不应该存在(当我用有效数据填写表格时)。
我在 Chai 做错了吗?
【问题讨论】:
-
But if I want to test the same way一样吗? -
我编辑了这个问题
标签: javascript html angular testing chai