murrgelb
Efx - A library to declaratively write testable effects
Efx is a library to define and test side effects declaratively. It is basically a very focused mocking framework, reducing implementation overhead and focusing on testable code.
The special thing about it is, that it uses the fairly new ancestor-keys from the process dictionary to track down the bindings for tests event for child-processes and therefore, more tests can be implemented asynchronously.
If you are interested, need more rational or just want to skim the code, you can find out more on our github. We are looking forward to some feedback!
https://github.com/bravobike/efx
The library is also available on hex: efx | Hex
Most Liked
murrgelb
We just added some minor features to Efx 0.2.10:
- We love to hotfix our code.
Efxnow allows to paste code directly into your production environment, if needed. Until now this wasn’t possible, because the hard dependency toMix.env. We fixed that. - We fell in love with property based testing, in our case
StreamData. Since uncontrolled and slow side effects are a burden in property based testing,Efxis a obvious choice to bind and control them. However, sinceEfxworks in a process scope andStreamDataexecutes multiple tests in the very same process, binding for each test-case doesn’t work. To enableEfxfor property based testing, we introducedwith_clean_bindings, which can be used in the body of a propery based test to achieve case dependent bindings: EfxCase — Efx v0.2.10
Happy hotfixing, testing and coding!
murrgelb
We just released Efx 1.0.0 ![]()
After some input from the community and minor bug fixes, we thought about our own usage patterns and slightly altered the binding-syntax in a backwards compatible way:
- Bindings are now done using functions captures, e.g.
bind(&MyEffects.write/1, fn _ -> :ok end). Before, we had to name the module as a first argument and pass the function name as an atom as the second. - Using function captures does not only provide hints for the compiler but also is enables auto completion support for most editors.
- Given that syntax we can now cover a very common use case that covers 90% of our tests: Returning a constant from bindings. We can now easily create bindings that return one value constantly:
bind(&MyEffects.write/1, const: :ok).
Happy coding!
ouven
murrgelb
We released some minor updates (currently at version 0.2.6):
defeffectcan have guards, nowdefeffectcan havecatchandrescuein the body defintion- we introduced
delegateeffectwhich basically behaves likedefdelegate. Delegates can be bound in tests, same as functions defined withdefeffect. This is a foundation for combining and reusing effects and effect-modules (tbd).
It’s very awesome to see this library being used and we’re very grateful for the feedback from you!
Happy coding!
murrgelb
We released some new stuff today (Version 0.2.1):
- Setup bindings once for all tests
We call these bindings omnipresent. We define them usually in ourtest_helpers.ex. There is an example in the EfxCase doc. - Formatter support
Formatters recently added braces arounddefeffectone-liners (e.g. indefeffect foo, do: "hello"). You can now include the library in your formatter config and have the formatter tamed
(see Usagein Readme).
Happy coding!







