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 concept of
testIsolation
which defaults toon
, 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
- 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.