Fork me on GitHub
#kaocha
<
2023-04-09
>
nottmey18:04:12

Hello, I find it hard to do TDD with kaocha (on --watch). Because, when an exception happens (caused by incomplete implementation not yet matching the previously written test) the whole stack trace is printed and I need to scroll up (a lot) to see what my next implementation step would be. How can I reduce the size of the printed stack or error report to the meaningful first 5-10 lines?

practicalli-johnny07:04:25

I minimise compilation errors (usual source of by writing the function definition that returns nil before saving the test code that calls that function

(defn function-name [& args] nil)
The tests then show which functions need work rather than the compiler

nottmey16:04:57

Yes, I also do that for the parts that are clearly visible, but when it comes to NPEs, missing case clauses, and other similar issues, it’s not as easy to predict in advance. I mean, those are plausible, right? When passing new data with new test case, these things happen.

Alys Brooks19:04:34

We have a PR in progress that would help with this: https://github.com/lambdaisland/kaocha/pull/321. In the meantime, you can try adding filters to :bindings {kaocha.stacktrace/*stacktrace-filters* [,,,]} . By default, the following is filtered out:

(def ^:dynamic *stacktrace-filters*    ["java.lang."                                       "clojure.test$"                                     "clojure.lang."                                     "clojure.core"                                     "clojure.main"                                     "orchestra."                                   "kaocha.monkey_patch"])
Finally, you could also try using io.aviso/pretty to install a more readable printer for stacktraces. I don't think Kaocha would interfere with its stacktrace hook, but I'm not completely sure: https://github.com/AvisoNovate/pretty

👍 2