Cypress. How intercept requests by request body #20014
Answered
by
TheColorRed
sadikovandrew
asked this question in
Questions and Help
-
Beta Was this translation helpful? Give feedback.
Answered by
TheColorRed
Feb 3, 2022
Replies: 1 comment 1 reply
-
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
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
sadikovandrew
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: