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

124
Visualizações
Is there a way to share fixtures while using cy.fixture in class between methods

I am doing my first steps in Cypress and issue which I meet is that I replicate the code so I wish to make it better. I've tried to use cy.fixture in a constructor but it failed, so I am looking for a way to use cy.fixture only once in class and assign result to this which can be used in other methods.

class LoginPage{

navigate(){
    cy.fixture('urls.json').then((url) => {
        cy.visit(url.baseUrl);
    })
}

checkIfRedirected(){
    cy.reload()
    cy.fixture('urls.json').then((url) => {
        cy.url().should('equal', url.claimUrl)
    })
}

}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It is possible to import the fixture at the top of the LoginPage

import url from './cypress/fixture/urls.json'

class LoginPage {

  navigate() {
    cy.visit(url.baseUrl);
  }

  checkIfRedirected(){
    cy.reload()
    cy.url().should('equal', url.claimUrl)
  }
}
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