I am learning Cypress and automating API tests. I have a JSON file in the fixtures folder and I want to pass this JSON file as a request body.
{
"name": "Harry",
"email": "hello@cypress.io",
"mobile": "1234"
}
so if I want to change the mobile value to something else then I can do like
cy.fixture('request.json').then((requestBody) => {
requestBody.mobile = '5678'
cy.request({
url: requestUrl,
method: 'POST',
body: requestBody
})
})
If I want to delete the mobile value and just want to pass name and email from request.json then can I do this from the same file or I have to create a separate file. Is it possible in cypress?
requestBody.mobile.delete() //something like this