Skip to content

Latest commit

 

History

History
 
 

stubbing-spying__window-fetch

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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
})