Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

232
Views
cy.saveLocalStorage no es una función Debido a que este error ocurrió después de cada enlace, nos saltamos las pruebas restantes en la suite actual:

1

tipo. Estoy muy fresca en Cypress. Me gustaría obtener su ayuda/consejo: 1. Para iniciar sesión, utilicé la forma mencionada a continuación, pero aparece el error: "cy.saveLocalStorage no es una función. Debido a que este error ocurrió durante un después de cada gancho, nos saltamos las pruebas restantes en el actual suite: Funcionalidad de inicio de sesión"

Y no sé dónde guardar mis credenciales. Soporte->Command.js

 let LOCAL_STORAGE_MEMORY = {}; 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]) }) }) Cypress.Commands.add('visitMultipleURL', url => { cy.window().then(win => { return win.open(url, '_self') }) })
 import 'cypress-iframe'; In login.spec.js describe('LoginFunctionality', function () { beforeEach(() =>{ cy.restoreLocalStorage(); Cypress.Cookies.defaults({ preserve: /[\s\S]*/, }) })// afterEach(() =>{ cy.saveLocalStorage(); }) let href; it.only('LoginFunctionality', function () { //cy.visit(Cypress.env('url')) cy.visit('xxx') cy.get('.chakra-stack > .css-1n94901').click() cy.contains('Login with xxxx').click() cy.url().then((url) => { href = url; cy.log('href ', href); }) }) it.only('LoginFunctionality', function () { cy.visit(href) cy.url().should('include','xxxxx[![enter image description here][1]][1]')//assertion of that we are in this url }) })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

A mi me paso algo parecido antes.

Le sugiero que lo depure probando el código directamente en su prueba primero para verificar qué está sucediendo.

Además, inicie sesión en la consola en LOCAL_STORAGE_MEMORY y vea si tiene acceso a su valor porque cypress no maneja las variables de la forma en que lo esperaríamos si fuera javascript puro (incluso cuando parezca que está tomando el valor)

probar

 let LOCAL_STORAGE_MEMORY = {anyAttribute: "VALUE"};

Para ver si obtiene ese atributo desde dentro del comando

Por lo general, eso es con lo que estaba relacionado mi problema.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!