Skip to content

Cypress. How intercept requests by request body #20014

Discussion options

You must be logged in to vote

I am not sure if this is what you are looking for, but you can write a handler that will handle custom actions for the request. This is a function that is passed in as the second parameter:

cy.intercept({
  method: 'POST',
  /* Your other request parameters */    
}, handler);

function handler(req) {
  if(req.body.something_here) {
    // Do something
  }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sadikovandrew
Comment options

Answer selected by sadikovandrew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants