** (RuntimeError) cannot begin test transaction with pool Ecto.Pools.Poolboy.
In order to use test transactions with Ecto SQL, you need to
configure your repository to use Ecto.Adapters.SQL.Sandbox:pool: Ecto.Adapters.SQL.Sandbox (ecto) lib/ecto/adapters/sql.ex:396: Ecto.Adapters.SQL.test_transaction/3 (elixir) lib/code.ex:363: Code.require_file/2 (elixir) lib/enum.ex:604: Enum."-each/2-lists^foreach/1-0-"/2 (elixir) lib/enum.ex:604: Enum.each/2 (mix) lib/mix/tasks/test.ex:191: Mix.Tasks.Test.run/1 (mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2 (elixir) lib/code.ex:363: Code.require_file/2
Based on previous reported issue : https://github.com/phoenixframework/phoenix/issues/1194
Removing "Ecto.Adapters.SQL.begin_test_transaction(Demo.Repo)" result another issue :
** (CompileError) test/views/layout_view_test.exs:2: module Demo.ConnCase is not loaded and could not be found
(elixir) expanding macro: Kernel.use/2
test/views/layout_view_test.exs:2: Demo.LayoutViewTest (module)
(elixir) lib/code.ex:363: Code.require_file/2
(elixir) lib/kernel/parallel_require.ex:47: anonymous fn/2 in Kernel.ParallelRequire.spawn_requires/5
Can you push your app somewhere? it feels like it is missing some configuration files or similar.
The test working properly after create a new clean project. I will try using this clean new project and put my configuration and let you know if problem still exist.
Thanks.
Sorry I'm late responding.
I'm not sure if help, the problem only appear when running "mix test" inside docker container. Running the command in host is working fine.
Thanks.
Hi, I crossed the same error, and the same context (running the test in a docker container), and that was because the mix env was not set to test.
MIX_ENV=test mix test
works! thanks.
I was having this issue, but I wanted a new environment. To fix it I needed to add
defp elixirc_paths(:ci), do: ["lib", "web", "test/support"]
to my mix.exs where ci is my environment name.
Same problem, and @migore's solution got me half way there.
I also had ["lib", "web"] hardcoded as my elixirc_paths at the top of my mix.exs when it should have been:
def project do
[....
elixirc_paths: elixirc_paths(Mix.env),
...]
end
Most helpful comment
I was having this issue, but I wanted a new environment. To fix it I needed to add
to my
mix.exswhereciis my environment name.