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.
Yep, also a happy user here!
Ditto! It's one of many clojure libraries I love to use!
TIL! Instant star. Also... For a "validate data" use case, how would matcher-combinators fare v/s spec or schema or malli?
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
Sorry, I was ambiguous... I was wondering about using matcher-combinators instead of malli or schema to validate (say) web app request / responses.
I suppose "matcher-combinators is much more ad-hoc" is still the answer.
+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.
What's an example of a use case that makes you really happy? I'm interested in this lib, but not quite sold
Itโs often difficult to find the differences in expected and actual data in tests, thatโs what Iโm using it primarily for
This is especially true when data structures are larger. And maybe you only want to check a subset of the data.
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
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)