pact-js 11.1.0. provider verification stage in ci is blowing up. consumer contract looks fine locally.
contract snippet:
provider.addInteraction({
state: 'agent available for wrap up',
uponReceiving: 'request for active interaction history',
withRequest: {
method: 'GET',
path: '/api/v2/interactions',
query: {
status: 'active',
routingType: 'queue'
}
},
willRespondWith: {
status: 200,
body: {
totalCount: 1,
items: [
{
id: Pact.term({generate: 'abc-123', matcher: Pact.regexp('.*-.*')})
}
]
}
}
})
the issue is the routingType param. when the provider (genesys cloud) actually runs the verification, it appends extra query params like pageSize=25 and page=1 that aren’t in the contract. pact is strict on query param matching by default. it’s failing with:
Query parameter 'pageSize' was not expected but was received.
tried using Pact.term on the query object but that doesn’t seem to work for extra keys. just matching the known keys isn’t enough. the provider sends back 200 with data, but pact rejects it because the query string doesn’t match exactly.
setting matchingRules on the query params:
withRequest: {
query: Pact.like({
status: 'active',
routingType: 'queue'
})
}
still fails. Pact.like checks for existence, not absence. if i want to ignore extra params, i need to tell pact that the query object can have other keys.
can’t find a clean way to say “match these specific keys and ignore the rest” in pact-js 11. docs suggest using Pact.term with a regex on the whole query string but that feels brittle and breaks if the order of params changes.
is there a standard pattern for ignoring provider-side pagination params in query strings? or do i have to manually list every possible param the gc api might append? that seems unsustainable.
using jest for tests. node 18.
anyone got a working example of flexible query param matching for list endpoints?