liveBook · Manning

Verifier interface

As explained in Contract Testing in Action

A Pact interface representing a provider and exposing provider-verification functionality for checking it against consumer contracts.

A verifier interface represents a provider during Pact contract verification. It checks whether a running provider satisfies the interactions recorded in consumer contracts, rather than testing every provider business rule. section 6.3.1 section 6.6

A practical provider verification setup typically:

  • Starts the provider service and makes its base URL available to the test. section 6.3.1
  • Configures the provider name, broker connection, provider version, publication behavior, and consumer version tags. section 6.3.1
  • Creates a Verifier instance, calls verifyProvider, reports the result, and closes the service. section 6.3.1
  • Keeps broader business-rule coverage in separate functional tests. section 6.6

MoviesAPI provider verification

A provider test starts the MoviesAPI locally, configures providerBaseUrl as its address, retrieves consumer contracts through the Pact Broker, and verifies the consumer version tagged main. It publishes the verification result and closes the server after completion. section 6.3.1

const options = {
  provider: 'MoviesAPI',
  providerBaseUrl: `http://localhost:${port}`,
  pactBrokerUrl: process.env.PACT_BROKER_BASE_URL,
  pactBrokerToken: process.env.PACT_BROKER_TOKEN,
  providerVersion: '1.0.0',
  publishVerificationResult: true,
  consumerVersionTags: ['main'],
};

const verifier = new Verifier(options);

The options object shows how provider identity, access, broker credentials, versioning, result publication, and consumer selection shape verification. section 6.3.1

How Contract Testing in Action covers it

How deep it goes
Explains setup, metadata, execution, publication, and cleanup, while deferring broader business-rule coverage to functional tests.
Examples
Uses a JavaScript MoviesAPI test that starts a local server, verifies movie-consumer expectations, and publishes results.
What it assumes
Assumes a consumer contract, a running provider API, and Pact Broker access; teaches the provider-verification setup.
What you can do after
Operate provider verification by configuring Verifier options, running verifyProvider, and publishing the result.
How it connects
Connects consumer-driven contract testing with provider states, functional testing, and the Pact Broker.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Contract Testing in Action. The section links point to the parts of the book it draws on.