The current project was created in the umbrella format using the Phoenix framework, where it has the
system_one
, system_one_web
and system_one_graphql
apps. And I’m creating a unit test for the user schema in the system_one_graphql app. And inside the test module it makes use of ConnCase that belongs to the system_one_web app. But when I run the test user_type_test.exs then the following error occurs:
SystemOne.Graphql.Schema.UserTypeTest [test/system_one_graphql/schema/user_type_test.exs]
* test GraphQL UserType List All (44.1ms) [L#22]
1) test GraphQL UserType List All (SystemOne.Graphql.Schema.UserTypeTest)
test/system_one_graphql/schema/user_type_test.exs:22
** (ArgumentError) errors were found at the given arguments:
* 1st argument: the table identifier does not refer to an existing ETS table
code: |> post("/graphql", %{
stacktrace:
(stdlib 3.17.1) :ets.lookup(SystemOneWeb.Endpoint, :secret_key_base)
lib/phoenix/endpoint.ex:490: SystemOneWeb.Endpoint.config/2
(elixir 1.13.3) lib/map.ex:830: Map.update!/3
lib/system_one_web/endpoint.ex:1: SystemOneWeb.Endpoint.call/2
lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
test/system_one_graphql/schema/user_type_test.exs:25: (test)
SystemOne.GraphqlTest [test/system_one/graphql_test.exs]
* test greets the world (0.00ms) [L#5]
* doctest SystemOneThis text will be hidden.Graphql.hello/0 (1) (0.00ms) [L#3]
Finished in 0.1 seconds (0.00s async, 0.1s sync)
1 doctest, 2 tests, 1 failure
Randomized with seed 749288
** (exit) 2
(mix 1.13.3) lib/mix/tasks/cmd.ex:64: Mix.Tasks.Cmd.run/1
(mix 1.13.3) lib/mix/task.ex:397: anonymous fn/3 in Mix.Task.run_task/3
(mix 1.13.3) lib/mix/project.ex:396: Mix.Project.in_project/4
(elixir 1.13.3) lib/file.ex:1560: File.cd!/2
(mix 1.13.3) lib/mix/task.ex:531: anonymous fn/4 in Mix.Task.recur/1
(elixir 1.13.3) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
(mix 1.13.3) lib/mix/task.ex:530: Mix.Task.recur/1
(mix 1.13.3) lib/mix/project_stack.ex:221: Mix.ProjectStack.recur/1
Below is the test module I have done so far:
defmodule SystemOne.Graphql.Schema.UserTypeTest do
use SystemOneWeb.ConnCase
# use ExUnit.Case
import Phoenix.ConnTest
@user_query """
query {
listAstusuar {
id
}
}
"""
describe "GraphQL UserType" do
test "List All", %{conn: conn} do
response =
conn
|> post("/graphql", %{
query: @user_query
})
|> IO.inspect(label: "💎")
assert json_response(response, 200) == %{"data" => []}
end
end
end