Being new to the world of UI automation/Cypress, I am seeking assistance in setting up assertions on a JavaScript object returned by the cypress-ag-grid package.
The code I have is reading data from an ag-grid.
cy.get("#myGrid").getAgGridData().should((data)=>{
cy.log(data)
})
This code prints the following object in console:
[
{ id: 1, name: "tata", safetyRating: "-50" },
{ id: 2, name: "maruti", safetyRating: "-50" },
{ id: 3, name: "ford", safetyRating: "" },
{ id: 4, name: "skoda", safetyRating: "" }
]
As I iterate over the safetyRating field,
cy.get("#myGrid").getAgGridData().should((data)=>{
data.forEach(({ safetyRating }) => {
cy.wrap(+safetyRating).should('be.lt', -50);
})
});
The test fails due to blank values being converted to 0, which is not less than or equal to -50. To pass the test case, I would like to add another assert condition in an 'OR' form, like this: .should('be.eq', 0);
Any better approaches for handling this issue are also welcomed.