Hi,
I’m struggling with passing the test. I checked the collections ID, collections name, and request names, but I still got a failed test result. When I checked the test results, it showed an AssertionError. There are two elements in the Item array of the Body, but I don’t know how to fix this. Please kindly see the details as follows.
Test
pm.test(“Item array is present and contains expected number of elements”,
function () {
const responseData = pm.response.json();
pm.expect(responseData).to.have.property('collection');
pm.expect(responseData.collection).to.have.property('item').that.is.an('array');
pm.expect(responseData.collection.item).to.have.lengthOf(1);
});
Failed Test Result
Item array is present and contains expected number of elements |
AssertionError: expected [ { …(4) }, { …(4) } ] to have a length of 1 but got 2