Good afternoon, I have just started using Pact and...
# pact-python
d
Good afternoon, I have just started using Pact and have a problem, our API response returns an array of objects which can have child objects , if the parent object has children they are in an array , if the parent has no children the array is empty. From looking at the Docs, the EachLike matcher dictates the array has at least one child object , so that is not useable in my case. Is there any other way to have a matcher for this situation. This is a bit of a deal breaker for us and I'm not sure why you cannot have a situation for, if array contains objects then objects should have this shape , else object is empty ? Something like Either {} or [{...}, {...} , ...]
👋 1
m
you need to use provider states to have two different scenarios: one where the array is empty, and another where it has objects in it
(see also https://github.com/pact-foundation/pact-support/pull/11 where @Beth (pactflow.io/Pact Broker/pact-ruby) schooled my on my first Ruby PR to the project 😆 )