嗨,我有一個像這樣的對像數組,
const arr_obj = [
{
value: '100',
id: '1',
}
]
cypress test code is like below,
it('some test' , () => {
const expectedValue = 200;
cy.apiGetObject(id).then((arr_obj) => {
expect(arr_obj[0].value).should('eq', expectedValue);
}
});
我必須嘗試檢查 arr_obj[0].value 是否等於上面的 expectedValue。但它給出了錯誤
無效的柴財產應
如果 arr_obj[0].value 和 expectedValue 相同,我應該如何檢查 cypress。
有人可以幫我解決這個問題嗎?謝謝。
expect
andshould
是兩種不同類型的斷言,不能一起使用。
因此,如果您想使用expect
,則必須使用:
expect(arr_obj[0].value).to.equal(expectedValue)
如果你想使用should
,你可以這樣做:
cy.wrap(arr_obj[0].value).should('eq', expectedValue)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句