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

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

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