API Hub for Contract Testing Code Demos

Introduction

We have created a number of examples projects and demo material that you can use as references for your rolling out your contract-testing initiatives.

Resources

Here are some useful resources when it comes to engaging your teams to help with Pact or contract-testing related initiatives:

Resource

Description

Download

Demo Pack

A general demo pack for introducing Pact & the concepts of contract testing

pdf | pptx

Scenarios

Product Catalog System (HTTP/Messages)

Our standard example is a product catalog website (see React) which consumes a basic Products API implementing the following HTTP interface.

All demo languages implement this interface so that we can easily mix and match technologies.

See and interact with the OpenAPI Product Spec here

Product Schema

product-schema-pactflow.png

Endpoints / Example Response

Endpoint

Example Response

GET/products

[{"id":"09","type":"CREDIT_CARD","name":"Gem Visa","version":"v1"},{"id":"10","type":"CREDIT_CARD","name":"28 Degrees","version":"v1"},{"id":"11","type":"PERSONAL_LOAN","name":"MyFlexiPay","version":"v2"}]

GET/product/1

{"id":"09","type":"CREDIT_CARD","name":"Gem Visa","version":"v1"}

Note

The single get product endpoint is not a spelling mistake, and is used to show evolution to more standard resource based design.

Demos

Click on the description link to see the example repository in GitHub.

We run these against GitHub Actions, so you can easily fork the repository and try it out today.

You can sign up for a free API Hub for Contract Testing developer account here.

Language

Type

Use Case

Demo

Compatible With

JavaScript

Consumer

Web

React JavaScript Website tested using Pact to generate consumer pacts

Example Provider

JavaScript

Consumer

Web

React JavaScript Website tested using Cypress to generate consumer pacts

Example Provider

JavaScript

Provider

API

ExpressJS API provider tested with Pact Verifier

Example Consumer Cypress

Example Consumer

.NET

Provider

OpenAPI

.NET API Provider tested wtih Swashbuckle and Schemathesis against OAS

Example Bi-Directional Consumer .NET

Java

Provider

OpenAPI

SpringBoot API Provider tested with RestAssured against OAS

Example Bi-Directional Consumer Cypress

Example Bi-Directional Consumer Mountebank

Example Bi-Directional Consumer Wiremock

Example Bi-Directional Consumer Nock

Example Bi-Directional Consumer MSW

JavaScript

Provider

OpenAPI

ExpressJS API Provider tested with Postman against OAS

Example Bi-Directional Consumer Cypress

Example Bi-Directional Consumer Mountebank

Example Bi-Directional Consumer Wiremock

Example Bi-Directional Consumer Nock

Example Bi-Directional Consumer MSW

JavaScript

Provider

OpenAPI

ExpressJS API Provider tested with ReadyAPI against OAS

Example Bi-Directional Consumer Cypress

Example Bi-Directional Consumer Mountebank

Example Bi-Directional Consumer Wiremock

Example Bi-Directional Consumer Nock

Example Bi-Directional Consumer MSW

JavaScript

Provider

OpenAPI

ExpressJS API Provider tested with SoapUI against OAS

Example Bi-Directional Consumer Cypress

Example Bi-Directional Consumer Mountebank

Example Bi-Directional Consumer Wiremock

Example Bi-Directional Consumer Nock

Example Bi-Directional Consumer MSW

JavaScript

Provider

OpenAPI

ExpressJS API Provider tested with Dredd against OAS

Example Bi-Directional Consumer Cypress

Example Bi-Directional Consumer Mountebank

Example Bi-Directional Consumer Wiremock

Example Bi-Directional Consumer Nock

Example Bi-Directional Consumer MSW

Python

Provider

API

Python API Provider tested with Pact Verifier

Example Python Consumer

Golang

Provider

API

Golang Gin API Provider tested with Pact Verifier

Example Golang Consumer

.NET

Provider

API

.NET API Provider tested with Pact Verifier

Example .NET Consumer

Java

Provider

SOAP

Java SOAP API provider tested with Pact Verifier

Example Java XML Consumer

Java

Provider

Messages

Java Kafka message provider tested with Pact Verifier

Example Java Kafka Consumer

Example NodeJS Kafka Consumer

Java

Provider

API

Java Spring Boot API provider tested with Pact Verifier

Example Java Junit Consumer

JavaScript

Provider

Messages

ExpressJS AWS Lambda SNS Provider tested with Pact Verifier

Example Node AWS SNS Consumer

JavaScript

Consumer

OpenAPI

Node API consumer using Mountebank stubs and Pact Bi-Directional BYO adapters to generate Pact contracts

Example Bi-Directional Provider Dredd

Example Bi-Directional Provider Postman

Example Bi-Directional Provider RestAssured

Example Provider

Java

Consumer

OpenAPI

Java API consumer using Wiremock stubs and Pact Bi-Directional BYO adapters to generate Pact contracts

Example Bi-Directional Provider Dredd

Example Bi-Directional Provider Postman

Example Bi-Directional Provider RestAssured

Example Provider

JavaScript

Consumer

OpenAPI

React JavaScript Website using MSW mocks and pact-msw-adapter to generate Pact contracts

Example Bi-Directional Provider Dredd

Example Bi-Directional Provider Postman

Example Bi-Directional Provider RestAssured

Example Provider

JavaScript

Consumer

OpenAPI

React JavaScript Website using Playwright routes and custom pact adapter to generate Pact contracts

Example Bi-Directional Provider Dredd

Example Bi-Directional Provider Postman

Example Bi-Directional Provider RestAssured

Example Provider

JavaScript

Consumer

OpenAPI

React JavaScript Website using Cypress fixtures and pact-cypress-adapter to generate Pact contracts

Example Bi-Directional Provider Dredd

Example Bi-Directional Provider Postman

Example Bi-Directional Provider RestAssured

Example Provider

JavaScript

Consumer

OpenAPI

React JavaScript Website using Nock Record & Replay feature and pact-nock-adapter to generate Pact contracts

Example Bi-Directional Provider Dredd

Example Bi-Directional Provider Postman

Example Bi-Directional Provider RestAssured

Example Provider

Python

Consumer

API

Python API Consumer tested using Pact to generate consumer pacts

Example Python Provider

Golang

Consumer

API

Golang API Consumer tested using Pact to generate consumer pacts

Example Golang Provider

.NET

Consumer

API

.NET (v3.x.x) API Consumer tested using Pact to generate consumer pacts

Example Provider .NET

.NET

Consumer

API

.NET (v4.x.x) API Consumer tested using Pact to generate consumer pacts

Example Bi-Directional Provider .NET

Java

Consumer

API

Java Junit API Consumer tested using Pact to generate consumer pacts

Example Java Spring Boot Provider

Java

Consumer

SOAP

Java SOAP API Consumer tested using Pact to generate consumer pacts

Example Java XML Provider

Java

Consumer

Messages

Java Kafka Consumer tested using Pact to generate consumer pacts

Example Java Kafka Producer

NodeJS

Consumer

Messages

NodeJS Kafka Consumer tested using Pact to generate consumer pacts

Example NodeJS SNS Provider

NodeJS

Consumer

Messages

NodeJS AWS Lambda SNS Consumer tested using Pact to generate consumer pacts

Example NodeJS SNS Provider

Publication date: