Skip to main content
Cypress App

clearAllLocalStorage

Clear localStorage data for all origins with which the test has interacted.

caution

Cypress automatically clears all local storage before each test to prevent state from being shared across tests when test isolation is enabled. You shouldn't need to use this command unless you're using it to clear localStorage inside a single test or test isolation is disabled.

Syntax​

cy.clearAllLocalStorage()
cy.clearAllLocalStorage(options)

Usage​

Correct Usage

cy.clearAllLocalStorage()

Arguments​

options (Object)

Pass in an options object to change the default behavior of cy.clearAllLocalStorage().

OptionDefaultDescription
logtrueDisplays the command in the Command log

Yields Learn about subject management​

  • cy.clearAllLocalStorage() yields null.

Rules​

Requirements Learn about chaining commands​

  • cy.clearAllLocalStorage() requires being chained off of cy.

Assertions Learn about assertions​

  • cy.clearAllLocalStorage() cannot have any assertions chained.

Timeouts Learn about timeouts​

  • cy.clearAllLocalStorage() cannot time out.

See also​