[英]javascript assertion between two numbers range
如何找到两个数字之间的值的断言
let lastArrayAmountValue=50;
assert.equal(lastArrayAmountValue, '5');
我想断言数字是否在5-10
之间这是我在柏树上做的测试。
expect(lastArrayAmountValue).to.be.within(5,10)
https://docs.cypress.io/guides/references/assertions#BDD-Assertions
看起来这种能力是内置在柏树中的
如果要within
异步元素中应用,请将其移动到.should()
以触发断言的重试。
例如,
cy.get(elementArraySelector)
.last()
.should($el => {
const value = +$el.text() || 0;
expect(lastArrayAmountValue).to.be.within(5,10) // retry until timeout
})
你也可以这样做。 数字大于等于 5 且小于等于 10。
cy.wrap(lastArrayAmountValue).should('be.gte', 5).and('be.lte', 10)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.