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

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

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