Skip to content

implement window.fetch capturing/mocking #95

@terinjokes

Description

@terinjokes

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions