Skip to content
Latchkey

Pact "Actual interactions do not match expected" in CI

The Pact mock server compared the requests your consumer code actually made against the interactions the test declared, and they differ. It fails the consumer test before any pact file is written.

What this error means

A consumer test fails with "Actual interactions do not match expected interactions" and lists missing, unexpected, or altered requests captured by the mock server.

Pact
Pact verification failed - expected interactions did not match actual.

Missing requests:
  GET /orders/42

Unexpected requests:
  GET /orders/42?expand=items

Common causes

The client sent a different request than declared

The consumer added a query param, header, or path segment the interaction did not declare, so the mock server reports an unexpected request.

A declared interaction was never exercised

The test set up an interaction the code path did not call, so the mock server reports it as a missing request.

How to fix it

Match the interaction to the real request

  1. Compare the declared interaction with the actual request in the failure output.
  2. Update the interaction (or the client) so the method, path, query, and headers agree.
  3. Ensure every declared interaction is actually triggered by the test.
consumer.pact.spec.js
await provider.addInteraction({
  state: 'order 42 exists',
  uponReceiving: 'a request for order 42',
  withRequest: { method: 'GET', path: '/orders/42', query: { expand: 'items' } },
  willRespondWith: { status: 200, body: like({ id: 42 }) },
});

Use matchers for dynamic query and headers

Where a value varies, match by type or regex so an equivalent request is accepted.

consumer.pact.spec.js
query: { expand: term({ matcher: 'items|all', generate: 'items' }) }

How to prevent it

  • Keep declared interactions in lockstep with the client code under test.
  • Exercise every declared interaction so none is reported missing.
  • Use matchers for query params and headers that vary at runtime.

Frequently asked questions

What causes ""Actual interactions do not match expected""?
The consumer added a query param, header, or path segment the interaction did not declare, so the mock server reports an unexpected request.
How do I fix "Actual interactions do not match expected"?
Match the interaction to the real request

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card