I have test that opens every item on the list. Then it validates if there are no empty (‘–‘) fields. I want to log in console that there were empty fields and go to another item and run the loop till the end. When Cypress throws error tests are stopped.
How can I catch this error and continue running my loop for other items and log errors.
cy.get('body').then(($body) => {
if ($body.find('.MuiTableRow-root.MuiTableRow-hover .MuiTableCell-body').length > 0) { globalActions.getTableRow().then((element) => {
if (element.is(':visible')) {
globalActions.checkProgressBarDoesntExist().then(() => {
cy.get('table[data-testid="table-items"] tbody tr').each(($row) => {
cy.wrap($row).find('.type').invoke('text').then((stageText) => {
if (stageText.includes('Testing')) {
cy.wrap($row).click();
ItemsValues.forEach((field) => {
cy.wrap(null).then(() => {
itemsActions.getValue(field)
.should('not.contain', '--')
.catch((err) => {
cy.task('log', `DOESNT WORK: ${err.message}`);
});
});
});
}
});
});
});
}
});
}
});
When I try this I get error : Expected .. not to contain —
Natalia Orzeł is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.