Skip to content

buildMessageVerifierOptions

typescript
import { buildMessageVerifierOptions } from '@seontechnologies/pactjs-utils'

Builds a PactMessageProviderOptions object for message-based (Kafka, SQS, etc.) provider verification. The parameter set is nearly identical to buildVerifierOptions, but replaces port and requestFilter with messageProviders.

typescript
// Full example: https://github.com/seontechnologies/pactjs-utils/blob/main/pact/message/provider/provider-message-queue.pacttest.ts
const options = buildMessageVerifierOptions({
  provider: 'SampleMoviesAPI-event-producer',
  messageProviders: {
    'a movie event': () => Promise.resolve({ id: 1, name: 'Test Movie' })
  },
  includeMainAndDeployed: true
})

Parameters

NameType / DefaultWhat it does
providerstringrequiredProvider name; must match consumer message pact definitions.
messageProvidersMessageProvidersrequiredMaps message description strings to functions returning the payload.
includeMainAndDeployedbooleanrequiredControls selector breadth. Same behavior as buildVerifierOptions.
stateHandlersStateHandlers — optionalProvider state setup/teardown functions.
consumerstring — optionalScopes selectors to a single consumer.
enablePendingbooleanfalsePending pacts don't fail the build.
logLevelstring'info'Log verbosity ('trace' through 'error').
publishVerificationResultbooleantruePublish results to broker.
pactBrokerTokenstringenv.PACT_BROKER_TOKENBroker auth token.
providerVersionstringenv.GITHUB_SHA || 'unknown'Provider version string.
providerVersionBranchstringenv.GITHUB_BRANCH || 'main'Branch name.
providerVersionTagsstring[]getProviderVersionTags()Provider version tags.
pactUrlsstring[] — optionalLocal pact file paths. Bypasses broker when provided.
pactBrokerUrlstringenv.PACT_BROKER_BASE_URLBroker base URL.
pactPayloadUrlstringenv.PACT_PAYLOAD_URLWebhook payload URL.

Return Value

Returns a PactMessageProviderOptions object from @pact-foundation/pact.

Released under the MIT License.