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

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