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!!