Can anyone tell me how to write a test that will count how many objects I have nested in JSON in the response.
I don’t know the number, so “to.equal” is out of the question.
I would like Postman to return a number in the console.
I searched the forum, none of the answers worked.
You have an object called data, with an array of objects called ib_clients.
I assume you mean the number of objects in that array which you can use the array.length() method.
const response = pm.response.json();
This will return the number in the console logs, but I can’t see how you can craft an appropriate test for this unless you know what the expected number will be.
This works perfect
var body = JSON.parse(responseBody);
tests["Array length is " + body.data.ib_clients.length] = true;
Thanks for Your support
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.