I have a response in below format.
[
{
"Name": "PQR",
"Code": "000XXY",
"Text": "ssdd1",
"Charg1": {
"step": 1,
"Months": 3,
"endDate": "2099-09-01T00:00:00",
"percent": 10
},
"Fees1": false
},
{
"Name": "ABC",
"Code": "000XXY",
"Text": "assd2 ",
"Charg2": {
"step": 2,
"Months": 3,
"endDate": "2099-09-01T00:00:00",
"percent": 10
},
"Fees2": false
},
]
I have tried below test scripts to validate the objects using below functions
var jsonData = JSON.parse(responseBody);
console.log(jsonData.length);
pm.test("Body matches string from response body",function()
{
for (i=0; i<jsonData.length;i++)
{
pm.expect(jsonData[i].text).to.include("Name");
}
});
Getting Below error message
Body matches string from response body | AssertionError: object tested must be an array, a map, an object, a set, a string, or a weakset, but undefined given