Код: Выделить всё
let linkArr = [];
describe('I am on desktop view of a page to check the main menu links', () => {
before(() => {
cy.visit(pageUrl);
cy.get('.main-header a').each(($link) => {
linkArr.push($link);
})
});
linkArr.forEach(link => {
it(`Ensures the link works`, () => {
checkLink(link);
const linkText = (link.prop('text').replace("/n", "")).trim();
stepReportNotes(reportObj, testName, `${link.prop('href')} on '${linkText}' returns 200 or 301`);
});
});
});
< /code>
Но это не так. Цикл Foreach Это выполняет свою работу, если я обернут foreach в It Eg:
Код: Выделить всё
it(`Ensures each link works`, () => {
linkArr.forEach(link => {
checkLink(link);
const linkText = (link.prop('text').replace("/n", "")).trim();
stepReportNotes(reportObj, testName, `${link.prop('href')} on '${linkText}' returns 200 or 301`);
});
});
Подробнее здесь: https://stackoverflow.com/questions/796 ... st-against
Мобильная версия