Hello,
Is there a way that I can set global-wide request header inside conn_case.ex?
I would like to set the authorization header for all the tests since setting it in every file is a bit annoying.
This does not work:
# test/support/conn_case.ex
setup tags do
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(MyApp.Repo, shared: not tags[:async])
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
{:ok, conn: Phoenix.ConnTest.build_conn()}
{:ok,
conn:
Phoenix.ConnTest.put_req_header(
"authorization",
"Bearer " <> Application.get_env(:myapp, MyAppWeb.Endpoint)[:api_key]
)}
end