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?
✗ Incorrect
cy.clearLocalStorage() clears all local storage data. Other options clear cookies or session storage, not local storage.
How do you set a local storage item with key 'token' and value 'abc123' in Cypress?
✗ Incorrect
The correct command is cy.window().then((win) => { win.localStorage.setItem('token', 'abc123') }) to set local storage data.
What happens to local storage data when the browser is closed?
✗ Incorrect
Local storage data persists even after the browser closes, unlike session storage which is cleared.
Which command verifies a local storage key 'user' equals 'admin' in Cypress?
✗ Incorrect
cy.getLocalStorage('user').should('eq', 'admin') is the correct way to assert local storage value.
Why should tests clear local storage before running?
✗ Incorrect
Clearing local storage ensures no leftover data causes false test results, keeping tests reliable.
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.