I need to pass two parameters in my POST request that should be randomly generated title and description I tried using Cypress._.random(0, 1e6) but had no luck as it generated only a few numbers The requirement for the title field is: 5-20 alphanumeric characters The need for the description field is: 20-200 alphanumeric characters
it('should PAA', () => {
const uuid = () => Cypress._.random(0, 1e6)
const title = uuid()
const description = uuid()
cy.getLocalStorage("accessToken").should("exist");
cy.getLocalStorage("accessToken").then(token => {
cy.request({
method : 'POST',
url: 'myURL',
headers : {"Authorization": "Bearer " + token},
body: {
"extra_fields":{
"price":5000,
"price_type":"price"
},
"area":0,
"type":"general",
"user_external_id":"0926c075-6afb-4d66-ba17-8a01a6a93e70",
"purpose":"for-sale",
"state":"pending",
"source":"strat",
"contact_info":{
"name":"Muhammad Haris BH",
"mobile":"+923234077603",
"roles":[
"allow_chat_communication",
"show_phone_number"
]
},
"title": title,
"description":description,
"photos":[
],
"location_id":"2-51",
"category_id":"249"
}
}).then( (response) =>{
expect(`Response.status = ${response.status}`).to.eq('Response.status = 201')
})
});
});
I'm passing the title and description in the body but UUID only generates a few numeric characters I need to pass an alphanumeric string with at least 20 characters.