Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

388
Vistas
unable to invoke Cypress custom commands in test files

I am working on managing the session cookie for each test case by setting it in beforeEach() and afterEach() block.

Using the below custom session command in C:\cypress\support\commands.js

 Cypress.Commands.add('saveSessionStorage', () => {
  Object.keys(localStorage).forEach(key => {
    LOCAL_STORAGE_MEMORY[key] = localStorage[key];
  });
});

Cypress.Commands.add('restoreSessionStorage', () => {
  Object.keys(LOCAL_STORAGE_MEMORY).forEach(key => {
    localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]);
  });
});

And imported in cypress/Support/Index.js

import './commands'

In test.js file used custom commands as below

    beforeEach(() => {
        cy.restoreSessionStorage()

  });
  
  afterEach(() => {
    cy.saveSessionStorage()
  });

But I am getting the below error while implementing the custom commands such has cy.restoreSessionStorage() & cy.saveSessionStorage() in test.js file as below

Property 'restoreSessionStorage' does not exist on type 'cy & EventEmitter'.ts(2339)

and

Property 'saveSessionStorage' does not exist on type 'cy & EventEmitter'.ts(2339)

What could be the problem? Please help

Project Structure: enter image description here

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda