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

311
Vistas
Getting 'cy.session is not a function' error in Cypress runner

I'm trying to follow this article here to add cy.session() to my login function. However when I do this and then run my test, I get the error cy.session is not a function

I've set "experimentalSessionSupport": true in my cypress.json config file (and confirmed that my test is seeing this value as true too). From my understanding, that should be all I need to do, but obviously I'm missing something.

I'm using Cypress version 9.4.1. I've tried creating a custom login command instead (exactly as in the article) but just get the same error when running it.

My test works perfectly without the cy.session() command.

login.js:

class LoginPage {    

  ...

  login(username, password) {
     cy.session([username, password], () => {
      cy.visit('/login');
      this.emailField.type(username);
      this.passwordField.type(password);
      this.loginButton.click();
     });
  }

}

export default new LoginPage();

cypress.json:

{
    ...
    "experimentalSessionSupport": true
}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I'm using Cypress version 9.4.1.

Welp, this wasn't actually true. I was still on a version that didn't support cy.session(). Silly mistake on my end. It's now all working fine since upgrading Cypress.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Is it a Typescript error - TypeError: cy.[custom command] is not a function?

If so, the type definition is probably not added yet due to experimental flavour.

Add same definition as you would use for a custom command to the top of the test.

This is taken from the latest release.

declare namespace Cypress {

  interface SessionOptions {
    validate?: () => false | void
  }

  interface Chainable<Subject = any> {
    session(
      id: string | object, 
      setup?: SessionOptions['validate'], 
      options?: SessionOptions
    ): Chainable<null>
  }

}
about 4 years ago · Juan Pablo Isaza Denunciar
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