Use cy.intercept() to stub and intercept HTTP requests and responses.
Wait for a specific request to complete.
Name of the alias to wait for.
// Wait for the route aliased as 'getAccount' to respond
// without changing or stubbing its response
cy.intercept('https://api.example.com/accounts/*').as('getAccount')
cy.visit('/accounts/123')
cy.wait('@getAccount').then((interception) => {
// we can now access the low level request
// that contains the request body,
// response body, status, etc
})
Wait for list of requests to complete.
Generated using TypeDoc
Use
cy.intercept()to stub and intercept HTTP requests and responses.https://on.cypress.io/intercept
cy.intercept('https://localhost:7777/users', [{id: 1, name: 'Pat'}])
cy.intercept('https://localhost:7777/protected-endpoint', (req) => { req.headers['authorization'] = 'basic fooabc123' })
cy.intercept('https://localhost:7777/some-response', (req) => { req.reply(res => { res.body = 'some new body' }) })