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

98
Views
Cypress: run entire test suite multiple times with different data

I have seen several posts about running a single test with different parameters. It is also documented here.

However, I couldn't find any examples of how to run the entire test suite, i.e. tests across multiple files in the cypress/integration folder multiple times with different data.

My scenario is that I want to stub different responses from an API I'm calling and run all test cases against the different responses. So for the 1st run, I would put in support/index.js:

beforeEach(() => {
  cy.intercept("GET", "example/API", { fixture: "fixture1.json" });
});

and for the 2nd run I would put:

beforeEach(() => {
  cy.intercept("GET", "example/API", { fixture: "fixture2.json" });
});

and so on. All my test cases are identical for different responses and I expect them to have the same result regardless of the data returned by the API.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Running a suite with different parameters

cypress run --env fixture=fixture1
// or
cypress run --env fixture=fixture2

Ref Environment Variables

In support/index.js

beforeEach(() => {
  const fixtureName = `${Cypress.env('fixture')}.json`
  cy.intercept("GET", "example/API", { fixture: fixtureName });
})

I expect them to have the same result regardless of the data returned by the API - I'm not sure what that means exactly but to me it suggests you don't have to worry about changing the fixture.


If you want a single call from the command line to run the whole suite, say 3 times with a different fixture each time, consider using the Cypress Module API

In a script file, e.g /scripts/run-fixtures.js

const fixtures = ['fixture1.json','fixture2.json','fixture3.json']  

const cypress = require('cypress')

fixtures.forEach((fixtureName) => {

  cypress.run({
    reporter: 'junit',
    browser: 'chrome',
    config: {
      baseUrl: 'http://localhost:8080',
      video: true,
    },
    env: {
      fixture: fixtureName,
    },
  })
})

Run it with node /scripts/run-fixtures.

support/index.js is the same as above.

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!