Skip to content
Advertisement

How do I run a beforeEach in Cypress?

I’m currently building a test, and it seems that after the second and third test, the beforeEach is not getting the information that I need and is telling me that I’m having the following issue:

JavaScript

My file is the following:

JavaScript

My issue starts after the Expand a Business test. I don’t know if I have to pass any other function under the beforeEach statement or if needs to be set up differently.

How should I use the beforeEach? This file was working before, but for some reason started to fail. Could you please advise?

Advertisement

Answer

The error message cy.type() can only accept a string or number. You passed in: undefined says the last part of the path is undefined, e.g this.data.fullName or this.info.userGoodCredit.company.

If this.data was undefined, you error would be cannot get property “fullName” of undefined, so your beforeEach() is probably ok.

It looks like there’s a typo in the property used in the test, or in the fixture object. Check with console.log(this.info.userGoodCredit) and console.log(this.data).

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement