Testing a controller that makes outside api calls

My first stab was to use Application config to allow a url override, which I set at runtime in tests. Then (duh!) I realised this messed up async tests.

Any reason why you can’t configure the url globally in config/test.exs ? If there is no reason, then that’s the easiest place to configure it, and tests should be able to run in async mode. If you can’t, then you’ll have to disable async for those tests or resort to the fancier solution suggested in the thread: Bypass and async tests with ex_unit - #9 by josevalim. (I never tried it out, btw)

1 Like