Is it possible in Cypress.io to gather results of multiple assertions inside .then
construction so that results can be used outside .then
?
Based on below example - if I have some pages that I would like to smoke-test (to check eg. if code is different than 404) how to gather information about them? How to verify results all together in one smoke test?
Please look at this simple piece of code that shows the problem:
describe('Smoke tests for some pages', () => {
it('should be able to view page that was loaded correctly', () => {
// Arrange:
const pageAddressList = [
'https://en.wikipediaaa.org',
'https://en.wikipedia.org'];
const errors = Array();
// Act:
pageAddressList.forEach((pageAddress) => {
cy.request(pageAddress).then((response) => {
// check response and add some error to errors if needed
})
});
// Assert:
// check if errors is empty
});
});
- Is above approach correct?
- Should there be separate tests for each page?
- What if I have 50+ pages to check?
- What is best approach in Cypress.io in such case?