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
providerstring — requiredProvider name; must match consumer message pact definitions.
messageProvidersMessageProviders — requiredMaps message description strings to functions returning the payload.
includeMainAndDeployedboolean — requiredControls selector breadth. Same behavior as buildVerifierOptions.
stateHandlersStateHandlers — optionalProvider state setup/teardown functions.
consumerstring — optionalScopes selectors to a single consumer.
consumerBranchstring — env.PACT_CONSUMER_BRANCHAdds { branch: <name> } to selectors. Requires consumer to also be set (throws otherwise). For stable branch names only; use webhook flow for dynamic PR branches.
enablePendingboolean — falseWhen true, pending pacts do not fail the provider build. See enablePending — bridge, not bypass.
logLevelstring — 'info'Log verbosity ('trace' through 'error').
publishVerificationResultboolean — truePublish results to broker.
pactBrokerTokenstring — env.PACT_BROKER_TOKENBroker auth token.
providerVersionstring — env.PACT_PROVIDER_VERSION || env.GITHUB_SHA || 'unknown'Provider version string.
providerVersionBranchstring — env.PACT_PROVIDER_BRANCH || env.GITHUB_BRANCH || 'main'Branch name.
providerVersionTagsstring[] — getProviderVersionTags()Provider version tags.
pactUrlsstring[] — optionalLocal pact file paths. Bypasses broker when provided.
pactBrokerUrlstring — env.PACT_BROKER_BASE_URLBroker base URL.
pactPayloadUrlstring — env.PACT_PAYLOAD_URLWebhook payload URL.

Return Value ​

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

Released under the Apache 2.0 License.