Skip to content

Instantly share code, notes, and snippets.

@Jell
Created August 30, 2016 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jell/76abeb78e8c472119079b951b1c2e9f5 to your computer and use it in GitHub Desktop.
Save Jell/76abeb78e8c472119079b951b1c2e9f5 to your computer and use it in GitHub Desktop.
CLJS run single test var
(ns cljs.test.repl
(:require [cljs.analyzer.api :as ana-api]
[cljs.analyzer :as ana]
[cljs.test]))
(defmacro run-single-test [[quote var :as form]]
(let [ns (or (some-> var namespace symbol)
ana/*cljs-ns*)]
`(cljs.test/run-block
(concat
[(fn []
(cljs.test/set-env! (cljs.test/empty-env))
~(when (ana-api/ns-resolve ns 'cljs-test-once-fixtures)
`(cljs.test/update-current-env! [:once-fixtures] assoc '~ns
~(symbol (name ns) "cljs-test-once-fixtures")))
~(when (ana-api/ns-resolve ns 'cljs-test-each-fixtures)
`(cljs.test/update-current-env! [:each-fixtures] assoc '~ns
~(symbol (name ns) "cljs-test-each-fixtures"))))]
(cljs.test/test-vars-block [~form])
[(fn []
(cljs.test/report (merge (:report-counters (cljs.test/get-current-env))
{:type :summary :ns ~ns}))
(cljs.test/clear-env!))]))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment