CodeVetter · Repo Unpack · Feature catalog
pact-foundation/pact-js
The public surface supports HTTP request/response contracts, asynchronous event contracts, synchronous messages, and GraphQL over HTTP. Matching APIs express flexible contracts while supplying concrete examples to consumer tests. Provider callbacks, broker options, interaction metadata, and plugins support more involved verification workflows.
- V4 HTTP tests configure method/path, query parameters, headers, body, and expected status through fluent builders, then execute a callback against a dynamic mock server with configurable host, port, TLS, and CORS.
- MatchersV3 supplies type, regex, numeric, bounded-array, key/value, status-code, date/time, UUID, URL, equality, inclusion, null, and array-containing declarations.
- HTTP builders accept binary files, Buffer bodies, multipart files with an optional boundary, and explicit matching rules; XmlBuilder and XmlElement construct XML templates containing text and repeated-element matchers.
- addGraphQLInteraction supports operation names, variables, queries, and mutations; query text is validated and wrapped in a whitespace-flexible regex inside an application/json request body.
- V4 asynchronous messages support JSON or binary content, metadata, and explicit rules; synchronous messages separately configure request and response content and expose Request plus a Response array to callbacks.
- Provider verification supports named state setup/teardown handlers, beforeEach/afterEach hooks, Express request filters, message producer registries, TLS client credentials, and optional broker result publication.
- given accepts state parameters, fromProviderState declares generator expressions, and provider callbacks can return generated values; the account example connects ${accountId} to the handler's returned accountId.
- HTTP and message builders support pending flags, comments, test names, and grouped references; usingPlugin loads named/versioned plugins, and message plugin builders can start custom transports.