作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我该如何做 or
使用 chai.should
进行测试?
例如就像是
total.should.equal(4).or.equal(5)
或者
total.should.equal.any(4,5)
什么是正确的语法?我在文档中找不到任何内容。
最佳答案
查看 Chai expect / should documentation ,有几种方法可以进行此测试。
请注意,您可以使用“和”进行链接,但显然不能使用“或”——希望他们有这个功能。
@param{ Function }matcher
@param{ String }message_optional_
Asserts that the target passes a given truth test.
expect(1).to.satisfy(function(num) { return num > 0; });
yourVariable.should.satisfy(function (num) {
if ((num === 4) || (num === 5)) {
return true;
} else {
return false;
}
});
@param{ Number }startlowerbound inclusive
@param{ Number }finishupperbound inclusive
@param{ String }message_optional_
Asserts that the target is within a range.
expect(7).to.be.within(5,10);
关于chai - 如何在 chai 中做一个 "or"应该,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32387293/
我是一名优秀的程序员,十分优秀!