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

108
Visualizações
Problem with a parametrized test with cypress.io

I want want to start a parametrized dynamic test with cypress.io. The parameters for this are in a file called params. In before the variable params get the parameters from the file, but the forEach loop loops over the intial value 1 and 2. Can anbody give me an hint to solve the problem?

describe('Suite', () => {

    let params=[1,2];

    before(() =>{

        cy.readFile('cypress\\fixtures\\params.txt').then( data=> {

            params = data;
            params= params.replace(/(\r\n)/gm, "\t");
            params = params.split('\t');
            cy.log(params);
          })
    })

    params.forEach( param  =>{

        it('Testing with '+param+':', ()=>{

            ...
        })

    });

})
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

How bout this: In fixtures params.json file:

[
  {
    "name": "Test 1",
    "something": "Some text"
  },
  {
    "name": "Test 2",
    "something": "Some other text"
  }
]

And in integration test.spec.js file:

const params = require('../fixtures/params.json');

params.forEach((test) => {
    it(test.name, () => {
        cy.log(test.something);
    });
});

And this is the result: enter image description here

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