bhauman / devcards

Devcards aims to provide a visual REPL experience for ClojureScript
1.53k stars 113 forks source link

How to show cljs.test error messages for failed tests? #68

Closed mikavilpas closed 8 years ago

mikavilpas commented 8 years ago

I'm liking the idea of devcards. :+1: I wrote some simple tests with it, but unfortunately some of them failed.

From the devcard UI I don't see why they did, though. Is it possible to show the error messages like the cljs.test runner does it?

bhauman commented 8 years ago

Can you give me an example of what you are doing?

mikavilpas commented 8 years ago

Yeah, when a test fails I basically want to show an error message like the one here

But instead of the "Expected stuff to equal stuff" message I just get a red container showing the test body. My problem is I can't see the cause of the failure.

mikavilpas commented 8 years ago

Here is my test class (I'm writing a pong game)

(ns pocpong.tests.engine-tests
  (:require [cljs.test :refer-macros [is] :include-macros true]
            [pocpong.engine.movement :as m]
            [pocpong.engine.types :as e])
  (:require-macros [devcards.core :as dc :refer [deftest]]))

(def include-dummy :yep)

(deftest move-ball-tests
  "positive Velocity"
  (is (= (e/Position. 6 6)
         (let [state (e/map->PongState
                      {:ball (e/Ball. (e/Position. 5 5)
                                      (e/velocity 1 1))})]
           (-> (m/move-ball state)
               :ball
               :position))))

  "negative Velocity"
  (is (= (e/Position. 4 4)
         (let [state (e/map->PongState
                      {:ball (e/Ball. (e/Position. 5 5)
                                      (e/velocity -1 -1))})]
           (-> (m/move-ball state)
               :ball
               :position)))))