The steps I want to take are:
- Start the Cypress test-suite and use
cy.setCookie
to set the JSESSIONID cookie (already acquired and up-to-date) - After the cookie is set, then use
cy.visit
to access the running app
The issue:
- The cookie is not set before
cy.visit
runs and this causes the app redirect to an unauthorized page
What I have done so far:
Cypress.Cookies.defaults({
preserve: 'JSESSIONID'
})
cy.setCookie('JSESSIONID', Cypress.env('JSESSIONID'), {
path: '/',
domain: '<domain.name>',
httpOnly: true,
secure: true,
sameSite: 'no_restriction',
log: true,
}).then(() => cy.visit('localhost:3000/<authenticated-route>')
It might be worth mentioning that <domain.name> is of the form www.staging.etc.com whereas is running locally: localhost:3000/
Any help would be greatly appreciated. Thanks in advance
Aucun commentaire:
Enregistrer un commentaire