I am using Pact for Consumer Driven Contracts testing. In my usecase, my consumer "some-market-service-consumer" is using provider "market-service". The contract "produced" at some-market-service-consumer, looks like this:
{
"provider": {
"name": "market-service"
},
"consumer": {
"name": "some-market-service-consumer"
},
"interactions": [
{
"description": "Get all markets",
"request": {
"method": "GET",
"path": "/markets"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"body": {
"markets": [
{
"phone": "HBiQOAeQegaWtbcHfAro"
}
]
},
"matchingRules": {
"$.headers.Content-Type": {
"regex": "application/json; charset=utf-8"
},
"$.body.markets[*].phone": {
"match": "type"
},
"$.body.markets": {
"min": 1,
"match": "type"
}
}
}
}
],
"metadata": {
"pact-specification": {
"version": "2.0.0"
},
"pact-jvm": {
"version": "3.3.6"
}
}
}
On provider-site, I am using pact-provider-verifier-docker¹. Here is my test-result:
WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body']['markets']
.....
@@ -1,7 +1,7 @@
{
"markets": [
... ,
- Pact::UnexpectedIndex,
+ Hash,
]
}
Key: - means "expected, but was not found".
+ means "actual, should not be found".
Values where the expected matches the actual are not shown.
It seems, as if the testing works fine - "phone" is tested valid. But at this point, I have no clue, what (expected) "Pact::UnexpectedIndex" means, and why it fails. Where does this expectation come from, how to fix it?
¹ In special, my own version, which uses most recent external dependencies.