Bridge between Pact and Postman

| 1 min read

pact

If you are commonly using Pact for contract-testing between your backend apps and your front-end apps, there is a little tool that might save you a lot of time.

Contract testing, in general, is a good way of understanding the impact that back-end API changes may have on clients consuming them, before that the issues actually occur.

Pact has an application in their toolkit called a "Pact Broker", on which you can send "Pact files" (JSON files), that contain the interactions that describe the requests made by a consumer.

These Pact files can be very lengthy, depending on the back-end usage, holding hundreds of request interactions.

There is a tool called pmpact that can generate Postman collections from a Pact file.

Postman is a tool to work with requests and APIs. It can store, import and export collections, which are lists of requests ready to be executed.

npm install -g pmpact
pmpact http://my-pact-broker/latest -o postman-collection.json

Once the collection is generated, it just needs to be imported in Postman and all the requests contained in the Pact file will be ready to be executed.

It is also very easy to create Postman environment variables, for example, to switch between a QA host and a production host.

More detail about the Postman usage in the pmpact doc.