yinchuandong / microservice-contract-testing

Contract testing for microservices via Pact including graphql and rest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Microservice Contract Testing

Quick Start

Start Pact Broker

docker-compose up

It will start a broker server and a postgres server. You shall be able to visit the broker via http://localhost:9292 but just see an example contract. Note you need to type the username and password which can be found in docker-compose.yml file.

pact-broker-auth

Install packages for providers

  1. user-service (http://localhost:4100/graphql)
cd user-service
yarn install
yarn start
  1. company-service (http://localhost:4101/graphql)
cd company-service
yarn install
yarn start

You shall be able to visit the graphql playground like below: user-service

Install packages for consumers

cd consumer
yarn install

Command

Provider commands

cmd
description
yarn test Run unittest with the latest contract from broker locally
yarn contract:verify Verify if current changes will affect consumers' contracts that depends on this service (should do this in CI)
yarn contract:can-i-deploy Check if current changes can be deployed using the latest contract from broker

Consumer commands

cmd
description
yarn test Run unittest and generate contract locally
yarn contract:publish Publish the generated contract to broker (should only do it in CI)
yarn contract:can-i-deploy Check if current consumer changes can be deployed using the latest contract from broker

About

Contract testing for microservices via Pact including graphql and rest


Languages

Language:TypeScript 78.3%Language:JavaScript 21.7%