Cypress.session
Cypress.session
is a collection of session-related helper methods intended to
be used alongside the cy.session()
command.
Experimental
The session
API is currently experimental, and can be enabled by setting the
experimentalSessionAndOrigin
option to
true
in the Cypress config.
Enabling this flag does the following:
- It adds the
cy.session()
andcy.origin()
commands, andCypress.session
API. - It adds the following new behaviors (that will be the default in a future
major update of Cypress) at the beginning of each test:
- The
testIsolation
mode is enhanced fromlegacy
mode toon
mode such that- The page is cleared (by setting it to
about:blank
). - Cookies, local storage and session storage in all domains are cleared.
- The page is cleared (by setting it to
- The
- It supersedes the
Cypress.Cookies.preserveOnce()
andCypress.Cookies.defaults()
methods. - Cross-origin requests will now succeed, however, to interact with a
cross-origin page you must use a
cy.origin
block.
Because the page is cleared at the beginning of each test by default,
cy.visit()
must be explicitly called at the beginning
of each test.
Syntax
Clear all saved sessions and re-run the current spec file.
Cypress.session.clearAllSavedSessions()
This can also be done by clicking the "Clear All Sessions" button in the Sessions Instrument Panel.
