Reputation: 307
Hi i have an array of object like so,
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);
}
});
i have to tried to check if arr_obj[0].value is equal to expectedValue like above. but it gives error
invalid chai property should
how should i check with cypress if the arr_obj[0].value and expectedValue are same.
could someone help me with this. thanks.
Upvotes: 2
Views: 2369
Reputation: 18634
expect
and should
are two different types of assertions and cannot be used together.
So in case if you want to use expect
you have to use:
expect(arr_obj[0].value).to.equal(expectedValue)
And in case you want to use should
, you can do:
cy.wrap(arr_obj[0].value).should('eq', expectedValue)
Upvotes: 2