gratitude

oyakushev 2025-03-28T12:47:23.834069Z

Many thanks to Nubank for https://github.com/nubank/matcher-combinators! After going through Midje, than fudje, than back to plain clojure.test assertions, I've finally found a library that I enjoy writing tests with. Instead of focusing on inventing yet another "English-like DSL for tests", matcher-combinators focuses on what's really important. I enjoy how simple it is and how seamlessly it integrates with clojure.test. Truly a missing piece for testing.

4
6
โž• 5
๐Ÿ’œ 22
๐Ÿ™‚ 8
borkdude 2025-03-28T13:14:24.405809Z

Yep, also a happy user here!

lread 2025-03-28T13:22:38.602189Z

Ditto! It's one of many clojure libraries I love to use!

adi 2025-03-29T09:10:35.869659Z

TIL! Instant star. Also... For a "validate data" use case, how would matcher-combinators fare v/s spec or schema or malli?

oyakushev 2025-03-29T12:34:43.320799Z

matcher-combinators is much more ad-hoc (compared to spec), and compared to Malli... I don't know, probably Malli can be used for the same purpose too, but I'm not sure if the ergonomics would be the same

adi 2025-03-29T15:25:27.335819Z

Sorry, I was ambiguous... I was wondering about using matcher-combinators instead of malli or schema to validate (say) web app request / responses.

adi 2025-03-29T15:26:53.891589Z

I suppose "matcher-combinators is much more ad-hoc" is still the answer.

flowthing 2025-04-02T09:50:53.492559Z

+1 from me. A very useful tool for writing tests that focus on the thing that's being tested instead of forcing the reader of the test to wade through a ton of boilerplate.

๐Ÿ‘ 1
reefersleep 2025-04-05T07:35:03.861189Z

What's an example of a use case that makes you really happy? I'm interested in this lib, but not quite sold

borkdude 2025-04-05T07:40:45.007809Z

Itโ€™s often difficult to find the differences in expected and actual data in tests, thatโ€™s what Iโ€™m using it primarily for

lread 2025-04-05T11:05:32.487389Z

This is especially true when data structures are larger. And maybe you only want to check a subset of the data.

โ˜๏ธ 1
borkdude 2025-04-05T11:06:38.115929Z

yes. I think clj-kondo is currently the only project I'm really using it it and there I'm comparing nested data in about every test

borkdude 2025-04-05T11:11:15.962529Z

I found out it also works in bb.

bb -Sdeps '{:deps {nubank/matcher-combinators {:mvn/version "3.9.1"}}}' -e "(require '[matcher-combinators.test] '[clojure.test :as t]) (t/is (match? [1 2 3] [1 0 3]))"

FAIL in () (Reflector.java:212)
expected: (match? [1 2 3] [1 0 3])
  actual: [1 (mismatch (expected 2) (actual 0)) 3]
(the location in the warning seems a bit off, but I'll take it)