Saving cookies in Cypress without cy.session()

Viewed 75

I am looking for some way how to save exact cookie in Cypress through whole test case.

Was using

Cypress.Cookies.defaults({ preserve: 'cookie_name' })

and

Cypress.Cookies.preserveOnce('cookie_name')

but this doesn't work anymore. And the new cy.session() is not working for me, because I use custom addresses per user and per new form.

Does anyone know of anything that works better than cy.session()?

1 Answers

The use pattern of cy.session() is a bit opaque, but since it replaces the older cookie config it probably can be made to work.

I have seen a note somewhere that session is likely to be revamped shortly.

Since Cypress.Cookies.preserveOnce('cookie_name') is deprecated but still available, maybe use that until session mark 2 comes along.

Related