This repository contains a sample project demonstrating Consumer-Driven Contract Testing using Pact. It includes two services:
product-web-app
: A frontend application (the Consumer).product-api
: A backend API (the Provider).
This project uses a Pact Broker to manage contracts and verification results.
- Consumer CI (
.github/workflows/consumer-ci.yml
): When changes are pushed toproduct-web-app
, this workflow runs the consumer tests and publishes the resulting contract to the Pact Broker. - Provider CI (
.github/workflows/provider-ci.yml
): When changes are pushed toproduct-api
, this workflow fetches the latest contracts for this provider from the Pact Broker, runs the verification tests, and publishes the results.
- Node.js (v20+)
- Docker
docker run --rm -p 9292:9292 -e PACT_BROKER_DATABASE_ADAPTER=sqlite pactfoundation/pact-broker
The broker will be available at http://localhost:9292.
cd product-web-app
npm test
npm run pact:publish
//launch the broker http://localhost:9292.
//check the status of the consumer it is present or not
cd product-api
npm test
//launch the broker http://localhost:9292.
//check the status of the provider it is present or not
The source of truth for all contracts and verification results. [Link to your Pact Broker here]