When I try to get data form a Json file, this message shown.
The question: Can I get text from a Json file?

I Need to insert this data (that the Json file have) in the text area
Test
beforeEach(() => {
cy.server()
cy.fixture("licencia.json").then((data) => {
cy.route('GET', 'licencia.json', data)
})
it.only('POST - Add License', function () {
cy.get('[id=operations-License-Post]').children('div').click()
.get('button').contains('Try it out').click()
cy.get('textarea').clear()
.get('textarea').type(this.data)
* Json Example/format*
{
"nombres": "Pulga",
"apellido": "Rodriguez",
"tipoDocumento": "NOT_DEFINED",
"fechaNacimiento": "1986-08-10T17:40:08.484Z",
"nroLicencia": "32001001",
"cuil": "20320010013",
"domicilio": "25 de mayo 1350",
"nacionalidad": "Argentino",
"sexo": "Masculino",
"grupoFactor": "0+",
"nroTramite": "251350",
"numeroInsumo": "string 1",
"fechaOtorgamiento": "2019-07-26T17:40:08.484Z",
"fechaRenovacion": "2019-07-26T17:40:08.484Z",
"fechaVencimiento": "2019-07-26T17:40:08.484Z",
"categoria": "A",
"clase": "1",
"restricciones": "ninguna",
"observaciones": "cinco",
"centroEmisor": "Las Talitas",
"donante": true,
"firmante": "Leito",
"estado": "Vigente"
}
win10
Chrome v75
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 this.data later on. You probably want
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)

I'm not sure if cy.type and json file is that I need to did this kind of enter text

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 cy.get('textarea').type(JSON.stringify(this.data)) is shown again

Finally!
Thanks for all the help @bahmutov
First solution was use the correct sintaxis like bahmutov explained and works great:
beforeEach(() => {
cy.server()
cy.fixture("licencia.json")
.as('data')
.then((data) => {
cy.route('GET', 'licencia.json', data)
})
})
Spec
cy.get('textarea').type(JSON.stringify(this.data))
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:
beforeEach(() => {
cy.server()
cy.fixture("licencia.txt")
.as('data')
.then((data) => {
cy.route('GET', 'licencia.txt', data)
})
})
Spec
cy.get('textarea').type(this.data)

There's my first suite in cypress. Thank you guys!