Cypress clears cookies and local storage before running every test by default. But we can let cypress know to cache the cookies and local storage using cy.session function.
Say you have multiple tests where you need to login every time before performing next set of tests, in this case you can wrap your login code inside cy.session function so that cookies and local storage are cached in the cypress session and same is reused.
Below code shows an example for same.


Leave a comment