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)
}
However, when I do this in my it function it gives me a blank or undefined
it('test', function () {
..........
cy.log(func())
}
}
Can anyone help here?
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
}