Skip to content

Conversation

@niels
Copy link

@niels niels commented Apr 10, 2021

Previously, a GraphQL document containing nested fields could not be tested if one of the values was null / nil. The library stringifies the expected response, coercing nil to "". The assert_values_match was not able to take into account the field being defined as nillable because it wasn't aware of the nesting. This led to the below mismatch:

  1) test assert_equivalent_graphql/3 nested fields compare (AbsintheErrorPayload.TestHelperTest)
     test/test_helper_test.exs:131
     Assertion with == failed
     code:  assert {field, expected} == {field, response}
     left:  {
              :single,
              %{
                "integer" => "1",
                "nillable" => "",
                "string" => "single nested string"
              }
            }
     right: {
              :single,
              %{
                "integer" => 1,
                "nillable" => nil,
                "string" => "single nested string"
              }
            }
     stacktrace:
       (elixir 1.11.3) lib/enum.ex:798: Enum."-each/2-lists^foreach/1-0-"/2
       test/test_helper_test.exs:132: (test)

This PR adds a new assert_values_match so that nested field definitions get recursively resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant