我使用cucumber和chai- as -promised作为断言库。检查计数值的正确方法是什么?我使用equal,但它只有在将字符串转换为integer.Is之后才起作用,有没有办法直接断言整数值?
this.Then(/^the list should contain "([^"]*)" items$/, function (arg1, callback) {
var count=parseInt(arg1);
expect(element.all(by.repeater('item in list.items')).count()).to.eventually.equal(count).and.notify(callback);
});发布于 2015-05-18 23:26:49
如果您真的想这样做,我相信您可以通过使用Chai的satisfy()方法和JavaScript强制绕过parseInt(),如下所示。然而,我个人更喜欢你目前使用的方法,因为它更容易理解,强制可能会很棘手。
this.Then(/^the list should contain "([^"]*)" items$/, function (arg1, callback) {
expect(element.all(by.repeater('item in list.items')).count()).to.eventually.satisfy(function(count) { return count == arg1 } ).and.notify(callback);
});https://stackoverflow.com/questions/30239936
复制相似问题