Day 02: Collections and environments_got AssertionError

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.

request link

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

Hey @mission-saganist-721 :wave:

Welcome to the Postman Community! :postman:

I’m kinda not sure what you have done here - none of those Collections have been forked into your Workspace, from the original 30 Days Workspace.

None of your Collections/Folders have documentation and the test code has been removed. :thinking:

My suggestion would be to delete those Collections that you have in that Workspace, head back to the 30 days of Postman Workspace, fork them and start it all again.

https://www.postman.com/postman/workspace/30-days-of-postman-for-developers

Hi Danny,

Thank you for the reply and suggestion.
I didn’t know how to fork the collections into my Workspace then, but now I got it and solved the problem. The test results look ok as well.
Thank you for being so helpful!

1 Like