Skip to content

arun-kumar-infostretch/pact-testing-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pact Contract Testing Tutorial

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).

Pact Workflow

This project uses a Pact Broker to manage contracts and verification results.

  • Consumer CI (.github/workflows/consumer-ci.yml): When changes are pushed to product-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 to product-api, this workflow fetches the latest contracts for this provider from the Pact Broker, runs the verification tests, and publishes the results.

Running Locally

Prerequisites

  • Node.js (v20+)
  • Docker

1. Start the Pact Broker

docker run --rm -p 9292:9292 -e PACT_BROKER_DATABASE_ADAPTER=sqlite pactfoundation/pact-broker

The broker will be available at http://localhost:9292.

2. Run the Consumer Tests

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

3. Run the Provider Tests

cd product-api
npm test

//launch the broker http://localhost:9292.

//check the status of the provider it is present or not

Pact Broker

The source of truth for all contracts and verification results. [Link to your Pact Broker here]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published