Test Pact provider for json structure only

1k views Asked by At

Looking at Pact for some contract testing, our Real api's have timestamps in the response, so I was looking to validate against the json schema only.

In the example here - https://github.com/DiUS/pact-workshop-jvm#step-4---verify-pact-against-provider

the test fails if the response body contains a different value than what's expected, the same will always happen for my tests because of timestamps, when we test against the provider.

How do I tell Pact to only validate against the json structure only and ignore the content?

1

There are 1 answers

2
Matthew Fellows On BEST ANSWER

You want to use a matcher. A matcher is a way of saying "I want the response to be of this shape, but I don't care about the specific value".

If you're needing them for the request values, consider generators. See these articles for an example: