如何在两个数字之间找到一个值的断言
let lastArrayAmountValue=50;
assert.equal(lastArrayAmountValue, '5');
我想断言数字是否在5-10
之间,这是在柏树上进行的测试。
发布于 2022-08-12 04:15:40
expect(lastArrayAmountValue).to.be.within(5,10)
https://docs.cypress.io/guides/references/assertions#BDD-Assertions
看来这种能力是建立在柏树上的
发布于 2022-08-12 07:54:08
如果要将within
应用于异步元素,请将其移动到.should()
中以触发对断言的重试。
例如,
cy.get(elementArraySelector)
.last()
.should($el => {
const value = +$el.text() || 0;
expect(lastArrayAmountValue).to.be.within(5,10) // retry until timeout
})
发布于 2022-08-12 07:16:18
你也可以这样做。数字大于等于5,小于等于10。
cy.wrap(lastArrayAmountValue).should('be.gte', 5).and('be.lte', 10)
https://stackoverflow.com/questions/73329168
复制相似问题