I am a newcomer to using Cypress
and I'm exploring an HTML page for testing purposes. My goal is to test the login authentication and log the body of an XHR
.
Here's the test code I wrote for this:
describe('Login test', function () {
it("Test description", () => {
cy.server();
cy.visit("login");
cy.route({
method: "POST",
url: '/login'
}).as("login");
cy.get('#username')
.type(Cypress.env('Account'));
cy.get('#password')
.type(Cypress.env('Password'));
cy.get('#login')
.click();
cy.wait("@login").then(xhr => {
cy.log(JSON.stringity(xhr.response.body));
});
});
});
However, the test failed with the following error message:
CypressError: Timed out retrying: cy.wait() timed out waiting 5000ms for the 1st request to the route: 'route_login'. No request ever occurred.
Can anyone offer assistance, please?