mardi 24 novembre 2020

Failing to pass the test of XHR request using Cypress

Hi people I am new to cypress and I am trying to pass the XHR test but I am failing. What am I doing wrong?

Here are my:

Request URL: http://example.com/api/customer
Request Method: POST
Status Code: 200 OK

Here is my route where my app goes after successful Request:

http://example.com/main/dasboard

Here is my Cypress test:

it.only("Waiting for server response", () => {
    cy.server();
    cy.route("POST", "**/api/customer").as("dataGetFirst");
    cy.wait("@dataGetFirst").its("status").should("be", 200);
  });

On my understanding I have to use the request ending api/customer or I need to use /main/dashboard ?? I also tried to just /customer but test is failing with this error:

Timed out retrying: cy.wait() timed out waiting 5000ms for the 1st request to the route: dataGetFirst. No request ever occurred.

Aucun commentaire:

Enregistrer un commentaire