Skip to content

Instantly share code, notes, and snippets.

@viesti
Last active August 29, 2015 14:24
Show Gist options
  • Save viesti/cef01b3bd76205c29757 to your computer and use it in GitHub Desktop.
Save viesti/cef01b3bd76205c29757 to your computer and use it in GitHub Desktop.
count test vars for cljs.test
(ns karma.macros
(:require [cljs.analyzer.api :as ana-api]))
(defmacro ns-metas [re]
(mapv (fn [ns]
`(ns-interns ~['quote ns]))
(filter #(re-matches re (str %))
(ana-api/all-ns))))
-----------------------------------------------------------------
(ns karma-adapter
(:require your.app.components-test
your.app.another-ns-under-test)
[karma.macros :refer-macros [ns-metas]])
(defn count-test-vars [ns-meta-list]
(reduce + (for [ns-meta ns-meta-list]
(count (filter (fn [[_ v]] (:test (meta v))) ns-meta)))))
{:total (count-test-vars (ns-metas #"your.app.*-test$"))}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment