Hi, @LauraBeatris!
About:
cannot use ExUnit.Case without starting the ExUnit application
I see you use ExUnit.Case
in your test/support/**_mock.ex
files.
Those files are being compiled before test suite starts running. ExUnit.start()
is declared in test_helpers.ex
If I understand correctly, you use ExUnit.Case
in order to be able to call macros assert
macros in the file. We can do that by simply importing.
So in those test/support/*_mock.ex
files replace use ExUnit.Case
with
import ExUnit.Assertions, only: [assert: 1]
About mocking: seem like you want to “swap” the real Client module with the “mock” in tests. In that case I can’t think of the situation off the top of my head why you would need both - just follow the guide in Mox
docs. So in dev/prod your app will use a real module that uses Tesla and makes request, while in test it would use your Mock and expect
on functions.
Speaking of Mox+Tesla, I’d like to mention that at my workplace we are mocking Tesla Adapter with Mox using using this approach Deprecate Tesla.Mock · Issue #241 · elixir-tesla/tesla · GitHub