Cannot read property '_setRequestBody' of undefined
See original GitHub issueCurrent behavior:
Whenever visiting a page in which the XHR id is protected via Object.defineProperties
, cypress throws the following error:
Cannot read property '_setRequestBody' of undefined
The issue here is that the following code in packages/driver/src/cypress/server.js
is trying to override the XHR id with a unique id
add (xhr, attrs = {}) {
const id = _.uniqueId('xhr')
_.extend(xhr, attrs)
xhr.id = id
xhrs[id] = xhr
proxies[id] = $XHR.create(xhr)
return proxies[id]
}
But since the id
property is immutable in my environment and is referencing the value of another property, like so
Object.defineProperties(XMLHttpRequest.prototype, {
"id": {
get: function() {
return XMLHttpRequest.prototype._id
}
}
})
The result is that the code is not being able to locate the proxy for the request, returning undefined
instead, thus, causing the error
proxy._setRequestBody(requestBody)
Desired behavior:
I would expect to be able to parameterise the property I want to be considered as an ID, in a way that I would be able to tell cypress to override the property _id
instead of id
.
Test code to reproduce
Reproduction is available here https://github.com/fltonii/cypress-test-tiny
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (5 by maintainers)
Top GitHub Comments
Hi All, I am experiencing the same issue. The UI library by SAP (Fiori Launchpad based on SAPUI5) is overwriting the XHR Id, which unfortunatly makes it impossible to use cypress for end-to-end UI tests for SAP software. Is there any option to switch to a different attribute name?
See the following code-snipped of the Fiori Launchpad library (as Fiori Launchpad itself is under commercial license i can unfortunatly not provide a running example - but the issue should be pretty clear from the screenshot).
Regards, Timo
This code has been there for quite a while, so I don’t think this was a recently introduced thing.
I can recreate this with the following code: