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

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 v0.2.10

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

murrgelb

murrgelb

We released some minor updates (currently at version 0.2.6):

  • defeffect can have guards, now
  • defeffect can have catch and rescue in the body defintion
  • we introduced delegateeffect which basically behaves like defdelegate. Delegates can be bound in tests, same as functions defined with defeffect. 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

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 our test_helpers.ex. There is an example in the EfxCase doc.
  • Formatter support
    Formatters recently added braces around defeffect one-liners (e.g. in defeffect foo, do: "hello"). You can now include the library in your formatter config and have the formatter tamed :wink: (see Usage in Readme).

Happy coding!

Where Next?

Popular in Announcing Top

BartOtten
This powerful library works together with Phoenix Router to provide the ultimate routing solution. It simplifies route manipulation, givi...
New
Gigitsu
Hi everyone! I’d like to share a small library I’ve recently extracted from a project I’m working on: ginject. ginject provides a minim...
New
ananthakumaran
An ExUnit formatter to visualize test execution and find bottlenecks in your test suite. I created a small library called ex_unit_spa...
New
halostatue
Enviable is a small collection of functions to make working with environment variables easier when configuring Elixir projects. It is des...
New
yotor_coder
:glowing_star: Looking for Contributors to Join PyraUI Hey everyone :waving_hand: I’ve been working on PyraUI — a modern UI component li...
New
type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
waseigo
DiskSpace Hi everyone, I needed this for a project I’ve been working on, and couldn’t find a simple solution that would work. The solutio...
New
corka149
A JSON patch is a way to define a sequence of manipulating operations on a JavaScript object. The IETF published the RFC 6902 - found he...
New
sodapopcan
I’ve heard that if you’re not embarrassed by v1 of your product Vim plugin then you’ve released too late. I’ve been sitting on this the ...
New
trisolaran
Hi! :waving_hand: I would like to present LiveSelect, a little library that I wrote to easily add a dynamic selection input to your LV f...
194 10054 106
New

Other popular topics Top

JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement