I have this code in my cypress test:
it.only('Checks "Billing" -> invoice section when products are added', () => {
cy.get('app-product').each(($product, index) => {
if ($product.find('input.product-name').length > 0) {
// we need this in order to break the loop and run the test only one time. makes no sence to run the same tests on all products
cy.wrap($product).find('input.product-name').first().then(($input) => {
if ($input.val() === 'productName') {
cy.wrap($product).find('.column-elem.amount').find('.nav-item.actions i-feather[name="more-vertical"].dropdown-toggle').click();
Elements.getButtonInDropdownMenu(Translations.get('BILLINGS.COPY')).scrollIntoView().click({force: true});
Permission.isAccessDeniedActionDone();
Permission.closeAccessDeniedModal();
// this does not break !!!
return false;
}
});
}
});
});
In the html page there can be multiple inputs with the value "productName". In order to be effective I want to run the test only once for one of the inputs. But I can not break the test with "return false;". So my question is: how to run the test only once and/or break the loop in my case?