What's the testing story for shadow-cljs like nowadays? I noticed that karma is deprecated and I'm not sure what to do/use to run tests both during dev (like the :browser-test target) and on CI
I don't really consider it a concern for shadow-cljs. shadow-cljs just builds the stuff, something else runs the actual tests. The testing targets where only really meant to show how stuff works. I have no time or interest to maintain actual test frameworks.
pick a testing tool/framework and I can make suggestions on how shadow-cljs could produce output usable by it
The old JS project in the org uses vitest so I'd prefer to use that unless prohibitively complicated
should be fine. probably best to use the :esm-files target. so {:target :esm-files :output-dir "out" :ns-regexp "-tests$"}
possibly with :js-options {:js-provider :import} in case vitest also builds stuff? not really sure
I saw some prior art like https://github.com/mkarp/shadow-vitest but it looked like the clojure.test stuff would need to be rewritten for vitest. I don't see how would the browser-test target work then?
🤷
I have never executed vitest, so absolutely no clue what it does. I'd assume it does the same as :browser-test so dunno why you'd need two different builds?
What do you usually use to run tests?
I don't usually test UI code, so all the tests that I do have in CLJ (if cljc) or node
I'm not a testing enthusiast, so there aren't that many tests actually
We have a test build like this:
:test
{:target :node-test
:output-to "target/test.js"
:ns-regexp ".*test$"}
And a script like this:
#!/bin/bash
echo "==================="
echo "Testing Debug Build"
npx shadow-cljs compile test && node target/test.js
echo "====================="
echo "Testing Release Build"
npx shadow-cljs release test && node target/test.jsAnd it's great. 🙂
Does the :source-map true compiler option get ignored for :release builds?
I have a config like below
:builds
{:vitest
{:target :esm-files
:js-options {:js-provider :import}
:modules {:main {}}
:release {:compiler-options {:source-map true}}
:ns-regexp "-test$"
:output-dir "target/vitest"}}
but shadow-cljs compile vitest doesn't seem to generate any .map files
Am I missing something?Never mind the files seem to be in position I was just looking at the wrong location
FWIW you can skip the :release part, just :compiler-options {:source-map true}. Also :esm-files does not take a :modules option, so it doesn't do anything there