在我的 cypress 测试中,我提交了一个请求,在响应中,主体返回为blob
。我怎样才能检查some text
体内的内容。有什么办法可以转换blob
into json or plain text
。请参阅随附的屏幕截图。添加下面的测试代码
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);
})
只需检查response.body。请参见下面的示例。
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
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)