We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Exploring Efx Library for Testable Effects in Elixir
193
clicks
Source: katafrakt.me
In this post, Paweł Świątkowski introduces the Efx library, a new tool in the Elixir ecosystem designed for writing testable effects in a declarative manner. He compares Efx to existing Elixir mocking libraries like Mox, Mock, Rewire, Bypass, and Mimic, highlighting the unique advantage of Efx in enabling purity injection. The author demonstrates how to use Efx by converting an order number generator to support effects, replacing impure functions with clean, predictable ones during tests. Through extensive code examples, he shows how to bind function implementations for testing, assert different test cases, and even test against actual database records. Świątkowski concludes by praising the Efx library for promoting good practices such as thinking about side-effects, minimizing impure functions, and encouraging the use of @spec annotations.
Related posts
© HashMerge 2024