I want to know how can I test if an object exists. For example, my API return these things :
"data": [
{
"id": 1,
"name": "Abu Dhabi",
"locale": "AE",
"rentWayCountryId": 242,
"stations": [
{
"id": 2,
"rentWayName": "ABU DHABI AIRPORT",
"rentWayStationId": "IAEAUH1",
"bindExtrasToStationToExtraCategory": []
}
]
},
I want to check that data.id exists.
I used the test options in postman and i did this :
var jsonData = JSON.parse(responseBody);
tests["Name value OK"] = jsonData.data.id === "1";
Could you tell me which condition should I use to verify only if the data exist?
Thank you very much !!