https://cypress.io logo
beforeEach(() => { cy.dataSession({ name...
# e2e-testing
a
beforeEach(() => { cy.dataSession({ name: 'user', setup() { cy.login() cy.getCookie('access') }, validate(cookie) { // try making a request with the cookie value // to a protected route. If it is successful // we are good to go. If we get a redirect // to login instead, we know the cookie is invalid cy.request({ url: '/sqleditor', failOnStatusCode: false, followRedirect: false, headers: { cookie:
access=${cookie.value}
, }, }) .its('status') .then((status) => status === 200) }, recreate(cookie) { cy.setCookie('access', cookie.value) cy.visit('/sqleditor') }, dependsOn: ['user'], }) }); after(() => { cy.clearCookies() Cypress.session.clearAllSavedSessions(); });