Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!