Serve pacts as a mock
A consumer developed against the spec mock gets everything the spec allows, and can come to rely on fields no pact protects. A pact stub answers with what the published pacts promise instead. See Serve pacts as a mock.
- Choose the pacts. Every consumer's latest pact from its main branch, one consumer version, or whatever is deployed to an environment. Open it from Generate a pact from a mock → Serve pacts as a mock, or from Serve as a mock in a Contracts row's menu.
- Answered exactly. Each request gets the status, headers and body of the interaction it matches, judged as a Pact mock server judges it: method, path, query, the recorded headers and the body, under the pact's matching rules.
- Provider states are scenarios. Send
X-Mock-Scenario: <provider state>to be answered in that state. - Never a dead end. A request no pact covers is answered by the spec mock, or with a
501that says why. Every answer says where it came from inX-Mock-Stub(pact,fallback-spec,no-match). - Nothing silently dropped. Messages, plugin interactions, duplicates and sources that chose no pact are listed with the reason.
- Always current. The stub is rebuilt as soon as its pacts, branches or deployments change, and serving a call reads nothing from the database.
- From a pipeline.
apiome pact stub --provider "Billing Service" --pacts main,deployedsaves the same stub; over REST it isPUT /v1/tenants/{t}/pact-stubs/{provider}/{name}. Saves and deletes are audited.
How the hosted mock answers is on Pact stubs.
