Skip to content

Problem with test that passes #12

@wolfiton

Description

@wolfiton

I was trying to rewrite this test in Wormwood:

@query """
  {
    menuItems(matching: 123) {
      name
    }
  }
  """
  test "menuItems field returns errors when using a bad value" do
    response = get(build_conn(), "/api", query: @query)
    assert %{"errors" => [
      %{"message" => message}
    ]} = json_response(response, 400)
    assert message == "Argument \"matching\" has invalid value 123."
  end

And i don’t see any possibilities at the moment to do so.

My final version is this

describe "GetMenuItems.gql == error" do
    test "Should return error Menu items (error)" do
      term = 123
      result = query_gql(variables: %{"matching" => term})
      IO.inspect(result)

      assert {:ok, %{errors: [%{message: message}]}} = result

      assert message == "Argument \"matching\" has invalid value $matching."
    end
  end

The main problem is that I am expecting my value instead of $matching in this case 123 like in the exunit test
The problem is discussed here https://elixirforum.com/t/test-error-case-in-wormwood/28876/18

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions