<#952 `eachKeyLike` matcher isn't eachKeyLike, it ...
# pact-js-development
g
#952 `eachKeyLike` matcher isn't eachKeyLike, it is eachValueLike (also rust core version needs a bump) Issue created by TimothyJones Software versions Please provide at least OS and version of pact-js • OS: All • Consumer Pact library: 10.1.4 • Provider Pact library:N/A • Node Version: N/A Issue Checklist Please confirm the following: ☑︎ I have upgraded to the latest ☑︎ I have the read the FAQs in the Readme ☑︎ I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures ☐ I have set my log level to debug and attached a log file showing the complete request/response cycle ☐ For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem Expected behaviour As per pact-foundation/pact-reference#216 ,
eachLike
doesn't match correctly. This object:
Copy code
{
  "john-doe1": {
    "brown-fox": {
      "jumps": "over",
      "the": "lazy dog"
    }
  },
  "john-doe2": {
    "brown-fox2": {
      "jumps": "over",
      "the": "lazy dog"
    }
  }
}
should be matched by
Copy code
Matchers.eachKeyLike(
   "some string", 
   Matchers.eachKeyLike(
      "some-string", 
      Matchers.eachKeyLike(
         "some-string",
         Matchers.string())))
Actual behaviour It is not matched - the match only applies at the first level. Steps to reproduce As above Extra information To get the fix, we'll need to bump the rust core to at least 0.3.12. Also, as @uglyog pointed out:
BTW, the eachKeyLike function is incorrectly named. It should be something like eachValueLike.
Probably the right fix for this is: • Rename the existing
eachKeyLike
to
eachValueLike
• Add the
eachKeyLike
matcher (this is a breaking change, since the signature for
eachKeyLike
would describe something different to what it currently does / and currently is documented to do) • Update the documentation to match • For bonus points, I think there's also an
eachKeyValueLike
matcher which could be added pact-foundation/pact-js