kaocha

nottmey 2023-04-09T18:49:12.778299Z

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-johnny 2023-04-10T07:47:25.368199Z

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

nottmey 2023-04-10T16:31:57.829559Z

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 Brooks 2023-04-14T19:04:34.295479Z

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

๐Ÿ‘ 1