-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cy.type() can only accept a string or number. You passed in: 'undefined' #4866
Comments
Please read the https://docs.cypress.io/api/commands/fixture.html#Using-an-alias-to-access-a-fixture and the examples linked there. You are never saving the loaded fixture, so there is no beforeEach(() => {
cy.server()
cy.fixture("licencia.json")
.as('data')
.then((data) => {
cy.route('GET', 'licencia.json', data)
})
}) Or even shorter https://docs.cypress.io/api/commands/fixture.html#Shortcuts beforeEach(() => {
cy.fixture("licencia.json").as('data')
cy.server()
cy.route('licencia.json', 'fixture:licencia')
}) |
@bahmutov Thanks for the comment! I made this corrections but still have the other issue that I found in the other tries (a lot of tries) |
so the JSON from the fixture is automatically parsed and converted into an object, right? You probably want to type it as text. This should do the trick cy.get('textarea').type(JSON.stringify(this.data)) |
@bahmutov this is another of the issues that I saw. using |
see #4287 |
Finally! First solution was use the correct sintaxis like bahmutov explained and works great:
BUT the second one, is related with this (my) particular case: I need a TXT file instead Json. The .txt don't need any particular syntax, so I can put the script with no issues related with specials characters. For the .txt:
There's my first suite in cypress. Thank you guys! |
Current behavior:
When I try to get data form a Json file, this message shown.
The question: Can I get text from a Json file?
Desired behavior:
I Need to insert this data (that the Json file have) in the text area
Steps to reproduce: (app code and test code)
Test
** Json Example/format**
The text was updated successfully, but these errors were encountered: