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 itmany different paths that will get you there, but what you're suggesting seems entirely reasonable.
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