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

85
Views
I Need to use variables in Cypress Cucumber Tests [still open]

I need to work on some variables in my project its necessary. And as you know it is very difficult in cypress because of cypress's own promise-like chain system. Because of that, some variables can come "unidentified" so tests will not pass.

Before starting edit: we are using cucumber but we are not giving para-metered step definitions because tests are dynamic and they will run on CI. .then() is not working because there are so many test steps that are using variables. also, I tried "background" keyword on cucumber and that didn't work.

This is the standard problem, I need a solution how can I force some tests to wait for variables to be filled and ready to read.

I think maybe event listeners can be work but I am not sure, really I don't have any idea about that situation.

Anyone can help me with that problem? Or anyone has an idea how can I use event listener in cucumber test cases? Thank you so much about reading my difficult question.

            var tmr
            // set variables
            localStorage.setItem('work_order_id', 10060);
            localStorage.setItem('current_step', 0);
            var taskInProggress=false

            function run_next_test() {
            
                taskInProggress=true
                let currentStep=localStorage.getItem('current_step')*1;


                console.log("Running task ", currentStep);      
                switch (currentStep) {
                    case 0 : 
                        //runStep0().then(response=>{
                        taskInProggress=false
                        localStorage.setItem('current_step', currentStep+1);
                        //});
                    /*
                      test
                    */
                    break;
                    default: // for work empty
                        taskInProggress=false
                        localStorage.setItem('current_step', currentStep+1);
                        break
                }
            }

            function step_listener(){
                let currentStep=localStorage.getItem('current_step');
                console.log("listen...");
                if (taskInProggress)  {
                    console.log("Step ",currentStep," still in progress ...");
                    tmr = setTimeout(step_listener, 1000);  
                    return
                }



                if (currentStep<10){
                    currentStep++;
                    run_next_test(currentStep)
                    tmr = setTimeout(step_listener, 1000);  
                }else{
                    clearTimeout(tmr);
                    console.log("Test finished")
                }

            
            }

            step_listener();

about 4 years ago · Juan Pablo Isaza
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!