murrgelb

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

cmo

Does this mean there is a minimum version of OTP required?

Most Liked

murrgelb

murrgelb

We just added some minor features to Efx 0.2.10:

  • We love to hotfix our code. Efx now allows to paste code directly into your production environment, if needed. Until now this wasn’t possible, because the hard dependency to Mix.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, Efx is a obvious choice to bind and control them. However, since Efx works in a process scope and StreamData executes multiple tests in the very same process, binding for each test-case doesn’t work. To enable Efx for property based testing, we introduced with_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

murrgelb

We just released Efx 1.0.0 :partying_face:

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

ouven

It is a mocking library, that doesn‘t need global binding for your test cases. So all mocking and preparation happens directly in your test code. No need for configs or anything else.

I started using it in my projects and it makes testing clearer and easier.

Kudos to @murrgelb

Last Post!

filonenko_g

filonenko_g

Hi, now it works great, thank you very much!
As for:

config :efx, :binding_enabled, true

this should also work for us.

Where Next?

Popular in Announcing Top

wmnnd
Hi there, for my project DBLSQD, I needed a file storage solution that is a bit more flexible than Arc. Because I thought others might f...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 30486 241
New
sasajuric
I’d like to announce a small library called boundaries. This is an experimental project which explores the idea of enforcing boundaries ...
New
oltarasenko
Dear Elixir community, After a year of development, bug fixes, and improvements, we are proudly ready to share the release of Crawly 0.1...
New
benlime
LiveMotion enables high performance animations declared on the server and run on the client. As a follow up to my previous thread A libr...
New
type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New

Other popular topics Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31586 112
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement