Kaocha is not able to dynamically add directories to the classpath in such a way that ClojureScript “sees” them, so I’m your project.clj you’ll have to add src/test/clj to :test-paths or :source-paths.
Ah, I see, thanks. It does seem weird that CLJS needs source directories on the classpath, especially when CLJ doesn’t. I guess I still have more to learn about how the CLJS compiler works.
On to my second question. My :unit-cljs test now works, but if I add :focus [my-ns.core-test] to the :unit-cljs clause Kaocha does not run the test. The :unit test works fine with or without the same :focus setting. Any thoughts on this one?
This will show you all the identifiers of the tests you have.
This is a shortcoming of kaocha-cljs. We add the directories you put in tests.edn to the classpath at runtime, but somehow ClojureScript doesn’t pick that up. I haven’t had a chance to look into that, I’m sure it’s fixable, but someone needs to investigate how exactly ClojureScript does its lookup. It might be looking at a different ClassLoader than the one we’re modifying.
Perfect. Changing it to :focus [cljs:my-ns/core-test] does the trick.
One last question, though not directly to do with Kaocha. Running my CLJS unit tests with a Node back-end fails when it runs across something that touches a browser API, e.g. the DOM or xmlhttprequest. I think I can fix that by installing global-jsdom with npm and running something like (js/require "global-jsdom") before my tests. Would a pre-load hook be the best place to run that code?
Yeah, I suppose you’re right. A headless browser would be better. As far as I could see, Kaocha just uses CLJS to start the REPL, which in turn just uses the default configured browser for the system. Is there a way to configure this?