Skip to main content

Cypress.Cookies

Cookies.debug() enables you to generate logs to the console whenever any cookies are modified.

Syntax​

Cypress.Cookies.debug(enable, options)

Arguments​

enable (Boolean)

Whether cookie debugging should be enabled.

options (Object)

Pass in an options object to control the behavior of Cookies.debug().

optiondescriptiondefault
verboseWhether or not to display the entire cookie object.true

Examples​

Debug​

By turning on debugging, Cypress will automatically generate logs to the console when it sets or clears cookie values. This is useful to help you understand how Cypress clears cookies before each test, and is useful to visualize how to handle preserving cookies in between tests.

Cypress.Cookies.debug(true) // now Cypress will log when it alters cookies

cy.clearCookie('foo')
cy.setCookie('foo', 'bar')
Console log when debugging cookies

Turn off verbose debugging output​

By default Cypress will log the cookie object which allows you to inspect all of its properties. However you may not need that level of detail and you can turn this off.

Cypress.Cookies.debug(true, { verbose: false })

Now when Cypress logs cookies they will only include the name and value.

Console log cookies with debug

Debugging will be turned on until you explicitly turn it off.

Cypress.Cookies.debug(false) // now debugging is turned off

History​

VersionChanges
11.0.0Removed preserveOnce and defaults
9.7.0Deprecated preserveOnce and defaults
5.0.0Renamed whitelist option to preserve
0.16.1{verbose: false} option added
0.16.0Removed support for Cypress.Cookies.get, Cypress.Cookies.set and Cypress.Cookies.remove
0.12.4Cypress.Cookies API added

See also​