# Microlibrary for testing with expectations

**URL:** <https://ziggit.dev/t/microlibrary-for-testing-with-expectations/1115>\
**Category:** Showcase\
**Created:** [July 9, 2023, 12:12pm UTC](https://ziggit.dev/t/microlibrary-for-testing-with-expectations/1115 "2023-07-09T12:12:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![matklad](https://ziggit.dev/user_avatar/ziggit.dev/matklad/32/2462_2.png) [@matklad](https://ziggit.dev/u/matklad)\
**Post date:** [July 9, 2023, 12:12pm UTC](https://ziggit.dev/t/microlibrary-for-testing-with-expectations/1115/1 "2023-07-09T12:12:01Z")

</div>

Last week, this great post was making rounds on HN & lobste.rs:

> **[My Kind of REPL](https://ianthehenry.com/posts/my-kind-of-repl/)**
>
> I want to tell you about an idea that has had a huge influence on the way that I write software. And I mean that in the literal sense: it’s changed the way that I write software; it’s re-shaped my development workflow.
> The idea is this: you can write...

It describes “Testing With Expectations”, also known as “Snapshot Testing” — a powerful “thinking outside of the box” technique for writing unit-tests which suck less.

Coincidentally, I’ve implemented a tiny variation of the idea for TigerBeetle:

> <https://github.com/tigerbeetle/tigerbeetle/blob/a0aa383ddbf06a487393d3bb87f3d9edb63a79ff/src/testing/snaptest.zig>

I don’t intend to publish this as a proper library at this point, but feel free to take a look and steal the pattern for your projects, it’s very simple!

---

<div class="post-metadata">

**Author:** ![kristoff](https://ziggit.dev/user_avatar/ziggit.dev/kristoff/32/9_2.png) [@kristoff](https://ziggit.dev/u/kristoff)\
**Post date:** [July 9, 2023, 1:18pm UTC](https://ziggit.dev/t/microlibrary-for-testing-with-expectations/1115/2 "2023-07-09T13:18:28Z")

</div>

that’s a very neat idea
