Hello. We have two teams, one working on the cons...
# general
n
Hello. We have two teams, one working on the consumer another on the provider. The provider team is finished with the provider and would like to verify the Pact, however the consumer is not yet in a state where the Pact test can be run to generate the Pact -- the consumer API is not generating the request. What is the best way to generate the Pact? (The only way I can think of is to mock the consumer request) Thank you
👋 1
y
You could replace the consumer request and make one directly (but this gives very limited confidence in your client code), however I am not sure what you are trying to achieve in terms of confidence. Are you looking to validate your provider meets its defined specification (not the consumers Pact contract). Or are you looking to test out the Provider verification pipeline? How incomplete is your consumer code? Do you have at least the API client part of it, that will call the provider service (which would be mocked in the consumer Pact test)
👌 1
Personally I would invest the initial effort in attempting to get the Pact contract generated in the correct manner in your unit testing code, rather than working on anything else superfluous, but that depends on. your aims 🙂
n
I am indeed trying to verify the provider meets the specification -- when the consumer is ready it will meed the same specification. I was trying to see if there was some manner in which I could generate a Pact without having to mock the consumer request -- but my suspicion was that there wasn't one. I agree with your suggestion to invest time to complete the consumer API, rather than mock the consumer, I'll forward it down to the consumer team.
y
Hey man, so here is a way you could generate a pact from a client, that is just a library for making requests. Here I use super test as the client. I should make not of this in my docs that this would be replaced by your client code under test https://github.com/YOU54F/template-jest-pact-typescript/blob/master/src/pact/client/json.pacttest.ts
n
Thank you. We are using Java, but I understand the approach. I am going to present it to the consumer team so they can decide whether to create a pact based on a mock request, or just build the client API.