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

165
Vistas
Cypress and Javascript: Logging function gives a blank

I have a function that is looping through arrays and giving me numbers as the output. It is working correctly because the cy.get(values) gives what I want. However, when I try to call cy.log(<func>) I get a blank (undefined). I'm not sure what's going on.

const func = () => {
        const nums = numArray.get() 
        let new = []
        for (let i = 0; i <= 2; i++) {
            const arr = nums[i].temps
            arr.forEach((element) => {
                new.push(element.aggregate)
            })
        }
     cy.get(new) 
}

enter image description here

However, when I do this in my it function it gives me a blank or undefined

it('test', function () {
    ..........
    cy.log(func())
  }
}

enter image description here

Can anyone help here?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You aren't returning anything in your function, so there is nothing for the cy.log() to display. Try returning the values.

const func = () => {
        const nums = numArray.get() 
        let new = []
        for (let i = 0; i <= 2; i++) {
            const arr = nums[i].temps
            arr.forEach((element) => {
                new.push(element.aggregate)
            })
        }
        return new
}
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