Skip to content

Files

41 lines (28 loc) · 1.64 KB

File metadata and controls

41 lines (28 loc) · 1.64 KB

Stubbing window.fetch

See individual spec files in cypress/integration folder.

Deleting fetch

Until issue #95 is implemented, if your application uses fetch protocol to make Ajax requests, Cypress cannot see or stub these network calls. To quickly check what requests the web application is making, open DevTools Network tab and check the "type" column. If the type shows xhr, Cypress can see it. If the type says fetch, Cypress cannot intercept it yet.

Ajax type

Tip: if the "type" column is not there, add it by right-clicking on any column and checking "Type" entry.

Add type column to Network tab

Delete in cy.visit

You can delete window.fetch when calling cy.visit, which in most libraries drops back to using XHR

cy.visit('/', {
  onBeforeLoad (win) {
    delete win.fetch
  },
})

Delete on every window load

You can register a callback to execute on each window:load

Cypress.on('window:before:load', (win) => {
  delete win.fetch
})