Hi Pact Team, i am using pact framework and facing...
# general
g
Hi Pact Team, i am using pact framework and facing a scenario where the response body of the api changes. How can I handle this ? I am using java
t
Have a look at the documentation on provider states
g
Thank you are you talking about this link https://docs.pact.io/?
t
Yes
m
perhaps you could elaborate a bit more on your use case, as it is currently not clear the scenario you are trying to solve for
g
Hi @Matt (pactflow.io / pact-js / pact-go) I am working on pact contract test framework ,where we are doing comparison based verification of the api response we received and what was expected. The expected/correct response body is stored in a metadata. So for all API's which we need to perform pact testing on, it is needed that we have a maintain a database, where we store api details and the response body. Now in some scenarios ,some api's response change in runtime so always it will differ from the response stored in the database, and error like : 0 - $ -> [{mismatch=Expected a Map with at least 6 elements but received 2 elements, diff={ - "children": [ - { - "code": "100", - "id": "100", - "title": "DimOneTest" - }, - { - "code": "102", - "id": "102", - "title": "Test SCD Action1" - }.............
I need to know how can i handle this kind of scenarios
m
It looks like you are expecting exact values, which is why your tests are failing when different data comes back. Pact has the concept of matchers which resolves this issue. In Java, you can see them here: https://docs.pact.io/implementation_guides/jvm/consumer I would read this section of our docs: https://docs.pact.io/consumer, specifically this section: https://docs.pact.io/consumer#choose-the-right-type-of-matching-for-the-situation
g
Ok Matt tysm i will try this approach
👍 1
m
Worth doing the workshops too if you’re new to Pact (howtolearn)
s
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops
g
from where can i participate? is it on youtube?
t
It’s on the link that Matt posted above
g
ok tysm