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

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

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