Transcripted Summary

Let's talk about contract test flow and CI/CD integrations.

To implement contract tests, you must first have a mature team and a flow that encourages constant collaboration within the team.


This cycle begins with the consumer team initiating a discussion about the requirements for a contract with the provider team.


Once both teams have agreed on the API contract, the consumer team can begin creating the tests, manifest interactions and expectations. The result of running these tests will become the contract. These contracts will need to be published to your Pact broker or equivalent.

Now the provider team can implement the API contracts for its consumer. The CI pipeline of the provider downloads the contracts of all of its consumers and runs the tests to confirm that no regressions have occurred.


You can integrate Pact contracts into your pipeline and set up web hooks to your Pact broker. Usage scenarios might include when the contents of a contract has changed, when a contract is published or when the provider verification is published.

Let’s take a closer look at the workflow in the following diagram:

The consumer job will run unit tests, Pact tests, and publish contracts. This triggers the consumer Pact check which ultimately decides whether or not to deploy.

On the provider side, Pact verification tests are run after unit tests are run. Verification results are then published. If you have a webhook configured to trigger when the contract content has changed, then only the changed Pact will be verified and these results will be published back to the broker. This Pact verification job configuration will be different from one configured as part of the main provider pipeline. The changed Pact should accept a URL as a configurable parameter.

If the Pact content has not changed and the provider verification is unchanged, we can simply skip to the final results.


If you wish to use Docker to run contract tests with Pact (for example, running CI builds within a Docker container) you can download the official Docker image from the Pact foundation.

Docker can also be used as your Pact broker. It will take a bit of time to set up but if you are mindful of budget constraints and not in a hurry this could be a good option.

Additional Content

The Pact documentation is very complete and community support is great. You can find resources on Github, Slack, Stack Overflow and Twitter as well as their own website.

If you wish to check out other examples, I posted an article about PactJs with GraphQL on my personal blog for you to check out.

Here are my contacts. Feel free to drop me a message if you have any feedback or questions. Thank you and I hope you enjoyed this course~


© 2024 Applitools. All rights reserved. Terms and Conditions Privacy Policy GDPR