Cypress - preserve cookies between tests
Preserving cookies between multiple tests
This is in the Cypress docs, still it's something that can be said more than once.
When writing multiple tests, Cypress automatically clears all cookies by default to ensure a clean test state.
Although this is a good default behaviour, it can be something you scratch your head on for a second or two, so - here's a quick example of what doesn't work and how to fix it:
cookieA is set in the first test but cleared in the context of the second test, unless you specifically tell Cypress to back off:
There's also an option that lets you preserve cookies by whitelisting them.
When in doubt, read the docs.