Test External API Requests
There are many opinions on how to test external requests. Rubyists use mocking (RSpec and Minitest both include mocking capabilities) at the method level or mocking at the HTTP level (VCR) to test external dependencies. Personally, I always reached for VCR because of how simple and powerful it was.
The solution for testing external requests in Elixir is largely the same: mock the function or mock the HTTP request. Personally, I usually mock at the HTTP request level. The best way to do HTTP mocking in Elixir is with the Bypass library, so let’s add that to our project.
Bypass[107] offers a pretty amazing testing capability. Because Elixir is able to spin up multiple applications at once, Bypass takes advantage of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access