wolfiton
Test error case in wormwood
Hi everyone,
Can’t find any error map in wormwood
My test works but I can’t test an error
describe "GetMenuItems.gql == error" do
test "Should return error Menu items (0 of them)" do
result = query_gql(variables: %{"matching" => "123"})
IO.inspect(result)
assert {:ok, %{data: %{"MenuItems" => menu_items}}} = result
IO.inspect(menu_items)
assert length(menu_items) == 0
end
end
This all I have
{:ok, %{data: %{"MenuItems" => []}}}
Am I missing something?
Thanks
Most Liked
benwilson512
I’m happy to keep helping you, but there are some Elixir basics here you seem to be struggling with that are making this a lot harder than it needs to be. Look carefully at the error message. Look at the exact data types between what you have what you are asserting on the left, and what the value of result is on the right. In particular, pay attention to what values are strings and what values are atoms.
Based on the content of your error messages, it looks like you’re working through the Absinthe book. This is a great way to learn absinthe. However, since you’re very new to this, I don’t think it’s a good idea to try to BOTH work through a new book AND utilize a testing library that isn’t used in the book. There are subtle but important differences between how wormwood tests work and how regular ExUnit test work, and those differences will only increase as you go further into the book and start handling things like authentication headers. I would ditch wormwood for now, and revisit it later after you have a solid grasp of how Absinthe and Elixir testing works.
benwilson512
Why should that return an error? 0 results isn’t an error. Additionally, a graphql query will only return an error if there is a syntax / validation issue with the query itself, or if you return an error from the resolver. If you aren’t doing that, it won’t error.
benwilson512
You didn’t pass in the same value. You passed in "123" (a string), but the wormwood example uses 123 (an integer).
Popular in Chat/Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









