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
). - All active session data (cookies,
localStorage
andsessionStorage
) across all domains are cleared.
- The page is cleared (by setting it to
- The
- It overrides the
Cypress.Cookies.preserveOnce()
andCypress.Cookies.defaults()
methods. - Cross-origin navigation will no longer fail immediately, but instead, time out
based on
pageLoadTimeout
. - Tests will no longer wait on page loads before moving on to the next test.
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.
