Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda