Run CLJS tests in nashorn using cljs.test report hooks.
Run CLJS tests in nashorn using cljs.test report hooks.
nashtest has two primary goals;
Happy to accept PR’s if people want to provide shims.
Single execution is intended for use in CI or as a precommit verification. If there are test failures the exit code will be 1, if all is green it will be 0.
$ lein nashtest
Testing jbx.events-test
Ran 1 tests containing 12 assertions.
0 failures, 0 errors.
Watch loop execution is intended for continuous feedback during development. A change to the :load-js file will result in automatic execution of the whole test suite.
$ lein nashtest watch
Watching for changes to test.js
Testing jbx.events-test
Ran 1 tests containing 12 assertions.
0 failures, 0 errors.
1) Add the plugin to your leiningen project.clj
file.
:plugins [[lein-nashtest "0.1.3"]]
2) Configure your cljsbuild test target in project.clj
.
:cljsbuild [{:id "test"
:source-paths ["src/cljs" "src/cljc" "test/cljs"]
:figwheel true
:compiler {:language-in :ecmascript5-strict
:language-out :ecmascript5-strict
:optimizations :whitespace
:main jbx.runner
:asset-path "js/test"
:output-to "target/cljsbuild/public/js/test.js"
:cache-analysis true}]
Note: Whitespace optimisation is required because document.write().
3) Create a cljs.test runner.
(ns jbx.runner
(:require
[cljs.test :as t :include-macros true]
[jbx.events-test]))
(defn ^:export run
[]
(enable-console-print!)
(t/run-all-tests #"jbx.*-test"))
Note: nashtest uses :test-main or :runner and will call your exported function as part of the test cycle. Do not include a call to the function at the bottom of your runner file.
4) Configure nashtest with a root key in project.clj
.
:nashtest {:load-js "test.js"
:test-main "jbx.runner/run"}