1

Trying to setup basic unit testing with clojurescript. Looked at:

https://github.com/clojure/clojurescript/wiki/Testing

In my project.clj file I have:

:cljsbuild {
            :builds [{:id "dev"
                      :source-paths ["src" "test"]
                      :figwheel { :on-jsload "my-proj.core/on-js-reload" }
                      :compiler {:main figreag.router
                                 :asset-path "js/compiled/out"
                                 :output-to "resources/public/js/compiled/my_proj.js"
                                 :output-dir "resources/public/js/compiled/out"
                                 :source-map-timestamp true }}

The main point is I add "test" into the :source-paths.

Then in: test/my-proj/tests.cljs I have:

(ns  ^:figwheel-always my-proj.tests
(deftest all-tests
  (run-tests 'my-proj.core-test)
  (run-tests 'my-proj.util-test))

Then in my REPL I do (run-tests). Is this the idiomatic way? I am also using figwheel too, obviously.

Alex Miller
  • 69,183
  • 25
  • 122
  • 167
ftravers
  • 3,809
  • 3
  • 37
  • 38
  • This has the problem that edits to tests aren't cleanly picked up by the REPL. Which kills tight iterations. Likely have to kill REPL, do a `lein clean`, then restart the REPL for test changes to get picked up. NOT FUN! :) Redefining a test function is OK, but removing test functions doesn't work unless you unload the namespace. – ftravers Sep 25 '15 at 19:47
  • 1
    Looks ok to me. Although you could also use `on-js-reload` callback to `(run-tests)` , right? – skrat Sep 29 '15 at 11:17

0 Answers0