Pact Documentation

website·Indexed 38 days ago

https://docs.pact.io/

Resources for API and microservices testing, including implementation guides for various languages, Pact command line tools, the Pact Broker Client, and technical guides for Messaging Pacts and PactNet 4.x upgrades.

Tokens
2.9K
Snippets
3
Records
46
Agent score
73%

What's inside Pact

  1. Overview of the Pact Broker

    The Pact Broker is a service used for sharing consumer-driven contracts (pacts) and their verification results. While optimized for pacts created by the Pact framework, it can be used for any contract that can be serialized to JSON. It is a critical component for integrating Pact into CI/CD pipelines.
  2. Manage repository branches in Pact Broker

    From version 2.82.0 onwards, the Pact Broker supports repository branches as a first-class concept, replacing the previous recommendation of using version tags to represent branches associated with pacticipant versions.
  3. Configure Pact Broker Webhooks

    Pact Broker webhooks are triggered when pact content changes or when a verification is published. The system supports webhook whitelists for security and a template library for common configurations. Advanced usage includes dynamic variable substitution within webhook payloads.
  4. Deploy Pact Broker using Docker or Kubernetes

    The Pact Broker can be deployed as a Dockerized application using the pactfoundation/pact-broker image from Dockerhub. For orchestrated environments, it can be deployed on Kubernetes, with Helm charts available for deployment.
  5. Share Pacts using the Pact Broker

    Because consumer CI generates pact files and provider CI generates verification results in isolation, these artifacts must be shared. The Pact Broker serves as the central repository to exchange these files and results to coordinate deployment safety.
  6. Test consumers or providers without a native Pact client

    When a Pact client language does not exist for your specific stack, you can use alternative strategies to test consumers or providers. Refer to the 'Other Languages' guide for these strategies.
  7. Verify Pacts against a Provider

    Provider verification ensures that the provider returns the expected data and that the consumer is calling the API correctly. Key considerations include:

    • Authentication/Authorization: Be pragmatic when handling auth during verification; ensure integration code is tested without over-complicating the verification step.
    • Provider States: Use provider states to set up the necessary environment/data on the provider side before a specific interaction is verified.