diff --git a/src/devcards/core.cljs b/src/devcards/core.cljs index de33e0e..065b6ef 100644 --- a/src/devcards/core.cljs +++ b/src/devcards/core.cljs @@ -906,6 +906,9 @@ (defonce test-channel (chan)) +;; Used to collect combined results from all currently rendered test suites +(defonce test-results (atom {})) + (defn run-card-tests [test-thunks] (let [out (chan) test-env (assoc (cljs.test/empty-env) @@ -934,13 +937,60 @@ (cljs.test/clear-env!) (recur (> (vals n) + (map :report-counters) + (reduce combine-results {:test 0 :pass 0 :fail 0 :error 0}) + (report-results (vals n))))) (defn test-card-test-run [this tests] (put! test-channel {:tests tests - :callback (fn [results] (.setState - this - #js {:test_results - results}))})) + :callback (fn [results] + (swap! test-results assoc (get-props this :path) results) + (.setState + this + #js {:test_results + results}))})) (define-react-class TestDevcard (componentWillMount @@ -951,6 +1001,9 @@ [this next-props] (when-let [test-thunks (gobj/get next-props (name :test_thunks))] (test-card-test-run this test-thunks))) + (componentWillUnmount + [this] + (swap! test-results dissoc (get-props this :path))) (render [this] (let [test-summary (get-state this :test_results)