Robert
04/12/2023, 7:21 AMpact-node@10.17.6: WARN: Ignoring unsupported matching rules {"match"=>"type"} for path $['body']['someData']['pData']['items'][*]@['type']
• Weirdly pact is adding and removing the matching rule during every test run. So the pact is also changed every time
"$.body.someData.pData.items[*].@id": {
"match": "type"
},
"$.body.someData.pData.items[*].@type": {
"match": "type"
},
I also saw there is a similar issue with the pact-php. https://github.com/pact-foundation/pact-php/issues/162 , but there is no progress since 3 years. So my question is should I raise an issue in pact-js or try to push the pact-php issue?Timothy Jones
04/12/2023, 7:26 AMTimothy Jones
04/12/2023, 7:27 AMWeirdly pact is adding and removing the matching rule during every test run. So the pact is also changed every timeThis is odd. Are you deleting the pact file before each run?
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Timothy Jones
04/12/2023, 7:35 AM@ has special meaning in jsonpathRobert
04/12/2023, 7:47 AMThis is odd. Are you deleting the pact file before each run?No the pact is not deleted. Pact is updating it
Timothy Jones
04/12/2023, 7:47 AMRobert
04/12/2023, 7:47 AMJust for clarification, the consumer test is in PHP and the verification is in JS - that right?In my case the consumer is in JS and the provider is JAVA
Timothy Jones
04/12/2023, 7:47 AMTimothy Jones
04/12/2023, 7:48 AMTimothy Jones
04/12/2023, 7:52 AM$.body.someData.pData.items[*].`@type
(note the backtick before the @)Timothy Jones
04/12/2023, 7:54 AMTimothy Jones
04/12/2023, 7:57 AMRobert
04/12/2023, 9:02 AMYou shouldn’t update it every time - I think there’s a note in the docs, you have to delete itCould I also use
pactfile_write_mode with override or is deleting it a better way?Timothy Jones
04/12/2023, 9:03 AMTimothy Jones
04/12/2023, 9:03 AMTimothy Jones
04/12/2023, 9:05 AMTimothy Jones
04/12/2023, 9:06 AMTimothy Jones
04/12/2023, 9:08 AMTimothy Jones
04/12/2023, 9:08 AMTimothy Jones
04/12/2023, 9:10 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Also, I can’t find the note that you need to clear out the pacts in the documentation any more. I know it used to be there.Thanks. It’s in the migration guide, but new users won’t read that
Matt (pactflow.io / pact-js / pact-go)
I don’t think the rust pact core which backs pact-js knows when you start and finish the test run, so I think if you can get it to overwrite the file, you’ll only have one interaction. A current maintainer will be able to tell youthe rust core only has one mode - update the existing pact (analogous to
merge). The reason is that you can run tests in parallel and so Pact doesn’t know about when the tests start/stop. It just knows about a test, and where to write the interactionTimothy Jones
04/12/2023, 11:13 AMTimothy Jones
04/12/2023, 11:13 AMMatt (pactflow.io / pact-js / pact-go)
pact-node version is which, but I definitely remember those Ruby warnings (they can be quite unreliable)Matt (pactflow.io / pact-js / pact-go)
Timothy Jones
04/13/2023, 2:52 AMPact does not support the full JSON path expressions, only ones that match the following rules:
• All paths start with a dollar ($), representing the root.
• All path elements are either separated by periods (.) or use the JSON path bracket notation (square brackets and single quotes around the values: e.g. [‘x.y’]), except array indices which use square brackets ([]). For elements where the value contains white space or non-alphanumeric characters, the JSON path bracket notation ([‘’]) should be used.
• The second element of the path is the http type that the matcher is applied to (e.g., $.body or $.header).
• Path elements represent keys.
• A star (*) can be used to match all keys of a map or all items of an array (one level only).This is probably the most relevant bit:
For elements where the value contains white space or non-alphanumeric characters, the JSON path bracket notation ([‘’]) should be used.I reckon whether not supporting properties starting with
@ is a bug or would need a spec change is an @uglyog question.Timothy Jones
04/13/2023, 2:53 AMJsonpath will still be used internally for matching body elements.V4 doesn’t mention jsonpath at all.
Robert
04/13/2023, 8:51 AMRobert
04/13/2023, 8:52 AM