← All projects

Featured project 9 · TypeScript + Java · Contract testing

Pact Contract Testing

Consumer-driven contract testing with Pact between a TypeScript checkout client and a Java Spring Boot product API, through a self-hosted Pact Broker with can-i-deploy, in one command locally and in GitHub Actions.

Live CI status of Pact Contract Testing

View source code View documentation View latest CI runs View test report

Purpose

Shows how two teams can change and deploy their services independently without an end-to-end environment: the consumer writes down what it needs, the provider proves it delivers that, and the broker answers before every deployment whether the versions fit together. Two languages on purpose: the teams share only the contract.

Technology stack

AreaTools
ConsumerTypeScript, fetch, Pact JS 17 (Pact specification V4), Vitest
ProviderJava 17, Spring Boot 4.1, Pact JVM 4.7 with JUnit 5, Maven wrapper
BrokerSelf-hosted Pact Broker 2.121 with PostgreSQL 17 in Docker Compose
Deployment checkspact-broker CLI: publish, can-i-deploy, create-environment, record-deployment
CIGitHub Actions: consumer and provider jobs, then the full broker workflow with the matrix on the run page

Architecture overview

checkout-web (TypeScript)      contract tests run the real client against Pact's mock server
      │  pact file (6 interactions)
      ▼
Pact Broker (Docker)           contracts, verification results, branches, environments, deployments
      │                        can-i-deploy?  record-deployment
      ▼
product-service (Spring Boot)  JUnit 5 verification of the real app: provider states, token filter

Key engineering decisions

Implemented features

Setup and execution

npm ci && npm ci --prefix checkout-web
npm run contract        # the whole workflow (needs Docker and Java 17+)
npm run demo:breaking   # a breaking consumer change, blocked by can-i-deploy
npm run broker:down

Sample test results

Pact Broker matrix with a verified main version and a failed feature-branch version
The broker's matrix: the main version verified and deployed to production, the feature-branch version failed.
can-i-deploy output: yes for the main version, no for the feature branch
can-i-deploy: yes for the main version, no for the feature version, with the reason.

CI workflow

On every push and pull request: the consumer job (lint, types, unit and contract tests) and the provider job (Maven tests) in parallel, then a job that starts the Pact Broker with Docker Compose and runs the whole workflow and the breaking-change demo, and writes the broker's matrix to the run page.

Known limitations and future improvements

Limitations

Next steps