Apologies if this is an old question, but I can't ...
# pact-js
a
Apologies if this is an old question, but I can't seem to find a pact (v2/v3) matcher that would check if an object-valued non-array response field (in e.g. REST/JSON) was one of a list of possible expectation shapes. This kind of thing arises quite frequently in e.g. GraphQL schema union types (where a field could be e.g. a Person or a Team), and the possible values are quite different.
t
You would cover these in separate tests
A pact test is not about describing the possible responses, it’s about ensuring that your response types are covered.
For example, if you could say “it might be a person or a team”, you could pass your tests without ever checking that the provider and consumer agree about what a Team should look like
Think of the matchers as saying “this test covers all cases that pass this matcher”, not “this is the response schema”
a
Thanks @Timothy Jones I see your point; it's a particular setup where provider responses are generated from GraphQL schema-driven mocks, but I can see I'm going to have to use provider state in some fashion to direct the mocking behaviour.