zachallaun

zachallaun

Mneme - Snapshot testing tool for the busy programmer

I’d like to announce Mneme, a snapshot testing tool I’ve been working on.

I’ll keep this post short for now. This has been a lot of fun to work on and I hope that others find it useful! Please feel free to post any comments/feedback here, or issues on GitHub.

First 10 of 65 Posts Switch mode

tcoopman

tcoopman

This looks great! Thanks for the library.

The GitHub link doesn’t seem to work though?

zachallaun

zachallaun OP

Fixed!

mindreframer

mindreframer

@zachallaun this looks great! I’ve tried it and so far this looks promising. I have one question though:
the interactive dots during the test suite run only appear at once after everything is finished. On bigger codebases this would be a no-go, since the immediate test feedback is really important here.
Is there a way to bring this “progress-bar” feeling back?

Also nice that you link to https://insta.rs/ and GitHub - janestreet/ppx_expect: Cram like framework for OCaml · GitHub , the ideas behind those libraries are quite cool!

More links, if anyone is interested:

zachallaun

zachallaun OP

Thank you so much for trying it out and for the question!

To make sure I better understand, are the dots appearing all at the end even when there are no prompts from Mneme? If so, that’s a bug and can/should be fixed. It’s currently expected that nothing will appear during prompting, however, even though async tests are continuing to run in the background — I’m currently suppressing output to prevent garbled terminals during prompting.

One possible solution I explored was a “raw mode” TTY, so that Mneme would have full control over the terminal and get keys on press instead of on-enter. This turns out to be a really tricky problem in Elixir/Erlang, however, though some changes coming with OTP 26 might make it easier in the future.

zachallaun

zachallaun OP

This article and discussion is what got me working on this. :slight_smile: I’ll add an “additional reading” section to the docs with some of this. Thanks for sharing here!

mindreframer

mindreframer

I mean the test run without any prompts, it looks like the process is hanging and then all the dots appear at once.

Raw TTY sounds indeed like a challenging problem, especially with async tests running. I currently do not a good idea how to approach it. Should I open an issue on the repo with a reproducible example?

zachallaun

zachallaun OP

If you have one, that would be great! Thank you!

mindreframer

mindreframer

Hey @zachallaun , here is a small demo:

I run tests in IEx, so I’ve adjusted mneme to restart on Mneme.start() fn call.

zachallaun

zachallaun OP

Thanks so much for the demo! I’ll see what can be done.

zachallaun

zachallaun OP

@mindreframer I’ve just published 0.1.1, which pretty dramatically reduces the performance gap between auto_assert and assert. If you are able to give it a try and let me know what issues persist, I’d greatly appreciate it.

This was most definitely worth pursuing! Your demo made is super clear just how slow auto_assert was compared to normal asserts.

My intuition about compile-time vs. runtime costs was wrong in the context of .exs, since all compile-time costs are incurred every time you run the test. By dramatically simplifying the code that the auto_assert macro produces, an unscientific benchmark of running a test with 100 generated auto-asserts goes from taking ~3 seconds to taking 0.2s (compared to 0.05s for normal asserts).

Where Next?

Trending in Announcing Top

bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
387 14960 120
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

Other Trending Topics Top

type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
bjorng
We want to introduce a new native datatype to Erlang: native records. Although replacing all tuple records with native records is not our...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New

We're in Beta

About us Mission Statement