Cypress Clear Session Storage

Profile picture for user arilio666

When test isolation is set, Cypress automatically clears all session data before each test to prevent the state from being shared across tests. This command should only remove sessionStorage within a single test or if test isolation is off.

In Cypress, use the win.sessionStorage.clear() command to clear the session storage. This command deletes all data from the current origin's session storage.

As a workaround, you can clear sessionStorage manually as follows:

cy.window().then((win) => {
 win.sessionStorage.clear()
})

By using this, you ensure that the session storage is cleared and ready for the next test.