TOPIC 41/6216 MINNOT STARTED

Pact: a consumer contract test between two services

Check the consumer’s real client against a mock, then check the real provider against the saved contract. Each result answers a different question.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: an order form between a shop and a baker. The shop says which loaf it needs. The baker checks whether its bread meets that need. The form leaves out details the shop does not use, such as the oven’s colour.

Mei tests Daily List, a made-up to-do app. Its phone app reads a task’s title. The tasks service plans to rename that field to name. Both names sound fine to a person. Code that still reads title may fail.

A contract test checks this agreement between programs. Mei first checks her phone app’s calling code against a controlled stand-in. This writes a file of its needs. Tom then checks the tasks service against that file.

These are two checks, not one. A passing phone test only shows it can use the stand-in’s reply. It does not show the changed service still sends that reply. Tom’s separate check supplies that evidence.

The picture has a limit: a written order does not inspect the baker. Nor does a saved contract test a running service by itself. These checks cover selected messages, not every user journey.

(SYNTHETIC / TRAINING ONLY: Daily List, Mei, Tom and all task data are invented.)

PLAIN WORDS · 1 in this section
rename
give a new name to

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.

THE REAL JOB Check the real client against a stand-in, then the real provider against the saved needs.

  1. Expect
  2. Pact
  3. Verify
Order form

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
The shopThe consumer
The bakerThe provider
The order formThe pact file
Checking the formVerification

WHERE THIS PICTURE STOPS

  • A form is read by people; Pact checks coded interactions and matching rules.
  • A saved form proves no delivery. A pact file needs separate provider verification.
  • A passed interaction is not proof of a whole journey or every deployed version.

HOOK

Expect, write, verify.

TELL A FRIEND

An order form: the shop writes it, the baker proves it.

OFTEN MIXED UP WITH Contract testing ideas. That topic gives the ideas. This one writes a consumer test and a provider check.

PRACTISE AND KEEP

Sources for this topic — 8 sources
  1. Market practice

    How Pact works — consumer tests and provider verification ↗ — Pact Foundation · How Pact works: HTTP roles, Consumer testing, Provider verification and Putting it all together; page footer 23 December 2024. Actual primary page read 8 November 2026. Daily List is synthetic.

    Actual consumer client against mock provider, pact generation, independent provider states and provider verification opened. Product guidance, not a universal testing standard. Original figure source bytes matched repositorye2072af34960cb19d6c132d370c2fd580ec0e55c under the documentation MIT notice. · Checked 2026-11-08

    Opened relevant primary passages on6November2026 via normal web search and document view. Actual consumer client against mock provider, pact generation, independent provider states and provider verification opened. Product guidance, not a universal testing standard. Original figure source bytes matched repositorye2072af34960cb19d6c132d370c2fd580ec0e55c under the documentation MIT notice.

    8 November 2026: actual HTTP interaction, Consumer Testing and Provider Verification sections through Putting It All Together opened, page footer 23 December 2024. Consumer checks and selected provider response verification are distinct; a written contract alone is not verification. No whole transport or deployed-behavior guarantee.

  2. Market practice

    Writing consumer tests ↗ — Pact Foundation · Writing consumer tests: assertions, field-by-field exact/loose matching and isolated real client code. Actual primary page read 8 November 2026. Daily List is synthetic.

    Field-specific response matchers and isolated tests of real consumer client code. · Checked 2026-11-08

    Named primary sections opened and read 8 November 2026. Product guidance, not a universal testing standard. Pact JS runtime behavior requires its separate executed test report. Provider API source: https://docs.pact.io/implementation_guides/javascript/docs/provider.

  3. Market practice

    Verifying Pacts ↗ — Pact Foundation · Verifying Pacts: local provider, downstream stubbing below request parsing, and publishing versioned verification evidence. Actual primary page read 8 November 2026. Daily List is synthetic.

    Local provider verification, stubbing below request parsing, and bounded versioned results. · Checked 2026-11-08

    Named primary sections opened and read 8 November 2026. Product guidance, not a universal testing standard. Pact JS runtime behavior requires its separate executed test report. Provider API source: https://docs.pact.io/implementation_guides/javascript/docs/provider.

  4. Market practice

    Using provider states effectively ↗ — Pact Foundation · Using provider states effectively: misleading one-record fixtures and contrasting data that exposes an ignored query parameter. Actual primary page read 8 November 2026. Daily List is synthetic.

    Contrasting fixture data can expose ignored query parameters; general functional tests remain provider-owned. · Checked 2026-11-08

    Named primary sections opened and read 8 November 2026. Product guidance, not a universal testing standard. Pact JS runtime behavior requires its separate executed test report. Provider API source: https://docs.pact.io/implementation_guides/javascript/docs/provider.

  5. Market practice

    Pact JS HTTP consumer and provider tests ↗ — Pact Foundation · Pact JS Consumer Tests and linked Provider Verification: Pact/PactV4, explicit specification version, executeTest, Verifier, stateHandlers and local pactUrls. Documentation read, not a runtime result. Actual primary page read 8 November 2026. Daily List is synthetic.

    Pact/PactV4 builder, explicit specification, real-client calls and fresh pact output. Linked provider page supports local pactUrls and stateHandlers. · Checked 2026-11-08

    Named primary sections opened and read 8 November 2026. Product guidance, not a universal testing standard. Pact JS runtime behavior requires its separate executed test report. Provider API source: https://docs.pact.io/implementation_guides/javascript/docs/provider.

  6. Market practice

    Can I Deploy ↗ — Pact project · Can I Deploy: version matrix, can-i-deploy with a target environment, and recording deployment after success. Actual primary page read 8 November 2026. Daily List is synthetic.

    The Pact Matrix records exact consumer/provider version pairs and verification results. Deployment checks use the target environment and its recorded deployed or released versions. · Checked 2026-10-21

    Primary page opened and read on 2026-10-21. Scope is the claim described here; this does not upgrade earlier citations to other pages. Examples in Daily List are synthetic teaching examples.

  7. Market practice

    Pending pacts ↗ — Pact project · Pending pacts: a failed pending verification can leave the provider task green; the published result remains failed. No consumer compatibility pass follows. Actual primary page read 8 November 2026. Daily List is synthetic.

    Pending verification may leave the provider build green while recording a failed verification. It does not make the unsupported consumer safe to deploy. Pending status depends on pact content, verification history and provider branch. · Checked 2026-10-21

    Primary page opened and read on 2026-10-21. Scope is the claim described here; this does not upgrade earlier citations to other pages. Examples in Daily List are synthetic teaching examples.

  8. Market practice

    Pact JS HTTP process summary diagram ↗ — Pact Foundation / DiUS · Pact JS summary diagram (MIT licence, image unchanged) shown in this lesson: separate consumer and provider checks around a shared contract.

    Original numbered diagram of separate consumer and provider unit-test boundaries, generated contract, sharing and verification. · Checked 2026-11-08

    Original image and root MIT LICENSE read at pinned repository commit e50b6068ce9766a95ebfd678353a0e8057a0d8e6. Copyright and full permission notice retained beside the unchanged image. No endorsement claim. The earlier docs.pact.io figure was previewed but held because its license lived in a separate docs subtree.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.