Answered
Before running a new Cypress test, how can I clear all the localStorage data that may be saved in the browser. I want to make sure I have a clean slate on my localStorage before running a new test.
I can remove each individual localStorage item, but that seems overkill.
Any ideas on how to do this?
Cypress provides a clearLocalStorage() method:
cy.clearLocalStorage()
To prevent shared state from overlapping between tests, Cypress runs this automatically before each test starts. So you should only have to use this inside tests to clear localStorage data.