Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. ```javascript
  2. // Colar esses comandos no arquivo cypress/support/index.js
  3. Cypress.Commands.add('saveLocalStorage', () => {
  4. Object.keys(localStorage).forEach(key => {
  5. LOCAL_STORAGE_MEMORY[key] = localStorage[key];
  6. });
  7. });
  8.  
  9. Cypress.Commands.add('restoreLocalStorage', () => {
  10. Object.keys(LOCAL_STORAGE_MEMORY).forEach(key => {
  11. localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]);
  12. });
  13. });
  14.  
  15. // quando você deseja persistir o localStorage
  16. cy.saveLocalStorage();
  17.  
  18. // Dentro de cada 'describe'
  19. beforeEach(() => {
  20. cy.restoreLocalStorage();
  21. });
  22. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement