Skip to content
Latchkey

How to Choose Pacts With Consumer Version Selectors

Consumer version selectors tell the verifier which consumer pacts to pull, for example the latest on the main branch plus all versions deployed to production.

Replace broad pact URLs with consumerVersionSelectors. Common selectors are the matching branch, the latest from main, and everything currently deployed to an environment.

Steps

  • Add consumerVersionSelectors to the verifier config.
  • Include mainBranch: true for the current mainline contract.
  • Include deployedOrReleased: true to cover live consumers.

Selectors

provider.verify.js
await new Verifier({
  provider: 'orders-api',
  providerBaseUrl: 'http://localhost:8080',
  pactBrokerUrl: process.env.PACT_BROKER_BASE_URL,
  pactBrokerToken: process.env.PACT_BROKER_TOKEN,
  providerVersion: process.env.GITHUB_SHA,
  consumerVersionSelectors: [
    { mainBranch: true },
    { matchingBranch: true },
    { deployedOrReleased: true },
  ],
}).verifyProvider();

Gotchas

  • Verifying every historical version is slow; selectors keep the set to what actually matters.
  • deployedOrReleased depends on record-deployment being called after real deploys.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →