I have used the Mox package to create mocks for some modules during test runs. These are mostly modules that make external HTTP requests. So my test_helper.exs
looks now like this (but with multiple mock modules):
ExUnit.start(exclude: [:skip, :external])
Mox.Server.start_link([])
Mox.defmock(HTTPClientMock, for: HTTPClient)
Application.put_env(:my_app, :http_client, HTTPClientMock)
However, I would like to have some tests that actually do make real HTTP requests. Is there a way I can pass an option to bypass the Mox and Application.put_env things so that these special external tests can use the real module instead of the mocks? This is sometimes called “integration tests”. I was hoping that maybe something like this would work:
mix test --no-mocks
But that generates an error:
** (Mix) Could not invoke task "test": 1 error found!
--no-mocks : Unknown option
Maybe what I am trying to do is not a good way. I could write a custom mix task to do the things I want to do in the dev environment, then I would not be fighting against what the test environment wants to do. Does this make sense, what I want to do?