Skip to content

Commit

Permalink
Karma-coverage plugin support
Browse files Browse the repository at this point in the history
  • Loading branch information
alun authored and honzabrecka committed Jan 20, 2017
1 parent 79e2350 commit 3bce565
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject karma-reporter "2.0.1"
(defproject karma-reporter "2.1.0"

:description "A plugin for running clojurescript tests with Karma."

Expand Down
13 changes: 12 additions & 1 deletion src/jx/reporter/karma.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,20 @@
(when (karma?)
(.result @karma (clj->js m))))

(defn- coverage-result []
(let [xform (comp
(map (partial re-find #"__cov_[^_]+$"))
(filter (comp not nil?))
(map (partial aget js/window))
(mapcat (juxt #(.-path %) identity))
(partition-all 2))
all-vars (.keys js/Object js/window)
coverage-info (into {} xform all-vars)]
(clj->js {:coverage coverage-info})))

(defn- karma-complete! []
(when (karma?)
(.complete @karma #js {})))
(.complete @karma (coverage-result))))

(defn- now []
(.getTime (js/Date.)))
Expand Down

0 comments on commit 3bce565

Please sign in to comment.