Tengo tal problema que Cypress no puede encontrar las propiedades. En respuesta obtengo array. Quiero encontrar el registro y obtener CustomMessage. :) ¿Te das cuenta de dónde estoy cometiendo un error: /? 
Aquí está mi código :)
cy.request({ method: 'GET', url: 'url', }) .then((resp) => resp.body) .then((data) => data.find((element) => element['body']['Message']['Phone'] == phone) ) .then((phone) => (otpCode = phone['body']['Message']['CustomMessage']))Gracias por cualquier ayuda :)
El problema es que nada en la matriz coincide con el phone
Intenta agregar un guardia
cy.request(...) .then((resp) => resp.body) .then((data) => { const found = data.find((element) => element.body.Message.Phone === phone) if (!found) throw 'Error: phone not found' return found }) .then((phone) => { otpCode = phone.body.Message.CustomMessage }) La forma en que lo tiene originalmente, cuando data.find() falla, toda la matriz se pasa a la extracción de otpCode .
Puede obtener el mensaje personalizado de esta manera:
cy.request({ method: 'GET', url: 'url', }).then((resp) => { const customMessage = resp.body[1].body.Message.customMessage })Hágalo simple con cy-spok .
const 'spok' = require('cy-spok') cy.request({ method: 'GET', url: 'url', }) // access properties with .its() .its('response.body') .its(1) .should(spok({ Message: { Phone: spok.string // or us spok.test to check string length as well } // now we verified the response has Message.Phone let's extract it .its('Message.Phone') .as('otpCode')