TypeError: Cannot read properties of undefined (reading āhaveā)
Not sure which assertion I should be using. I guess all I really want to check if that is null or not. I know that ID must exist or the find query wouldnāt work.
I donāt think Iāve written or explained the test very well.
What I actually wanted to do is ensure that the value āSampleCollectionā was in the results for id.
There are multiple collections in the response. What you have will pass, but its not confirming that SampleCollection exists. (Cosmos DB collection, not to be confused with Postman collections).
Iāve only just started using Postman, and Iām used to jsonpath and xpath assertions in tools like SoapUI. I know a bit about Javascript but havenāt used it in anger. So just learning how to dig into the responses, attributes, etc at the moment.
Iāve done this in a slightly better way since. Which is to get all IDās, and then check what Iām looking for is in the response.
// another way of getting alls the ID's.
var mapTest1 = response.DocumentCollections.map(function(item){return item.id;});
// and another
var mapTest2 = response.DocumentCollections.map(({ id }) => id);
Thanks for that, I think I get it.
Itās an interesting approach and looks like a good alternative to some of the things I have done in previous tests!!