kaocha

Official support channel: https://clojureverse.org/c/projects/kaocha
2021-02-12T11:21:25.039Z

hi, i currently have some clojure.test code that looks like this

(defn with-screenshots [test-fn]
  (with-redefs [clojure.test/do-report take-screenshot-and-report]
    (test-fn)))
this is part of some fixtures i use only for my browser tests (which i run from the repl as well as from CLI) what would be the equivalent way of achieving this in kaocha? i think i could write a reporter that would take the screenshot when required, but how would i ensure it is only used on my browser tests? my current idea is that it would look a bit like this:
(def ^:dynamic *enable-screenshots* false)

(defmethod screenshot :kaocha/fail-type [m]
  (when *enable-screenshots*
    (take-screenshot)))

(defn with-screenshots [test-fn]
  (binding [*enable-screenshots* true]
    (test-fn)))
and then put my screenshot reporter in my tests.edn for all tests, knowing that only tests using the with-screenshots fixture would enable it

plexus 2021-02-12T15:32:58.039700Z

many different paths that will get you there, but what you're suggesting seems entirely reasonable.

2021-02-12T16:56:41.040Z

cool thank you. i saw i had options in plugins, hooks and reporters, but what i couldn't find was the ability to dynamically turn them on or off from within code