fbeline

fbeline

Copeiro - testing library

After working with Elixir for a few months, I’ve noticed extra efforts by me and my colleagues when writing tests involving lists.
Usually those issues was related to ordering. Sometimes even producing flaky behavior.

With that in mind, I wrote a small library that provides a way to assert lists in an idiomatic way and does not make me feel “weird” about it.

Please, feel free to share your thoughts around the subject :raised_hands:

Most Liked

eksperimental

eksperimental

Just one comment. You don’ t need to require a module if you are importing it.

al2o3cr

al2o3cr

I’ve seen this, but it’s generally been a symptom of code that was relying on Postgres returning rows in insertion order in tests when not using an order_by clause.

IMO the flakiness there indicates a bug, so hiding it by making comparisons order-insensitive wouldn’t be ideal.

fbeline

fbeline

I’ve seen this, but it’s generally been a symptom of code that was relying on Postgres returning rows in insertion order in tests when not using an order_by clause.

Yes, that is exactly the point. In several tests the order does not matter and the insertion order is not the expected one for some runs.

IMO the flakiness there indicates a bug, so hiding it by making comparisons order-insensitive wouldn’t be ideal.

It’s not necessarily a bug in your code. In my experience it’s usually related to a missing “order_by” (in test) as you said.

Also, you should not use a function that checks if it’s a “subset” or ignore order if order is something important to your business rules.

eksperimental

eksperimental

Personally I wouldn’t use in since it is an operator that behaves in a different way. I would use has and has not, but you will have to flip the arguments. Or name it something else.

Where Next?

Popular in Libraries Top

kevinlang
Hey all, We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3! We have successfully on-boarded the full suite of integration tests (...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
mbuhot
Leverage Open Api 3.0 (Swagger) to document, test, validate and explore your Plug and Phoenix APIs. Generate and serve a JSON Open API ...
New
archan937
It is a well-know topic within the Elixir community: “To mock or not to mock? :)” Every alchemist probably has his / her own opinion con...
New
Crowdhailer
I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention. Assuming you have...
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
Jskalc
Hi! Today, after a couple weeks of development I’ve released v0.1 of LiveVue. It’s a seamless integration of Vue and Phoenix LiveView, i...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
versilov
Could not wait for the missing Elixir ML libraries to appear, so, I wrote one myself, taking https://github.com/sdwolfz/exlearn as a foun...
New

Other popular topics Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
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
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Sub Categories:

We're in Beta

About us Mission Statement