This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-06
Channels
- # announcements (1)
- # beginners (147)
- # boot (9)
- # calva (28)
- # cider (3)
- # circleci (18)
- # cljdoc (54)
- # cljs-dev (55)
- # cljsrn (22)
- # clojure (179)
- # clojure-canada (9)
- # clojure-dev (74)
- # clojure-europe (1)
- # clojure-italy (15)
- # clojure-nl (7)
- # clojure-spec (30)
- # clojure-uk (55)
- # clojurescript (65)
- # core-async (15)
- # cursive (12)
- # datomic (16)
- # events (4)
- # fulcro (25)
- # graalvm (3)
- # joker (2)
- # kaocha (15)
- # keechma (94)
- # off-topic (12)
- # qlkit (2)
- # re-frame (15)
- # reagent (11)
- # reitit (29)
- # remote-jobs (15)
- # rewrite-clj (16)
- # shadow-cljs (73)
- # spacemacs (151)
- # sql (3)
- # tools-deps (11)
- # unrepl (19)
- # vim (35)
hi all! has anyone successfully used kaocha-cljs
for a cljs
project? I’m in great need of inspiration and help 🙂
I can’t quite understand (my limitation, not Kaocha’s!) how to run cljs tests in my cljs project. Context: I have a cljs app (re-frame, etc.), I would like to run cljs tests of this app in the browser (using Kaocha and I’m guessing browser.repl
). And whatever I do, I cannot get it to work. I think an example or a high level architecture would be enough for me to understand it 🙂 Like, how do I start my app, where do I put the repl/connect
bit (if I need it at all), etc.
Right! Okay. So this is actually a bit relevant to my question here: https://clojurians.slack.com/archives/CCY2V0U6A/p1559847736004000
The idea is that you're going to tell Kaocha everything it needs to know to run your tests in a
tests.edn
file, and then Kaocha is going to handle starting the ClojureScript process in which your tests will run itself.
Here's an example of a tests.edn
file that contains tests: https://github.com/probcomp/metaprob/blob/6cec4215a50db128f17039d8b8005742dd7ddae3/tests.edn
That map I believe needs to have an :id
and a :type
of :kaocha.type/cljs
. Once you've done that you should be able to run your tests with either bin/kaocha
from the shell or with (require '[kaocha.repl :as kaocha]) (kaocha/run)
(assuming you followed the installation instructions in Kaocha's README
). Note that kaocha/run
must be run from a Clojure REPL, not a ClojureScript REPL.
That part - yes 🙂 And thanks for the example. However, you’re using node as your test runtime (I’m guessing from your tests.edn example).
I’m facing issues with running the tests inside a browser though 😞
I know that you can pass browser.repl env to :cljs/repl-env
key and I can see kaocha opening a browser but then I always get an error regarding Client not able to connect back (or something like that).
@countgizmo that error could occur due to any number of reasons. It could be a bug in kaocha-cljs, or it could be something in your app/setup preventing kaocha-cljs from functioning correctly. If you can create a repo that you can share that reproduces the problem then I'm happy to take a look at it. Otherwise gather up as much information as possible and create an issue. You can get more detailed debug output by adding this to your tests.edn
:bindings {kaocha.type.cljs/*debug* true}
@U07FP7QJ0 Thank you! I will continue to dig into it then!
Am I understanding correctly that since Kaocha is only runs on Clojure there's no way to use Kaocha to run ClojureScript tests in the ClojureScript REPL?
@countgizmo that error could occur due to any number of reasons. It could be a bug in kaocha-cljs, or it could be something in your app/setup preventing kaocha-cljs from functioning correctly. If you can create a repo that you can share that reproduces the problem then I'm happy to take a look at it. Otherwise gather up as much information as possible and create an issue. You can get more detailed debug output by adding this to your tests.edn
:bindings {kaocha.type.cljs/*debug* true}