function AssertResponseCode200(request) {
cy.wait(request).then(response => {
expect(response.status).to.eq(200);
});
}
function CheckDictionaries() {
var requestUrls = [
"requestUrl1",
"requestUrl2",
"..."
];
for (let i = 0; i < requestUrls.length; i++) {
cy.route("GET", requestUrls[i]).as(`request${i}`);
AssertResponseCode200(`@request${i}`);
}
}
it("Assert dictionaries", () => {
cy.server();
CheckDictionaries();
});
CypressError: Timed out retrying: cy.wait() timed out waiting 5000ms for the 1st request to the route: 'request1'. No request ever occurred.
I want to cycle through requests and check that everything works fine and response code is 200. But I'm stuck, because the only url that gets aliased is the first one in my array, but I need all elements of my requestUrls
array to be aliased with request${i}
. Is there anything wrong with my code, or routes in cypress can not work with for loops?
Aucun commentaire:
Enregistrer un commentaire