Skip to main content

Pactflow Code Demos

Introduction

We have created a number of example 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:

ResourceDescriptionDownload
Demo PackA general demo pack for introducing Pact & the concepts of contract testingpdf | 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

id
required
string
type
string
name
required
string
version
string
price
required
number
{
  • "id": "string",
  • "type": "string",
  • "name": "string",
  • "version": "string",
  • "price": 0
}

Endpoints / Example Response

EndpointExample 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"}
info

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 Pactflow developer account here

LanguageTypeUse CaseDemoCompatible With
JavaScriptConsumerWebReact JavaScript Website tested using Pact to generate consumer pacts
  • Example Provider
  • JavaScriptConsumerWebReact JavaScript Website tested using Cypress to generate consumer pacts
  • Example Provider
  • JavaScriptProviderAPIExpressJS API provider tested with Pact Verifier
  • Example Consumer Cypress
  • Example Consumer
  • .NETProviderOpenAPI.NET API Provider tested wtih Swashbuckle and Schemathesis against OAS
  • Example Bi-Directional Consumer .NET
  • JavaProviderOpenAPISpringBoot 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
  • JavaScriptProviderOpenAPIExpressJS 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
  • JavaScriptProviderOpenAPIExpressJS 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
  • PythonProviderAPIPython API Provider tested with Pact Verifier
  • Example Python Consumer
  • GolangProviderAPIGolang Gin API Provider tested with Pact Verifier
  • Example Golang Consumer
  • .NETProviderAPI.NET API Provider tested with Pact Verifier
  • Example .NET Consumer
  • JavaProviderSOAPJava SOAP API provider tested with Pact Verifier
  • Example Java XML Consumer
  • JavaProviderMessagesJava Kafka message provider tested with Pact Verifier
  • Example Java Kafka Consumer
  • Example NodeJS Kafka Consumer
  • JavaProviderAPIJava Spring Boot API provider tested with Pact Verifier
  • Example Java Junit Consumer
  • JavaScriptProviderMessagesExpressJS AWS Lambda SNS Provider tested with Pact Verifier
  • Example Node AWS SNS Consumer
  • JavaScriptConsumerOpenAPINode 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
  • JavaConsumerOpenAPIJava 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
  • JavaScriptConsumerOpenAPIReact 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
  • JavaScriptConsumerOpenAPIReact 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
  • JavaScriptConsumerOpenAPIReact 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
  • PythonConsumerAPIPython API Consumer tested using Pact to generate consumer pacts
  • Example Python Provider
  • GolangConsumerAPIGolang API Consumer tested using Pact to generate consumer pacts
  • Example Golang Provider
  • .NETConsumerAPI.NET (v3.x.x) API Consumer tested using Pact to generate consumer pacts
  • Example Provider .NET
  • .NETConsumerAPI.NET (v4.x.x) API Consumer tested using Pact to generate consumer pacts
  • Example Bi-Directional Provider .NET
  • JavaConsumerAPIJava Junit API Consumer tested using Pact to generate consumer pacts
  • Example Java Spring Boot Provider
  • JavaConsumerSOAPJava SOAP API Consumer tested using Pact to generate consumer pacts
  • Example Java XML Provider
  • JavaConsumerMessagesJava Kafka Consumer tested using Pact to generate consumer pacts
  • Example Java Kafka Producer
  • NodeJSConsumerMessagesNodeJS Kafka Consumer tested using Pact to generate consumer pacts
  • Example Java Kafka Producer
  • NodeJSConsumerMessagesNodeJS AWS Lambda SNS Consumer tested using Pact to generate consumer pacts
  • Example NodeJS SNS Provider