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
First Post!
cmo
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 v1.0.1
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!
Last Post!
filonenko_g
Hi, now it works great, thank you very much!
As for:
config :efx, :binding_enabled, true
this should also work for us.
Popular in Announcing
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









