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 --
getValue
a custom command (and if so, can you post the contents of it)?should
command is failing at some point in the loop.