This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-20
Channels
- # announcements (1)
- # babashka (4)
- # beginners (8)
- # cider (4)
- # clj-kondo (10)
- # cljdoc (1)
- # cljsrn (7)
- # clojure (3)
- # clojure-europe (20)
- # clojure-france (3)
- # clojure-sg (2)
- # clojurescript (16)
- # clojureverse-ops (3)
- # community-development (5)
- # core-async (35)
- # cursive (1)
- # datahike (14)
- # datomic (7)
- # events (5)
- # fulcro (59)
- # graphql (11)
- # lsp (33)
- # meander (1)
- # off-topic (33)
- # polylith (23)
- # portal (33)
- # re-frame (1)
- # reagent (10)
- # reclojure (7)
- # reveal (14)
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.
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: https://github.com/clojure/test.check/blob/master/doc/intro.md#clojuretest-integration
Thanks @U01KQ9EGU79 - I hit some odd things with the shadow-cljs repl but perhaps that's surmountable. Looks spot on.
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 http://grep.app
Fancy! Thanks.
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.
"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 https://github.com/djblue/portal 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: https://github.com/cursive-ide/cursive/issues/1252 There's also #cursive