bhauman / devcards

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

Test fixtures are ignored by deftest #104

Closed bsteuber closed 5 years ago

bsteuber commented 8 years ago

Hi - and thanks for the great work with figwheel and devcards :D

The following example breaks in the devcards view, but works fine when using cljs.test/run-tests instead. If you provide some help on how to implement it I could try providing a patch myself.

(ns fixture.example
  (:require [cljs.test     :refer-macros [use-fixtures is]]
            [devcards.core :refer-macros [deftest]]))

(def state (atom nil))

(use-fixtures :each
  {:before (fn []
             (reset! state :foo))})

(deftest fixtures
  (is (= :foo @state)))
bhauman commented 8 years ago

This is true and unfortunately, fixing it is non trivial. It has to do with a subtle miss-match asynchrony of the the live coding process and the design of fixtures in cljs-test. In order to catch errors for async tests in Devcards things get a bit tricky.

This was an attempt that ignored all the edge cases: https://github.com/bhauman/devcards/pull/76

Please don't follow the approach in that example. It's important to understand the how and why of the current implementation before finding a solution to the fixture problem. Quite frankly we might have to look at cljs-test and see if something needs to be changed there.

bsteuber commented 8 years ago

I see, it looks really complicated indeed - that's a pity..

On Tue, Apr 19, 2016 at 10:15 PM Bruce Hauman notifications@github.com wrote:

This is true and unfortunately, fixing it is non trivial. It has to do with a subtle miss-match asynchrony of the the live coding process and the design of fixtures in cljs-test. In order to catch errors for async tests in Devcards things get a bit tricky.

This was an attempt that ignored all the edge cases:

76 https://github.com/bhauman/devcards/pull/76

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/bhauman/devcards/issues/104#issuecomment-212107891

mikavilpas commented 8 years ago

This doesn't really bother me right now - but for the record: is there some workaround?

bhauman commented 5 years ago

I highly recommend that folks use https://github.com/bhauman/cljs-test-display