Skip to content

Add support for cljs test #65

@zerg000000

Description

@zerg000000

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 ""}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions