In my cypress test, I have submitted a request and in the response the body returned as blob
. How can I check the some text
content in body. Is there any way convert the blob
into json or plain text
. Please see the screenshot attached. Adding the test code below
cy.request('https://someurlHere).then((response) => {
expect(response.status).to.eq(200) // this is loooking good
expect(response).to.have.property('headers') // this is loooking good
console.log(response.text());
//var alertArr = [];
//alertArr = response.json();
//console.log(alertArr);
})
Just check for response.body. See below example.
cy .request('POST', 'http://localhost:8888/users/admin', { name: 'Jane' }) .then((response) => { // response.body is automatically serialized into JSON expect(response.body).to.have.property('name', 'Jane') // true })
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.