In a recent Elixir project that I had started with mix new
, I struggled with adding utility functions for tests. I had added a module with a couple functions to help me compare the contents of some strings, but I couldn’t seem to import and use the functions. The error message I was getting suggested the functions did not exist.
In a Phoenix project, you can just add new files to lib/test/support
. This is because the mix.exs
file has the line:
defp elixirc_paths(:test), do: ["lib", "test/support"]
For my project, I just added the following line to mix.exs
:
defp elixirc_paths(:test), do: ["lib", "test/utils"]