Hi! 😊
I'm in the process of switching over to Kaocha, and it's mostly been a joy! But I've run into one problem I can't figure out:
I have a function that wraps clojure.spec.alpha/explain-data and I have a function that tests that it massages the output from spec in the expected way when something fails a spec checked with this function.
In the test, I'm just parsing the error message and comparing it to the expected message string, "nil - failed: string"?. This works just fine when running the test in CIDER and with lein test.
When running the test with Kaocha, however, I get:
Expected:
"nil - failed: string?"
Actual:
-"nil - failed: string?"
+"-- Spec failed --------------------\n\n nil\n\nshould satisfy\n\n string?\n\n-------------------------\nDetected 1 error"
1 tests, 2 assertions, 1 failures.
So I looked up the "Spec failed ... should satisfy ..." part in the Kaocha code base, and it looks like it might come https://cljdoc.org/d/lambdaisland/kaocha/1.91.1392/doc/orchestra-spec-instrumentation-?
Is there any way to turn this off, or have I perhaps inadvertently switched it on? I want to keep the existing behaviour of the test runner, so that I get the same result running the tests in CIDER as I do with Kaocha.
Here's my tests.edn file:
#kaocha/v1
{:tests [{:id :unit
:test-paths ["test"]
:ns-patterns [".*"]}]
:plugins [:kaocha.plugin/junit-xml
:kaocha.plugin/profiling
:kaocha.plugin/capture-output
:kaocha-retry.plugin/retry]
:kaocha.plugin.profiling/profiling? false
:kaocha.plugin.junit-xml/omit-system-out? true
:kaocha.plugin.capture-output/capture-output? false}Ah, we're using orchestra elsewhere in the project and it looks like Kaocha might be loading all/other test namespaces even when running lein kaocha --focus my.ns, is that right?
(Where kaocha is an alias for with-profile +kaocha run -m kaocha.runner and the kaocha profile is:
:kaocha {:dependencies [[lambdaisland/kaocha "1.91.1392"]
[lambdaisland/kaocha-junit-xml "1.17.101"]
[kaocha-retry "0.4.0"]]}
)
In any case, I can't figure out how to turn instrumentation off for this test so it passes as expected, but perhaps that is more related to Orchestra than to Kaocha?I set up a minimal project without any other uses of orchestrate and could reproduce. Please let me know if this'd be useful to see and I can create a repo and share the link! 😊
Aha, a colleague figured it out!
It's from kaocha.runner/-main* where clojure.spec.alpha/*explain-out* is bound to expound.alpha/printer.
Overwriting this with our own binding in our test solved it!