'Cypress 9.6.0 - response returned from cy.request has a body as ArrayBuffer
I'd like to access response body of request sent via cy.request inside custom command, but response's body turns out to be ArrayBuffer for some weird reason, but rest of the response is just fine. Here is code example:
Cypress.Commands.add('requestWrapped', ({ method, path, body }) => {
const token = window.sessionStorage.getItem('x-csrf')
cy.request({
method,
url: `${Cypress.env('backendUrl')}/${path}`,
body,
headers: {
'X-CSRF-Token': token,
'Access-Control-Allow-Credentials': true,
'content-type': 'application/json; charset=utf-8',
},
}).then((res) => {
console.log(res.body) // ArrayBuffer here
})
})
And it's being called inside it block
cy.requestWrapped({
method: 'POST',
path: 'some/random/path',
body: {
name: xyz,
id: 123-123,
},
})
I also tried to use cy.request standalone inside the test, without any wrapper around - got same result
Any ideas what might went wrong there? Thanks in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
