testing

Gabriele Lippi 2023-02-06T14:45:39.405699Z

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!

nenadalm 2023-02-06T14:58:40.980939Z

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

Gabriele Lippi 2023-02-06T15:06:56.087459Z

thanks!

mauricio.szabo 2023-02-06T18:46:20.678529Z

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

mauricio.szabo 2023-02-06T18:46:49.169759Z

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

mauricio.szabo 2023-02-06T18:47:22.490029Z

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 Lippi 2023-02-07T12:32:29.626599Z

interesting, I'll look into it. Thanks 🙂

Phillip Mates 2023-02-07T14:04:51.811569Z

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 Mates 2023-02-07T14:05:43.157319Z

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

lassemaatta 2023-02-07T16:17:04.883879Z

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 Mates 2023-02-07T16:18:14.317429Z

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

mauricio.szabo 2023-02-08T14:58:09.742679Z

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 🤣