问题
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);
        })
回答1:
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
  })来源:https://stackoverflow.com/questions/57666827/convert-response-body-blob-to-json-or-plain-text-in-javascript