Fork me on GitHub
Oliver George05:11:41

Can someone please point me at code using tc/quick-check inside deftest. I'm looking for a clean way to wire things up and get nice error reports.

Oliver George09:11:15

One simple pattern is

(deftest t1
  (is (:result (tc/quick-check 100 t1-prop))))
No nice debugging info in report but does at least tell you where it hurts.


defspec is a macro with the same behavior as quick-check and it integrates with clojure.test. Check it:

Oliver George00:11:04

Thanks @U01KQ9EGU79 - I hit some odd things with the shadow-cljs repl but perhaps that's surmountable. Looks spot on.

Oliver George00:11:16

Also, this helper/pattern gives me reasonable debugging info without too much plumbing. (Can't recall where I found it.)

(defn qc-ret
  [{:keys [result] :as data}]
  (if result {:result true} data))

(deftest init-db--gen
  (is (= {:result true} (qc-ret (tc/quick-check 100 init-db--fx-ret)))))


I don't have examples handy but the first place I would look is

Oliver George07:11:12

Fancy! Thanks.

Karl Xaver11:11:38

Newbie question: How do you experiment with/inspect objects like #object[HTMLImageElement [object HTMLImageElement]] #object[CSSStyleDeclaration [object CSSStyleDeclaration]] js->clj doesn't seem to do anything on these. So far I resorted to (js/console.log object) + scrolling/clicking through the browsers console which is a bit tedious. Thanks!


If the browser console is tedious while being as interactive as it is (you can run arbitrary JS code on those objects or their subfields), what kind of workflow would be better?


if you prefix your log-output with a string-token you can use the console´s filtering facilities to include this token and remove all the noise.


Browsers' JS consoles have many tools nowadays. Filtering, grouping, pivoting, evaluation, saving nested objects via context menus, probably other things that I can't recall right now or simply don't know about.

Karl Xaver12:11:44

"Tedious" was a bit of an overstatement :) I just thought there might be something I missed that's more integrated with the repl/editor, so I don't have to 1) wrap my obj in a console.log expr (compared to evaling directly) 2) switch to the browser 3) use the mouse to find/unfold things It's time to give the console some love and learn its keyboard shortcuts. I wasn't aware that it is so powerful. And 1) can be solved with some elisp. Using the string-token tip already. Thanks for the input!


There are also things like but I have no idea how good they are with JS objects. But if you work with CLJ/Java data that you want to inspect, those are great tools.


Anybody using the Cursive plugin and is able to have symbols like .getElementById resolved?


It's an old and known problem: There's also #cursive


Bummer, oh well