Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

312
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda