Skip to content

Instantly share code, notes, and snippets.

@riccardogiorato
Created September 26, 2021 17:51
Show Gist options
  • Save riccardogiorato/46dad7ddc78bc3fe43e6d2f515eb3507 to your computer and use it in GitHub Desktop.
Save riccardogiorato/46dad7ddc78bc3fe43e6d2f515eb3507 to your computer and use it in GitHub Desktop.
const baseUrlTesla = "https://www.tesla.com/";
const urlHttp = "http://tesla.com";
it(urlHttp + " end location", () => {
cy.visit(urlHttp);
cy.url().should("eq", baseUrlTesla);
});
it(urlHttp + " redirect", () => {
cy.request({
url: urlHttp,
followRedirect: false, // turn off following redirects
}).then((resp) => {
// redirect status code is 301
expect(resp.status).to.eq(301);
expect(resp.redirectedToUrl).to.eq(baseUrlTesla);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment