I am getting below error in cypress for the below test. I am not familiar with JS and Cypress.Is there any mistake in the code?
*The following error originated from your test code, not from Cypress.
testRegistration.forEach is not a function*
export const testRegistration = ({firstName, lastName, email, password, confirmPassword}) ={
cy.get('input[name="firstName"]').type(firstName)
cy.get('input[name="lastName"]').type(lastName)
cy.get('input[name="email"]').type(email)
cy.get('input[name="password"]').type(password)
cy.get('input[name="confirmPassword"]').type(confirmPassword)
return cy.contains('button', 'Register').click()
}
I am trying to shorten the above code with foreach ,
export const testRegistration = ({firstName, lastName, email, password, confirmPassword}) => {
return cy.contains('button', 'Register').click()
}
testRegistration.forEach(function (argument, index) {
cy.get(`input[name= "${argument}"]`).type(argument);
});