Skip to content

Commit

Permalink
use cljs-test-display for :browser-test
Browse files Browse the repository at this point in the history
fixes #406
  • Loading branch information
thheller committed Dec 4, 2018
1 parent 40b2d0f commit 81ee576
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion out/demo-test-browser/index.html
@@ -1,2 +1,2 @@
<!DOCTYPE html>
<html><head><title>shadow.test.browser</title><body><pre id="log"></pre><script src="/js/test.js"></script><script>shadow.test.browser.init();</script></body></head></html>
<html><head><title>shadow.test.browser</title><body><script src="/js/test.js"></script><script>shadow.test.browser.init();</script></body></head></html>
2 changes: 2 additions & 0 deletions project.clj
Expand Up @@ -57,6 +57,8 @@
[expound "0.7.1"]
[fipp "0.6.14"]

[com.bhauman/cljs-test-display "0.1.1"]

[com.wsscode/pathom "2.1.3"
:exclusions
[org.clojure/data.json
Expand Down
1 change: 0 additions & 1 deletion src/main/shadow/build/targets/browser_test.clj
Expand Up @@ -32,7 +32,6 @@
[:head
[:title (str runner-ns)]
[:body
[:pre#log]
[:script {:src "/js/test.js"}]
[:script (str (cljs-comp/munge runner-ns) ".init();")]]])))

Expand Down
24 changes: 7 additions & 17 deletions src/main/shadow/test/browser.cljs
@@ -1,28 +1,18 @@
(ns shadow.test.browser
"generic browser test runner"
(:require [shadow.test :as st]
[shadow.dom :as dom]))

;; FIXME: implement custom reporter instead
(defonce log-node (dom/by-id "log"))
(when log-node
(set-print-fn!
(fn [s]
(dom/append log-node (str s "\n")))))
(:require
[shadow.test :as st]
[shadow.dom :as dom]
[cljs-test-display.core :as ctd]))

(defn start []
;; (js/console.log "test env" @st/tests-ref)
(st/run-all-tests))
(st/run-all-tests (ctd/init! "test-root")))

(defn stop [done]
(set! (.-innerText log-node) "")

;; FIXME: determine if async tests are still running
;; and call done after instead
;; otherwise a live reload might interfere with running tests by
;; reloading code in the middle
;; FIXME: determine if async tests are still pending
(done))

;; not sure we need to do something once?
(defn ^:export init []
(dom/append [:div#test-root])
(start))

0 comments on commit 81ee576

Please sign in to comment.