I have started adding end-to-end tests to my Phoenix application, using Wallaby, and I am not sure how to access sent emails from these tests. Swoosh.TestAssertions says the assertions and the Test
Swoosh adapter will not work in E2E tests, and that you should use the Local
adapter for such tests.
So it seems I need to use a different Swoosh adapter for my E2E tests and unit tests, and as far as I can tell, that would require running the E2E tests in a different Mix environment, but the test
mix task really does not like being run in a different environment.
** (Mix) "mix test" is running in the "browser_test" environment. If you are running tests from within another command, you can either:
1. set MIX_ENV explicitly:
MIX_ENV=test mix test.another
2. set the :preferred_envs for "def cli" in your mix.exs:
def cli do
[preferred_envs: ["test.another": :test]]
end
I did find another thread where someone managed to work around this, but it sounds like they were trying to do this for different reasons, and this feels like fighting against your tools, so I want to ask whether there’s a cleaner to have different test configs in the same environment.