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

120
Vistas
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 Respuestas
Responde la pregunta

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 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