Pact is a consumer-driven contract testing framework where API consumers define expected interactions and providers verify them. The Pact Broker stores contracts and verification results, and can-i-deploy uses this data to prevent deploying incompatible service versions.
0 / 5 completed
1 / 5
What is consumer-driven contract testing, as implemented by Pact?
In Pact consumer-driven contract testing, the consumer writes tests that record expected API interactions into a Pact file (the contract). The provider then verifies this contract by replaying the recorded interactions against their actual implementation, catching breaking changes without running full integration tests.
2 / 5
A consumer team publishes a Pact contract to the Pact Broker. What is the Pact Broker's role in the workflow?
The Pact Broker is a central repository that stores Pact files and tracks verification results per version. The can-i-deploy tool queries the Broker to check whether a specific consumer or provider version is safe to deploy, based on whether all relevant contracts are verified.
3 / 5
During provider verification, Pact replays consumer interactions against the provider. What is a provider state?
Provider states are named setup hooks defined by the provider (e.g., 'a user with ID 123 exists'). Before replaying an interaction that requires specific data, Pact calls the corresponding provider state handler to seed the database or configure mocks, ensuring the provider is in the correct state for each interaction.
4 / 5
A developer runs pact verify and sees a failure for an interaction. The consumer expects a field userId but the provider returns user_id. What type of breaking change does this represent?
Pact performs flexible matching but field names are exact by default. A provider returning user_id when the consumer expects userId is a response body mismatch that causes verification to fail. This is exactly the type of breaking API change Pact is designed to catch before deployment.
5 / 5
What does the can-i-deploy command check before deploying a service?
can-i-deploy queries the Pact Broker to verify that the version being deployed has verified, compatible contracts with all consumer and provider versions currently deployed in the target environment. It prevents deploying a version that would break existing integrations.