Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

106
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda