What I am trying: Pass multiple arguments in cy.task()
command and print those argument values declared in function mentioned in plugins/index.js
file
Issue: The function print prints only the first argument value and undefined for a second argument
Code:
//test file with cy.task() command
class LoginPage {
let site = abc
let userDetails = xyz
openPage(env, site, userDetails) {
cy.task('loadUserAccountDetails', site, userDetails)
}
}
module.exports = LoginPage
// plugins/index.js file where the event is registered with declared function
const validUserDetails = (site, userDetails) => {
console.log('--->' + site) // This prints abc
console.log('--->' + userDetails) // This prints undefined
}
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
on('task', {
loadUserAccountDetails: validUserDetails
})
}
Kindly help.