Add to Cheatsheet: Check whether a route/url is accessible

Created on 11 April 2024, 9 months ago

Iff you need to check whether a route/url is accessible in Cypress here's how you can do it:

describe("Test path access", () => {
  it("Anon user is not able to access route", () => {
    cy.request({
      url: '/example-url',
      followRedirect: false,
      failOnStatusCode: false
    }).then((resp) => {
      expect(resp.status).to.eq(403)
    })
  });
  it("admin role can access page", () => {
    cy.login('cypress', 'cypress')
    cy.visit('/example-url')
  });
});
✨ Feature request
Status

Active

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States thejimbirch Cape Cod, Massachusetts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024