I have done similar, this is one part of the code and its works well
Check this code
var jsonData = JSON.parse(responseBody);
for(i=0; i environment.Cstartdate;
tests["response body has department name"] = jsonData.data[i].department.name !== null;
}