Is there any support for looser matching of the ex...
# pact-js
m
Is there any support for looser matching of the expected HTTP request in consumer tests? Our use case is that some of our requests to the provider require authentication tokens in the headers, which we would need to get from
fromProviderState
. However, our frontend (consumer) code does not handle authentication tokens in production - we have a separate library that attaches auth tokens to requests, so when we make the requests in our pact consumer tests that we would make in production, the tests fail because there is no auth token in the request headers. Is it possible to setup
withRequest
to ignore the missing header params as long as certain other request params match? Or is there another possible workaround?
y
You can use request filters on the provider side, so you don’t need to add anything into your consumer request, simply set an agreed provider state https://github.com/pact-foundation/pact-js/blob/master/docs/provider.md#modify-requests-prior-to-verification-request-filters
👀 1