-
Notifications
You must be signed in to change notification settings - Fork 48
Description
I am using pact specification version 3, and using multiple files to declare my interactions, as described here.
I've noticed that the matching rules are being lost for all interactions besides the last one to execute during my test suite. I've dug through the source code and the pact specification, and I think I found a discrepancy.
Pact Specification
The Jsonpath section of the specification seems to declare that matchingRules
be a top level key for request
and response
, and that matchingRules
should then have keys that dictate what section of the request / response are being matched. It looks like Jsonpath takes over from there.
Code
Pact::InteractionV3Parser.parse_request_with_non_string_body
takes care of nested matching rules, and line 45 indexes into request_matching_rules
with a key, e.g. body
. This is consistent with what the specification describes.
The pact file I'm getting
Looks something like this:
{
"consumer": {
"name": "My Consumer"
},
"provider": {
"name": "My Provider"
},
"interactions": [
{
"description": "An events request",
"providerState": "an event board exists",
"request": {
"method": "POST",
"path": "/graphql",
"body": {
"operationName": null,
"query": "{\n eventBoard {\n title\n __typename\n }\n}\n",
"variables": { }
}
},
"response": {
"status": 200,
"body": {
"data": {
"eventBoard": {
"title": {
"__typename": "TranslatableField",
"en": "Example Event Board Title"
},
"__typename": "EventBoard"
}
}
},
"matchingRules": {
"$.body.data.eventBoard.title": {
"match": "type"
}
}
}
}
],
"metadata": {
"pactSpecification": {
"version": "3.0.0"
}
}
}
Note that the matchingRules
that are written here do not conform with the spec. I'm still reading through the code to find out where the contract gets written to the filesystem, but this seems to be the source of my problem. Can anyone confirm that this is a bug, or am I missing something?
Local setup
npm packages:
- @pact-foundation/[email protected]`
- @pact-foundation/[email protected]`
gems (which come from pact-node
)
- pact-1.38.0
- pact-message-0.5.0
- pact-mock_service-2.12.0
- pact-provider-verifier-1.22.0
- pact-support-1.9.0
- pact_broker-client-1.18.0