Skip to content

danrusu/pact-consumer-poc

Repository files navigation

Contract testing POC - Consumer

1. Setup

pnpm install

2. Start Consumer

pnpm start

3 Run contract tests using PactFlow.io broker

  • validate producer expectations and generate contract

    pnpm test:pact
  • setup environment vars

    • bash
    export PACT_BROKER_BASE_URL=https://domain.pactflow.io
    export PACT_BROKER_TOKEN=*****
    • powershell
    [System.Environment]::SetEnvironmentVariable('PACT_BROKER_BASE_URL','https://domain.pactflow.io')
    [System.Environment]::SetEnvironmentVariable('PACT_BROKER_TOKEN','*****')
  • Publish contract to PactFlow.io

$hash=git rev-parse --short head
$branch=git rev-parse --abbrev-ref head
docker run --rm `
  -w /opt/pact `
  -v ${PWD}/pact/pacts:/opt/pact `
  -e PACT_BROKER_BASE_URL `
  -e PACT_BROKER_TOKEN `
  pactfoundation/pact-cli:latest publish . `
  --consumer-app-version $hash `
  --branch $branch
  • Can I deploy
$hash=git rev-parse --short head
docker run --rm `
  -e PACT_BROKER_BASE_URL `
  -e PACT_BROKER_TOKEN `
  pactfoundation/pact-cli:latest pact-broker can-i-deploy `
  --pacticipant pact-consumer-poc `
  --version $hash `
  --to-environment test
  • Record deployment/release
$hash=git rev-parse --short head
docker run --rm `
  -e PACT_BROKER_BASE_URL `
  -e PACT_BROKER_TOKEN `
  pactfoundation/pact-cli:latest pact-broker record-deployment `
  --pacticipant pact-consumer-poc `
  --version $hash `
  --environment test

About

Dummy frontend consumer for PACT POC

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published