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

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

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