Fork me on GitHub
#testing
<
2023-02-06
>
Gabriele Lippi14:02:39

Hi all, I hope that this is the right place to ask, in case is not, please excuse me 🙏😅 I was wondering if anyone knows if is there any open source code relative to UI of tests that one can see when running test in frontend clojurescript project like this one in the picture. Because I'd like to see if it's possible to improve a bit the part with the diff between the expected and the actual code. Thanks!

nenadalm14:02:40

you can make the diff nicer using humane-test-output as described here: https://github.com/bhauman/cljs-test-display/issues/5#issuecomment-619090019

mauricio.szabo18:02:20

Honestly, I would suggest you to try some libraries. I never actually use clojure.test's default matching

mauricio.szabo18:02:49

One option is to use Nubank's Matcher Combinators. It works really well honestly for this kind of stuff

mauricio.szabo18:02:22

I actually have a test library called check that builds on it, because matcher combinators doesn't really work with async tests in ClojureScript

Gabriele Lippi12:02:29

interesting, I'll look into it. Thanks 🙂

Phillip Mates14:02:51

heads up that matcher-combinators is awaiting a patch to make it work better with cljs browser tests: https://github.com/nubank/matcher-combinators/pull/189 I'm hoping the maintainers merge+deploy it soon

Phillip Mates14:02:43

(and you'll want to disable color output to get things to render correctly as mentioned in that PRs description)

lassemaatta16:02:04

Matcher combinators is nice, but it has some performance caveats. If I recall correctly, even a smallish collection mismatch may cause a massive calculation as it tries to calculate the minimum diff between the actual and expected values.

Phillip Mates16:02:14

yes, the in-any-order matcher can lead to really slow performance (for the sake of minimal mismatch info)

mauricio.szabo14:02:09

I had this problem with matcher combinators twice. And I use it everywhere, so it's not as bad as it seems. In one of the cases, I had a 200mb JSON payload that I wanted to match, so I think this one doesn't count :rolling_on_the_floor_laughing: