Fork me on GitHub
#kaocha
<
2018-11-26
>
borkdude09:11:16

Does kaocha support running some expressions before the tests start? Specifically, I would use this to call clojure.spec.test.alpha/instrument to instrument some vars for all tests

borkdude09:11:49

Should work with clojure + clojurescript (with advanced compilation)

miikka14:11:50

Just came here to ask the same thing. I see the changelog says Function specs are now checked with orchestra + expound – not sure if this means Kaocha's specs or the specs in the system under test.

miikka14:11:13

I suppose it would be easy enough to write a plugin that does this for Clojure.

borkdude15:11:41

@miikka I guess those are fns that kaocha itself uses. Instrumentation of user fns should always be a choice.

plexus15:11:14

Kaocha runs orchestra/instrument by default before doing a test run

miikka15:11:46

So before loading the test code?

plexus15:11:46

For global pre/post actions yes the recommendation is to use a plugin

plexus15:11:55

yes, before loading the test code

borkdude15:11:39

I guess this doesn’t have an effect on user specs, since those are not loaded at this point: https://github.com/lambdaisland/kaocha/blob/bd185bff9d4d6e97bc4af9bca0987c6b8e59e098/src/kaocha/runner.clj#L20

plexus15:11:56

ah yes, I guess you're right

borkdude15:11:58

which is good, imho

borkdude15:11:14

because instrumenting tests should be a choice, it can have negative effects

borkdude15:11:47

but a plugin would be ok, thanks. does kaocha also support clojurescript?

plexus15:11:08

ClojureScript support is not yet there, I've started on it but it's still gonna be a good bit of work

plexus15:11:50

that said I do aim to have at least a first working version before the Clojurists Together funding runs out, hopefully I'll have something to show earlier e.g. by the end of the year

borkdude15:11:00

right now I’m fine with cljs-test-runner (a similar thing like clj-test-runner from cognitect, which is really minimal), but just wondering, since those do not have the option to “plugin”, now I have to workaround by relying on the alphabetical ordering of namespaces…

borkdude15:11:33

which is bad… good luck 🙂

plexus15:11:44

your plugin will roughly look like this

plexus15:11:47

(ns my.app.kaocha-hooks
  (:require [kaocha.plugin :refer [defplugin]]))

(defplugin 
  (pre-run [test-plan]
    ;; do your thing
    (... instrument ...)

    ;; make sure to return the argument
    test-plan))


;; bin/kaocha --plugin 

;; {:plugins [:]}

borkdude15:11:27

cool! I would be happy to give it a try once cljs support lands!

👍 4
borkdude15:11:16

if you’re looking for a test case for clj+cljs: https://github.com/borkdude/advent-of-spec

borkdude15:11:38

it’s entirely written in .cljc