Skip to content

bahmutov/cy-intercept-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cy-intercept-example

Cypress v6 network examples using cy.intercept

npm install
npx cypress open

See more information at:

Watch the video of the introduction at https://youtu.be/_wfKbYQlP_Y

See cypress/integration/spec.js, here is a fragment that stubs Ajax call to external domain to fetch three users:

// https://on.cypress.io/intercept
cy.intercept({
  pathname: '/users',
  query: {
    _limit: '3'
  }
}, {
    fixture: 'users.json',
    headers: {
      'Access-Control-Allow-Origin': '*'
    }
}).as('users')

cy.get('#load-users').click()
cy.wait('@users')