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:
cy.intercept
requests going to the homepage URL and give them an alias.- Click the logo.
- Use the alias to check that the request to the homepage URL was successful.
- 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);
});
Source:stackexchange.com