Im working with a JSON response that has nested elements and I want to validate it against JSON test data using Postman and test functions.
Currently, I am able to do this by hardcoding the validation:
const jsonData = pm.response.json();
pm.expect(jsonData.items[0].title).to.eql(pm.iterationData.get("title"));
pm.expect(jsonData.items[1].title).to.eql(pm.iterationData.get("title"));
Here is an example of my JSON test data file:
[
{
"title": "Title1"
},
{
"title": "Title2"
}
]
My question is, how can I validate it in a different way while still using the JSON test data structure? For instance, if I have around 100 titles to verify in the JSON test data, I don't want to manually write out 100 lines...
Thank you in advance!