0
0
Cypresstesting~5 mins

Cookie management in Cypress - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a cookie in web testing?
A cookie is a small piece of data stored by the browser to remember information about the user or session.
Click to reveal answer
beginner
How do you get a cookie value in Cypress?
Use cy.getCookie('cookieName') to retrieve a cookie by its name.
Click to reveal answer
beginner
How can you clear all cookies in a Cypress test?
Use cy.clearCookies() to remove all cookies before or after a test.
Click to reveal answer
intermediate
Why is cookie management important in testing?
Cookies store session info and preferences. Managing them ensures tests run with the right user state and avoid flaky results.
Click to reveal answer
intermediate
How do you set a cookie in Cypress before visiting a page?
Use cy.setCookie('cookieName', 'value') to set a cookie, then visit the page to test with that cookie.
Click to reveal answer
Which Cypress command retrieves a cookie by name?
Acy.readCookie('name')
Bcy.cookie('name')
Ccy.fetchCookie('name')
Dcy.getCookie('name')
What does cy.clearCookies() do?
ADeletes all cookies
BDeletes one cookie
CSets a new cookie
DReads cookie values
Why should you manage cookies in tests?
ATo control user session and avoid flaky tests
BTo speed up test execution
CTo change the browser theme
DTo disable JavaScript
How do you set a cookie in Cypress?
Acy.createCookie('name', 'value')
Bcy.addCookie('name', 'value')
Ccy.setCookie('name', 'value')
Dcy.newCookie('name', 'value')
When is it best to clear cookies in tests?
AOnly once when installing Cypress
BBefore or after tests to reset state
CNever, cookies should persist
DOnly during test failures
Explain how to manage cookies in Cypress tests and why it is important.
Think about commands to read, write, and clear cookies and why session control matters.
You got /5 concepts.
    Describe a scenario where failing to clear cookies could cause test problems.
    Consider how leftover cookies affect user login or preferences in tests.
    You got /4 concepts.