what's the current best choice for running clojurescript tests in CI (leiningen + shadow-cljs)? Karma is deprecated, so I'd rather not use it. At first I thought using shadow-cljs to create tests for node.js would be great, but a lot of our code refers to various js/foo variables which are only available in a browser environment (as far as I understand). There's a bunch of js test frameworks (jest, vitest etc) but it seems I can't just write clojure.test tests but instead have to use their own API's for tests.
I have this exact issue, where I have a library written in cljc and Iβd like to target both JVM and node for the tests to be 100% sure of the results when targeting cljs
I found this example from tick. They write their tests in cljc and run them with Kaocha.cljs for clojurescript. They even run them for babashka https://github.com/juxt/tick/blob/master/test/tick/api_test.cljc https://github.com/juxt/tick/blob/master/.github/workflows/tests.yaml
I'm just using vitest browser mode. It is good Karma Alternative.
But as you mentioned, It's not compatible with clojure.test
So we have to use decribe, test, promise etc... I think we can make vitest compatible plugin someday.
Ideally I'd like to be able to write at least some of the tests with clojure.test in .cljc and run them both on the JVM and on a js environment
e.g. to check that calculations or domain functions work in both environments, not really looking for something for testing DOM stuff
Oh. It makes sense.
I think there is "puppeteer with cljs test setup" something, somewhere...
I guess in the short term I can move forward with testing with node.js, as long as I make sure that any references to js/.. fields are either moved elsewhere or wrapped in exists? checks (which seems to fix any ReferenceError issues). As I said, most of the code I'd like to check is just business logic so it shouldn't depend on some browser feature anyways. But still, I'd love to hear what other folks are doing in similar situations
wrote up an Ask about a feature that I think would be helpful for test library writers in the future. i'm interested to hear any feedback on the idea: https://ask.clojure.org/index.php/14089/separate-bindable-reporting-function-from-clojure-report
@cfleming would this be helpful for Cursive? i know you've said you have to monkeypatch/work around clojure.test's reporting system before
@lee that's a great change to testing, i wish that's how testing worked already
Ha! I just https://github.com/clj-commons/etaoin/commit/b8d8d0ef2ccae3b694db9a508e2b936adbbacb5e#diff-bf0d474829aa7b5291f19444c04670bc8f8289155f9f33f13b973449d1340d01! <-- if you are collecting samples, another for your collection!
Thanks @nbtheduke, I'll read through that in detail and try to get my head around it - looks like some interesting links there to investigate too.