// Colar esses comandos no arquivo cypress/support/index.js
Cypress.Commands.add('saveLocalStorage', () => {
Object.keys(localStorage).forEach(key => {
LOCAL_STORAGE_MEMORY[key] = localStorage[key];
});
});
Cypress.Commands.add('restoreLocalStorage', () => {
Object.keys(LOCAL_STORAGE_MEMORY).forEach(key => {
localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]);
});
});
// quando você deseja persistir o localStorage
cy.saveLocalStorage();
// Dentro de cada 'describe'
beforeEach(() => {
cy.restoreLocalStorage();
});
Last active
June 5, 2019 16:37
-
-
Save dakoctba/66484f3426e5eb140996b5fd788dd339 to your computer and use it in GitHub Desktop.
Cypress and localStorage
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment