Skip to content

Instantly share code, notes, and snippets.

@riccardogiorato
Created September 26, 2021 17:54
Show Gist options
  • Save riccardogiorato/e123e3d1bd30aea94869a62cf96b145e to your computer and use it in GitHub Desktop.
Save riccardogiorato/e123e3d1bd30aea94869a62cf96b145e to your computer and use it in GitHub Desktop.
const baseUrlTesla = "https://www.tesla.com/";
const url404test = "https://www.tesla.com/not-a-real-page";
it("404 'not found' response", () => {
cy.request({
url: url404test,
followRedirect: false,
failOnStatusCode: false,
}).then((resp) => {
expect(resp.status).to.eq(404);
expect(resp.redirectedToUrl).to.eq(undefined);
});
cy.visit(url404test, { failOnStatusCode: false });
cy.get(".error-code").should("contain", "404");
cy.get(".error-text").should("contain", "Page not found");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment