hey all
i'm using calva for my cljs (shadow-cljs) project
i have a running repl that is connected to the browser app
how can i run tests? can i use the same repl?
when i execute calva: run tests for current namespace i get
; Running tests for the following namespaces:
; my-app-test
; my-app
; No tests found. 😱, ns: 0, vars: 0
but when i execute (run-tests) it works from the same namespace
;
; Testing my-app-test
;
; Ran 1 tests containing 4 assertions.
; 0 failures, 0 errors.Hi! Iirc the Calva test runner does not support ClojureScript, because cider-nrepl doesn’t support it yet. This is very unclear in the Calva UI. What I do is: 1. I use shadow-cljs test runner on auto-run, so every time it reloads code, it also runs tests. 2. I have custom repl commands for running tests. So I run individual tests and tests for a namespace using these custom repl commands. Here are some custom commands I have defined:
"calva.customREPLCommandSnippets": [
...
{
"name": "Call Top Level Defined Symbol",
"snippet": "($top-level-defined-symbol)"
},
{
"name": "Run tests",
"key": "r",
"repl": "cljs",
"snippet": "(require 'clojure.test) (clojure.test/run-tests)"
},
{
"name": "Run all tests",
"key": "t",
"repl": "cljs",
"snippet": "(require 'clojure.test) (clojure.test/run-all-tests)"
},
...
],oh got it thank you!
I really like the shadow-cljs test runner. Here’s a config with the test runner enabled: https://github.com/anteoas/replicant-todomvc/blob/main/shadow-cljs.edn
i'm using the runner but without autorun
and target "karma" instead of node-test
I use karma in some projects too, but lately I have started relying more on node-tests. For that todomvc example all tests can run in the JVM too, yet has almost full test coverage of the UI.