Many developers are migrating to window.fetch from XHRs due to the simplified async interface it exposes. I happen to be one of those developers.
Cypress should support window.fetch with similar abilities to those of XHRs: I should be able to query the request and response, wait on them, and mock with data and fixtures.
Cypress team edit
This feature will work seamlessly once Full network stubbing is implemented.
Workarounds
- use experimental fetch polyfill available in v4.9.0
or do it yourself:
- delete
window.fetch before visiting the page to force your application to polyfill it on top of XHR. If the application does not include a polyfill, you can load one from your tests.
- stub
window.fetch directly in JavaScript
See these solutions in Stubbing window.fetch example recipe
Many developers are migrating to
window.fetchfrom XHRs due to the simplified async interface it exposes. I happen to be one of those developers.Cypress should support
window.fetchwith similar abilities to those of XHRs: I should be able to query the request and response, wait on them, and mock with data and fixtures.Cypress team edit
This feature will work seamlessly once Full network stubbing is implemented.
Workarounds
or do it yourself:
window.fetchbefore visiting the page to force your application to polyfill it on top of XHR. If the application does not include a polyfill, you can load one from your tests.window.fetchdirectly in JavaScriptSee these solutions in Stubbing
window.fetchexample recipe