Skip to content

Commit c4bf8e0

Browse files
committed
Make console output from tests more colorful
1 parent 0910553 commit c4bf8e0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test/runner.cljs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@
6262
(println (:fail m) "failures," (:error m) "errors.")
6363
(aset js/window "test-failures" (+ (:fail m) (:error m))))
6464

65-
(defn pretty-print-diffs [diffs]
65+
(defn pretty-print-diffs [diffs color]
6666
(let [printer (fn [[op data]]
6767
(cond
68-
(= op js/DIFF_DELETE) (str (ansi :red) data (ansi :reset))
69-
(= op js/DIFF_INSERT) (str (ansi :green) data (ansi :reset))
68+
(= op js/DIFF_DELETE) (str (ansi :red) data (ansi color))
69+
(= op js/DIFF_INSERT) (str (ansi :green) data (ansi color))
7070
:else data))]
7171
(apply str (map printer diffs))))
7272

@@ -80,16 +80,16 @@
8080
dmp (diff-match-patch-class.)
8181
diffs (.diff_main dmp json-b json-a)]
8282
(.diff_cleanupSemantic dmp diffs)
83-
(println (pretty-print-diffs diffs)))))
83+
(println (ansi :bg-white) (ansi :black) (pretty-print-diffs diffs :black) (ansi :reset)))))
8484

8585
(defmethod report [::test/default :fail] [m]
8686
(test/inc-report-counter! :fail)
8787
(println (ansi :red) "\nFAIL in" (test/testing-vars-str m) (ansi :reset))
8888
(when (seq (:testing-contexts (test/get-current-env)))
89-
(println (test/testing-contexts-str)))
90-
(when-let [message (:message m)] (println message))
91-
(println "expected:" (pr-str (:expected m)))
92-
(println " actual:" (pr-str (:actual m)))
89+
(println (ansi :blue) (test/testing-contexts-str) (ansi :reset)))
90+
(when-let [message (:message m)] (println (ansi :magenta) message (ansi :reset)))
91+
(println "expected:" (ansi :green) (pr-str (:expected m)) (ansi :reset))
92+
(println " actual:" (ansi :yellow) (pr-str (:actual m)) (ansi :reset))
9393
(present-diff-if-applicable (:actual m)))
9494

9595
(test/run-tests

0 commit comments

Comments
 (0)