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

184
Vistas
Does loading multiple json files in single test suit is a good practice in cypress?

Does loading multiple json files in single test suit is a good practice in cypress? Something like this:

before(() => {
    cy.fixture('productCatalogData').then((datajson) => {
      recipeData = datajson.recipes;
      return recipeData;
    });
    cy.fixture('loginData').then((datajson) => {
      loginData = datajson;
      return loginData;
    });
  });
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you need both the json files in one suite, I don't think there should be a problem using fixtures multiple times. However you can shorten the cy.fixture() code a bit like this:

before(() => {
  cy.fixture('productCatalogData').as('productCatalogData')
  cy.fixture('loginData').as('loginData')
})

it('Access fixtures data', function () {
  // The test has to use "function" callback to make sure "this" points at the Mocha context
  //Access fixtures data using this.productCatalogData and this.loginData
})

But one thing to add here, cypress removes aliases after every tests. So if you have just one test inside the suite then before() will work fine, but if you have multiple tests you have to use beforeEach().

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