Clojurians
#kaocha
<
2019-01-23
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

plexus01:01:42

can you elaborate a bit @stathissideris?

stathissideris06:01:16

@plexus I have a bunch of spec s/fdefs on my functions, and I’d like to instrument those functions with their specs before running my tests

plexus07:01:57

the hooks plugin is your friend, probably a post-load hook makes sense so you know everything's been loaded/defined

plexus07:01:09

(ns my.app.kaocha-hooks)

(defn post-load [test-plan]
  (clojure.spec.test.alpha/instrument)
  test-plan)
#kaocha/v1
{:plugins [:kaocha.plugin/hooks]
 :kaocha.hooks/post-load [my.app.kaocha-hooks/post-load]}

plexus07:01:13

something along these lines

plexus07:01:46

watch out that you return test-plan from the hook function (this is true of all hooks, always return the first argument)

rickmoynihan13:01:23

Thanks for this. Just seconding that I have this same usecase too, and I suspect it will become increasingly common. Might it be worth adding something like this to the manual?

plexus00:01:26

Absolutely!

rickmoynihan09:01:28

Incidentally how might this work if your app uses something like integrant and ig/load-namespaces. i.e. you have a constructor function in the app that loads the apps namespaces and specs dynamically, rather than using the require tree?

stathissideris07:01:29

Thank you very much, I’ll try it out!

jstaab19:01:07

I'm trying to use kaocha with shadow-cljs, is there a way to get it to recognize installed node modules? I know shadow-cljs does some non-standard things with require; I'm doing (:require ["algebra.js" :as algebra]) and getting No such namespace: algebra.js, could not locate algebra/js.cljs, algebra/js.cljc, or JavaScript source providing "algebra.js" in file /my/project/utils/algebra.cljs