lambdaisland / lambdaisland/kaocha-cljs2
How to enable watch mode for recompiling cljs tests after files change?
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 34
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
Hello. I'm not sure i'm understanding how kaocha-cljs2 is supposed to work. I'm writing some ClojureScript library code, so it doesn't need a browser to run tests. I've managed to make a setup that builds a test bundle with shadow-cljs, with :target :node-test, adding the chui-runtime and setting autorun. So when I compile it, it opens a websocket with funnel, and start listening to run tests on demand from kaocha runtime. But I can't find a way of forcing the bundle to be recompiled when some source file changes.
Here is my configuration in shadow-cljs.edn:
{...
:builds
{:test
{:target :node-test
:ns-regexp "^mylib-tests.*-test$"
:output-to "target/tests.cjs"
:output-dir "target/tests/"
:test-dir "target/tests" del wp y el tríptico? del wp y el tríptico? del wp y el tríptico?
:autorun true
:runner-ns kaocha.cljs2.shadow-runner
:main kaocha.cljs2.shadow-runner/start
:preloads [lambdaisland.chui.remote]}}}
I run the build with
clojure -M:dev:shadow-cljs-kaocha compile test
with this alias in deps.edn:
{...
:aliases
{:dev
{...
:shadow-cljs-kaocha
{:main-opts ["-m" "shadow.cljs.devtools.cli"]
:extra-deps {lambdaisland/kaocha-cljs2 {:mvn/version "0.2.72"}
lambdaisland/chui {:mvn/version "1.2.205"}}}}}
And then I start kaocha this way:
clojure -M:dev:test --watch
Also with an alias:
{...
:aliases
{:dev
{...
:test
{:main-opts ["-m" "kaocha.runner"]
:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}
lambdaisland/kaocha-cljs2 {:mvn/version "0.2.72"}}}
When shadow-cljs is run, it correctly compiles the build, load tests and opens a web socket:
$ clojure -M:dev:shadow-cljs-kaocha compile test
[:test] Compiling ...
========= Running Tests =======================
[lambdaisland.funnel-client] {:connecting "ws://localhost:44220", :line 54}
[goog.net.WebSocket] "Opening the WebSocket on ws://localhost:44220"
[kaocha.cljs2.shadow-runner] {:lambdaisland.chui/capture-test-data! {frontend-tests.util-simple-math-test {:name frontend-tests.util-simple-math-test, :meta {:
file "frontend_tests/util_simple_math_test.cljs", :line 7, :column 5, :end-line 7, :end-column 41},
...
And then I can launch kaocha runner and execute tests. And if I add --watch mode, it runs the tests again if sources change, but because shadow-cljs does not trigger, the build does not change and the executed tests are the same of the previous run, I can't see the changes.
Is there any way to tell chui to watch the source files? Or to relaunch shadow-cljs on changes?
Or is there a different, better way to do all of this? Thanks.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the setup from shadow-cljs.edn and deps.edn using the documented compile and Kaocha --watch commands. Start by examining the kaocha.cljs2.shadow-runner entry points and how shadow-cljs receives source changes. Done means source edits trigger recompilation and Kaocha executes the updated tests.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100