[Vuejs]-How to check in Cypress that we redirected to the same page?

4👍

It sounds like you want to spy on the request made to the homepage URL and make sure it was successful. I just checked this and it works for me. You may need slight modifications like changing the logo’s id and the path of the cy.intercept to match your app. Here are the steps:

  1. cy.intercept requests going to the homepage URL and give them an alias.
  2. Click the logo.
  3. Use the alias to check that the request to the homepage URL was successful.
  4. Any other checks you might want to do, like cy.location or checking for various homepage elements to make sure that the redirect really loaded your homepage successfully.
it("clicking logo reloads/redirects to homepage", () => {
  cy.intercept("/app/home").as("homepage");

  cy.get("#logoThatRedirectsToHomepage").click();
  cy.wait("@homepage").its("response.statusCode").should("eq", 200);
});

Leave a comment