0
0
Cypresstesting~5 mins

Local storage management in Cypress - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is local storage in web testing?
Local storage is a browser feature that stores data on the user's computer. It keeps data even after the browser is closed, allowing tests to check saved information between sessions.
Click to reveal answer
beginner
How do you clear local storage in Cypress?
Use cy.clearLocalStorage() to remove all data from local storage during a test. This helps start tests with a clean state.
Click to reveal answer
intermediate
How to set a local storage item in Cypress before a test?
Use cy.window().then((win) => { win.localStorage.setItem('key', 'value') }) to add data to local storage. This simulates saved data before the app loads.
Click to reveal answer
intermediate
How can you verify a local storage value in Cypress?
Use cy.getLocalStorage('key').should('eq', 'value') to check if the stored value matches what you expect.
Click to reveal answer
beginner
Why is managing local storage important in automated tests?
Managing local storage ensures tests run with predictable data. It avoids leftover data causing false test results and helps simulate user scenarios accurately.
Click to reveal answer
Which Cypress command clears all local storage data?
Acy.clearLocalStorage()
Bcy.clearCookies()
Ccy.resetStorage()
Dcy.clearSessionStorage()
How do you set a local storage item with key 'token' and value 'abc123' in Cypress?
Acy.saveLocalStorage('token', 'abc123')
Bcy.localStorage('token', 'abc123')
Ccy.window().then((win) => { win.localStorage.setItem('token', 'abc123') })
Dcy.storeLocal('token', 'abc123')
What happens to local storage data when the browser is closed?
AIt is deleted
BIt is saved and persists
CIt moves to cookies
DIt is encrypted
Which command verifies a local storage key 'user' equals 'admin' in Cypress?
Acy.assertLocalStorage('user', 'admin')
Bcy.checkLocalStorage('user', 'admin')
Ccy.verifyLocalStorage('user', 'admin')
Dcy.getLocalStorage('user').should('eq', 'admin')
Why should tests clear local storage before running?
ATo avoid leftover data affecting results
BTo test cookies instead
CTo save local storage data
DTo speed up tests
Explain how to manage local storage in Cypress tests and why it is important.
Think about setting, clearing, and checking local storage during tests.
You got /4 concepts.
    Describe the difference between local storage and session storage in the context of automated testing.
    Focus on data persistence and test implications.
    You got /4 concepts.