It seems I can't set local storage in Cypress? When I get the item from local storage it is different to what I have set (it always returns the default value)
Am I setting the storage incorrectly?
beforeEach(() => {
cy.clearLocalStorage();
cy.clearCookies();
window.localStorage.setItem('One', 'NL');
window.localStorage.setItem('Two', 'NL');
window.localStorage.setItem('Three', 'NL');
visitPage('/');
cy.window().then((win) => {
const myItemOne = win.localStorage.getItem('One');
const myItemTwo = win.localStorage.getItem('Two');
const myItemThree = win.localStorage.getItem('Three');
cy.log(myItemOne, myItemTwo, myItemThree);
});
Should return log NL, NL, NL, but returns SE, SV, SV