Reputation: 1
I'm testing a component that appears on many pages of a WEB site, so I created a script that passes by each one. It works, but if a failure happens on some URL the test stops, and the script doesn't move on to the other URLs.
I'm using a file .json within the Fixture folder that contains an array with some URLs.
[
{"url":"www.example01.com"},
{"url":"www.example02.com"},
{"url":"www.example03.com"},
{"url":"www.example04.com"}
]
I'm using this script below for run a test on each URL.
/// <reference types="cypress"/>
const urlTest = require('../../fixtures/URLs.json')
const estado = 'São Paulo'
const municipio = 'SAO PAULO'
describe('Test de url', () => {
it(`Visit URL and check the resseler component`, () => {
cy.get(urlTest).each((param) => {
cy.visit(param.url)
cy.welcomeBannerAndCookiesAcceptation()
cy.intercept('POST', '**/WhereToBuyResult').as('searchResultState')
cy.intercept('POST', '**/CitiesReSellers').as('searchResultTown')
cy.validateMunicipioFieldIsAvailable()
cy.getState(estado)
cy.wait('@searchResultTown')
cy.getTown(municipio)
cy.wait('@searchResultState')
cy.validateIfResselersAreVisible()
});
})
})
I'm seeking a solution that keeps testing the component on each URL regardless of whether a fail was found or not, and indicates which URLs have presented failures.
Cypress: v10.9.0
Thanks
Upvotes: 0
Views: 205
Reputation: 150
This will give independent tests, so if one fails the others still run.
/// <reference types="cypress"/>
const urlTests = require('../../fixtures/URLs.json')
describe('Test de url', () => {
urlTests.forEach(URL => {
it(`Visit "${url}" and check the resseler component`, () => {
cy.visit(url)
...
})
})
})
Upvotes: 2