2016-05-01 11:45:37 +00:00
|
|
|
(ns reagenttest.runtests
|
2015-02-10 13:18:56 +00:00
|
|
|
(:require [reagenttest.testreagent]
|
|
|
|
[reagenttest.testcursor]
|
|
|
|
[reagenttest.testratom]
|
2015-09-12 16:34:10 +00:00
|
|
|
[reagenttest.testratomasync]
|
2015-09-19 17:03:29 +00:00
|
|
|
[reagenttest.testtrack]
|
2015-09-23 15:02:48 +00:00
|
|
|
[reagenttest.testwithlet]
|
2015-02-10 13:18:56 +00:00
|
|
|
[reagenttest.testwrap]
|
2018-04-27 20:17:25 +00:00
|
|
|
[reagent.impl.template-test]
|
2018-12-03 22:10:19 +00:00
|
|
|
[reagent.impl.util-test]
|
2017-11-28 15:12:29 +00:00
|
|
|
[cljs.test :as test]
|
|
|
|
[doo.runner :as doo :include-macros true]
|
2015-07-31 13:13:27 +00:00
|
|
|
[reagent.core :as r]
|
2018-04-16 17:50:32 +00:00
|
|
|
[reagent.debug :refer [dbg log]]))
|
2015-01-31 22:09:42 +00:00
|
|
|
|
2014-11-29 22:47:57 +00:00
|
|
|
(enable-console-print!)
|
2013-12-16 22:19:36 +00:00
|
|
|
|
2015-07-31 13:13:27 +00:00
|
|
|
(def test-results (r/atom nil))
|
2013-12-16 22:19:36 +00:00
|
|
|
|
2015-02-10 17:20:48 +00:00
|
|
|
(def test-box-style {:position 'absolute
|
|
|
|
:margin-left -35
|
|
|
|
:color :#aaa})
|
|
|
|
|
|
|
|
(defn all-tests []
|
2018-04-27 20:17:25 +00:00
|
|
|
(test/run-all-tests #"(reagenttest\.test.*|reagent\..*-test)"))
|
2015-02-10 17:20:48 +00:00
|
|
|
|
2015-02-10 13:18:56 +00:00
|
|
|
(defmethod test/report [::test/default :summary] [m]
|
|
|
|
;; ClojureScript 2814 doesn't return anything from run-tests
|
|
|
|
(reset! test-results m)
|
|
|
|
(println "\nRan" (:test m) "tests containing"
|
|
|
|
(+ (:pass m) (:fail m) (:error m)) "assertions.")
|
|
|
|
(println (:fail m) "failures," (:error m) "errors."))
|
|
|
|
|
2016-04-29 11:17:54 +00:00
|
|
|
(defn run-tests []
|
|
|
|
(reset! test-results nil)
|
|
|
|
(if r/is-client
|
|
|
|
(js/setTimeout all-tests 100)
|
|
|
|
(all-tests)))
|
|
|
|
|
2014-01-06 18:16:53 +00:00
|
|
|
(defn test-output-mini []
|
|
|
|
(let [res @test-results]
|
2016-04-29 11:17:54 +00:00
|
|
|
[:div {:style test-box-style
|
|
|
|
:on-click run-tests}
|
2015-02-10 17:20:48 +00:00
|
|
|
(if res
|
|
|
|
(if (zero? (+ (:fail res) (:error res)))
|
|
|
|
"All tests ok"
|
|
|
|
[:span "Test failure: "
|
|
|
|
(:fail res) " failures, " (:error res) " errors."])
|
|
|
|
"testing")]))
|
|
|
|
|
2015-03-21 12:53:37 +00:00
|
|
|
(defn init! []
|
2017-10-18 11:25:41 +00:00
|
|
|
;; This function is only used when running tests from the demo app.
|
|
|
|
;; Which is why exit-point is set manually.
|
2015-03-21 12:53:37 +00:00
|
|
|
(when (some? (test/deftest empty-test))
|
2017-10-18 11:25:41 +00:00
|
|
|
(doo/set-exit-point! (fn [success?] nil))
|
|
|
|
(run-tests)
|
|
|
|
[#'test-output-mini]))
|
2015-03-21 12:53:37 +00:00
|
|
|
|
2018-04-27 20:17:25 +00:00
|
|
|
(doo/doo-all-tests #"(reagenttest\.test.*|reagent\..*-test)")
|