How can I use Cypress to intercept and modify a value in a multipart/form-data request

14 views Asked by At

One of the network requests made by the browser has a payload like:

enter image description here

Before the request is sent I want to change the amount, but leave the rest of the payload unchanged.

I have tried the below 2 methods to achieve this just to see what happens, but as expected, neither worked:

cy.intercept('POST', '/*/payment', (req) => {      
  req.body.amount = "2100"
})

cy.intercept('POST', '/*/payment', {
  body:{
    amount: "2100",
  },      
})
0

There are 0 answers