duct
duct copied to clipboard
Add support for cljs test
Currently seems no ways to run cljs test or trigger cljs test from repl. Here is my first attempt to add cljs to duct. Any thoughts on this topic? one drawback is the cljs need to compile using (reset)
before cljs-test
project.clj
...
:profiles {
:project/dev { ...
:dependencies [...
[doo "0.1.7"]]}
}
...
dev/resources/dev.edn
{:duct.core/environment :development
:duct.core/include ["ns-project/config"]
:duct.server/figwheel
{:builds [...
{:id "test"
:source-paths ["src" "test"]
:build-options
{:main ns-test.runner
:output-to "target/out/test.js"
:optimizations :none
:process-shim false}}]}}
dev/src/dev.clj
...
(defn cljs-test []
(let [doo-opts {:paths {:phantom "phantomjs --web-security=false"}}
compiler-opts {:main 'ns-test.runner
:output-to "target/out/test.js"
:optimizations :none
:process-shim false}]
(doo/run-script :phantom compiler-opts doo-opts)))
...
test/ns-test/runner.cljs
(ns ns-project.runner
(:require [doo.runner :refer-macros [doo-tests]]
[ns-project.text-test]))
(doo-tests 'ns-project.text-test)
REPL
=> (reset) (cljs-test)
...
=> :resumed
Testing ns-project.text-test
Ran 3 tests containing 4 assertions.
0 failures, 0 errors.
=> {:exit 0, :out "Testing ns-project.text-testRan 3 tests containing 4 assertions.0 failures, 0 errors.", :err ""}