-
Notifications
You must be signed in to change notification settings - Fork 6
/
console.cljs
67 lines (50 loc) · 2.04 KB
/
console.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
(ns fulcro-spec.reporters.console
(:require [cljs.test]))
(enable-console-print!)
(def ^:dynamic *test-level* (atom 0))
(defn space-level []
(apply str (repeat (* 3 @*test-level*) " ")))
(defmethod cljs.test/report :console [m])
(defmethod cljs.test/report [::console :pass] [m]
(cljs.test/inc-report-counter! :pass))
(defmethod cljs.test/report [::console :error] [m]
(cljs.test/inc-report-counter! :error)
(println "\nERROR in" (cljs.test/testing-vars-str m))
(some-> m :message println)
(println "expected:" (pr-str (:expected m)))
(println " actual:" (pr-str (:actual m)))
(println))
(defmethod cljs.test/report [::console :fail] [m]
(cljs.test/inc-report-counter! :fail)
(println "\nFAIL in" (cljs.test/testing-vars-str m))
(some-> m :message println)
(println "expected:" (pr-str (:expected m)))
(println " actual:" (pr-str (:actual m)))
(println))
(defmethod cljs.test/report [::console :begin-test-ns] [m]
(println "\nTesting" (name (:ns m))))
(defmethod cljs.test/report [::console :begin-specification] [m]
(reset! *test-level* 0)
(println (space-level) (:string m)))
(defmethod cljs.test/report [::console :end-specification] [m]
(println)
(reset! *test-level* 0))
(defmethod cljs.test/report [::console :begin-behavior] [m]
(swap! *test-level* inc)
(println (space-level) (:string m)))
(defmethod cljs.test/report [::console :end-behavior] [m]
(swap! *test-level* dec))
(defmethod cljs.test/report [::console :begin-manual] [m]
(swap! *test-level* inc)
(println (space-level) (:string m)))
(defmethod cljs.test/report [::console :end-manual] [m]
(swap! *test-level* dec))
(defmethod cljs.test/report [::console :begin-provided] [m]
(swap! *test-level* inc)
(println (space-level) (:string m)))
(defmethod cljs.test/report [::console :end-provided] [m]
(swap! *test-level* dec))
(defmethod cljs.test/report [::console :summary] [m]
(println "\nRan" (:test m) "tests containing"
(+ (:pass m) (:fail m) (:error m)) "assertions.")
(println (:fail m) "failures," (:error m) "errors."))