Test with post does not work

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)
     ** (ArgumentError) errors were found at the given arguments:
       * 1st argument: the table identifier does not refer to an existing ETS table
     code: |> post("/graphql", %{
       (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 {

  describe "GraphQL UserType" do
    test "List All", %{conn: conn} do
      response =
        |> post("/graphql", %{
          query: @user_query
        |> IO.inspect(label: "💎")

      assert json_response(response, 200) == %{"data" => []}

Hi @ns.bruno!

Could you share the definition of your SystemOneWeb.ConnCase module? That might help.

@trisolaran below the module SystemOneWeb.ConnCase:

defmodule SystemOneWeb.ConnCase do
  @moduledoc """
  This module defines the test case to be used by
  tests that require setting up a connection.

  Such tests rely on `Phoenix.ConnTest` and also
  import other functionality to make it easier
  to build common data structures and query the data layer.

  Finally, if the test case interacts with the database,
  we enable the SQL sandbox, so changes done to the database
  are reverted at the end of every test. If you are using
  PostgreSQL, you can even run database tests asynchronously
  by setting `use SystemOneWeb.ConnCase, async: true`, although
  this option is not recommended for other databases.

  use ExUnit.CaseTemplate

  alias Ecto.Adapters.SQL.Sandbox

  using do
    quote do
      # Import conveniences for testing with connections
      import Plug.Conn
      import Phoenix.ConnTest
      import SystemOneWeb.ConnCase

      alias SystemOneWeb.Router.Helpers, as: Routes

      # The default endpoint for testing
      @endpoint SystemOneWeb.Endpoint

  setup tags do
    :ok = Sandbox.checkout(OnSistemas.Repo)

    unless tags[:async] do
      Sandbox.mode(OnSistemas.Repo, {:shared, self()})

    {:ok, conn: Phoenix.ConnTest.build_conn()}

thanks, that didn’t help after all :slight_smile:

My best guess is that you forgot to start your endpoint. Check your application.ex file in the system_one_web application.

you should start your endpoint there as part of your application’s supervision tree. You should see something like:

def start(_type, _args) do
    children = [
      # Start the Telemetry supervisor
      # Start the PubSub system
         name: MyApp.PubSub,
         adapter: Phoenix.PubSub.Redis,
         node_name: to_string(node()),
         url: Application.get_env(:data_ingestion, :redis, "redis://localhost")
      # Start the Endpoint (http/https)

    opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, opts)

If I uncomment the line with MyApp.Endpoint and try to run some tests, I see the same error you’re seeing.