<#841 Nested arrayContaining causes mocked server ...
# pact-js-development
g
#841 Nested arrayContaining causes mocked server to return null for the inner array Issue created by wabrit Software versions • OS: Windows 10 • Consumer Pact library: Pact JS 10.0.0-beta.58 • Node Version: v16.13.2 Expected behaviour Using arrayContaining matcher should work regardless of nesting level (e.g. arrayContaining including a nested property which is also matched by arrayContaining) Actual behaviour An arrayContaining nested inside another arrayContaining causes the mocked server to return null for the inner array. Steps to reproduce Sample (GraphQL) query
Copy code
query badQuery($id: ID!) {
        foo(id: $id) {
            bar {
              results {
                  __typename
              }
            }
        }
    }
Sample expectation:
Copy code
foo: {
  bar: arrayContaining(
    {
      results: arrayContaining({
        __typename: equal('Result')
       })
     }
   )
  }
Relevant log files DEBUG output from consumer test: ``` [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $ [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Configuring a normal object [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $.variables [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Configuring a normal object [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $.variables.id [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] detected pactmatchertype, will configure a matcher [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $ [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Configuring a normal object [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $.data [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Configuring a normal object [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $.data.foo [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Configuring a normal object [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $.data.foo.bar [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] detected pactmatchertype, will configure a matcher [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $ [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Configuring a normal object [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $.results [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] detected pactmatchertype, will configure a matcher [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $ [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Configuring a normal object [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $.__typename [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] detected pactmatchertype, will configure a matcher [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $.results [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $.results[*] [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Configuring a normal object [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $.results[*].__typename [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] detected pactmatchertype, will configure a matcher [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Skipping the matching rule (skip_matchers == true) [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $.data.foo.bar [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $.data.foo.bar[*] [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Configuring a normal object [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Path = $.data.foo.bar[*].results [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] detected pactmatchertype, will configure a matcher [2022-03-16T100704Z DEBUG pact_ffi:mock server:bodies] Skipping the matching rule (skip_matchers == true) [2022-03-16T100704Z DEBUG pact_plugin_driver::catalogue_manager] Updated catalogue entries: core/interaction/http core/interaction/https [2022-03-16T100704Z DEBUG pact_plugin_driver::catalogue_manager] Updated catalogue entries: core/content-generator/binary core/content-generator/json core/content-matcher/json core/content-matcher/multipart-form-data core/content-matcher/text core/content-matcher/xml [2022-03-16T100704Z DEBUG pact_plugin_driver::catalogue_manager] Updated catalogue entries: core/matcher/v1-equality core/matcher/v2-max-type core/matcher/v2-min-type core/matcher/v2-minmax-type core/matcher/v2-regex core/matcher/v2-type core/matcher/v3-content-type core/matcher/v3-date core/matcher/v3-datetime core/matcher/v3-decimal-type core/matcher/v3-includes core/matcher/v3-integer-type core/matcher/v3-null core/matcher/v3-number-type core/matcher/v3-time core/matcher/v4-array-contains core/matcher/v4-equals-ignore-order core/matcher/v4-max-equals-ignore-order core/matcher/v4-min-equals-ignore-order core/matcher/v4-minmax-equals-ignore-order core/matcher/v4-not-empty core/matcher/v4-semver [2022-03-16T100704Z DEBUG pact_mock_server::mock_server] Started mock server on 127.0.0.1:65384 [2022-03-16T100704Z DEBUG hyper:protoh1:io] parsed 7 headers [2022-03-16T100704Z DEBUG hyper:protoh1:conn] incoming body is content-length (178 bytes) [2022-03-16T100704Z DEBUG hyper:protoh1:conn] incoming body completed [2022-03-16T100704Z DEBUG pact_mock_server::hyper_server] Creating pact request from hyper request [2022-03-16T100704Z DEBUG pact_mock_server::hyper_server] Extracting query from uri /graphql [2022-03-16T100704Z INFO pact_mock_server::hyper_server] Received request HTTP Request ( method: POST, path: /graphql, query: None, headers: Some({"host": ["127.0.0.1:65384"], "content-type": ["application/json"], "content-length": ["178"], "user-agent": ["node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"], "accept": ["*/*"], "connection": ["close"], "accept-encoding": ["gzip", "deflate"]}), body: Present(178 bytes, application/json) ) [2022-03-16T100704Z DEBUG pact_mock_server::hyper_server] body: '{"operationName":"badQuery","variables":{"id":"1"},"query":"query badQuery($id: ID!) {\n foo(id: $id) {\n bar {\n results {\n __typename\n }\n }\n }\n}"}' [2022-03-16T100704Z INFO pact_matching] comparing to expected HTTP Request ( method: POST, path: /graphql, query: None, headers: Some({"Content-Type": ["application/json"]}), body: Present(178 bytes, application/json) ) [2022-03-16T100704Z DEBUG pact_matching] body: '{"operationName":"badQuery","query":"query badQuery($id: ID!) {\n foo(id: $id) {\n bar {\n results {\n __typename\n }\n }\n }\n}","variables":{"id":"1"}}' [2022-03-16T100704Z DEBUG pact_matching] matching_rules: MatchingRules { rules: {BODY: MatchingRuleCategory { name: BODY, rules: {DocPath { path_tokens: [Root, Field("variables"), Field("id")], expr: "$.variables.id" }: RuleList { rules: [Type], rule_logic: And, cascaded: false }} }, PATH: MatchingRuleCategory { name: PATH, rules: {} }} } [2022-03-16T100704Z DEBUG pact_matching] generators: Generators { categories: {} } [2022-03-16T100704Z DEBUG pact_matching::matchers] String -> String: comparing '/graphql' to '/graphql' using Equality (false) [2022-03-16T100704Z DEBUG pact_matching] expected content type = 'application/json', actual content type = 'application/json' [2022-03-16T100704Z DEBUG pact_matching] content type header matcher = 'RuleList { rules: [], rule_logic: And, cascaded: false }' [2022-03-16T100704Z DEBUG pact_plugin_driver::catalogue_manager] Looking for a content matcher for application/json [2022-03-16T100704Z DEBUG pact_matching] No content matcher defined for content type 'application/json', using core matcher implementation [2022-03-16T100704Z DEBUG pact_matching] Using body matcher for content type 'application/json' … pact-foundation/pact-js