I'am trying to load the iex.iexs file when debugging a test. I created an alias in Mix.exs that tries to import it.
defp aliases do
[
...,
"ex.file": [&import_iex_file/1, "compile"]
]
end
defp import_iex_file(_var) do
require IEx.Helpers
# This raises a File.Error if ~/.iex.exs doesn't exist.
if "./.iex.exs" |> Path.expand() |> File.exists?() do
IEx.Helpers.import_file("./.iex.exs")
end
end
When I run a test with iex -S mix test_path the file is loaded, but when it stop at the IEx.pry I can't access the aliases that I added at the .iex.iex file.
Note the file name should be
.iex.exs. As you have noticed, running tests does not start anIExsession, so the file is not loaded. Instead, it might be better to do whatever setups you need for tests inside yourtests/test_helper.exsfile. If you really need to re-use the settings/shortcuts in your.iex.exsfile, you can include it from yourtest_helper.exsfile something like this: