View Source Testing
There are two primary ways to mock requests in Tesla:
- Using
Mox
- Using
Tesla.Mock
(deprecated)
You can also create a custom mock adapter if needed. For more information about adapters, refer to the Adapter Guide to create your own.
Should I Use Mox
or Tesla.Mock
?
We recommend using Mox
for mocking requests in tests because it
is well-established in the Elixir community and provides robust features for
concurrent testing. While Tesla.Mock
offers useful capabilities, it may be
removed in future releases. Consider using Mox
to ensure long-term
compatibility.
For additional context, see GitHub Issue #241.