TestContext fails on async call #69

Closed
fredericlb opened this Issue Jun 16, 2014 · 5 comments

Comments

Projects
None yet
4 participants
@fredericlb

Hi,

I am not really sure if this is really a bug or if I'm making a mistake but when running this test :

(deftest ^:async empty-db-is-of-length-0
  (go
   (reset-db)
   (let [c (core/all-docs db {"include-docs" true})
         res (<! c)]
     (is= (:total_rows res) 0))
   (done)))

i am told that th following assert failed :
(instance? TestContext test-ctx)

however it looks to me that my code is quite close to the one concerning core.async in the README.

do you have any idea of the reason why this code snippet fails ?

thanks,

@cemerick

This comment has been minimized.

Show comment Hide comment
@cemerick

cemerick Jun 24, 2014

Owner

Perhaps a dupe of #70. Queued, thanks.

Owner

cemerick commented Jun 24, 2014

Perhaps a dupe of #70. Queued, thanks.

@cemerick cemerick added this to the 0.3.2 milestone Jun 24, 2014

@Verneri

This comment has been minimized.

Show comment Hide comment
@Verneri

Verneri Aug 6, 2014

Using the example given in here gives the same result:

(defn- timeout-helper
  [test-context delay]
  (with-test-ctx test-context
    (let [now #(.getTime (js/Date.))
        t (now)]
      (js/setTimeout
        (fn []
          (is (>= (now) (+ t delay)))
          (done))
        delay))))

(deftest ^:async timeout
  (timeout-helper 2000))

printing the arguments of helper shows that context is 2000 and delay nil.

and cljs is version "0.0-2202"
cljs.test version "0.3.1"

and the code is run in phantomjs

Verneri commented Aug 6, 2014

Using the example given in here gives the same result:

(defn- timeout-helper
  [test-context delay]
  (with-test-ctx test-context
    (let [now #(.getTime (js/Date.))
        t (now)]
      (js/setTimeout
        (fn []
          (is (>= (now) (+ t delay)))
          (done))
        delay))))

(deftest ^:async timeout
  (timeout-helper 2000))

printing the arguments of helper shows that context is 2000 and delay nil.

and cljs is version "0.0-2202"
cljs.test version "0.3.1"

and the code is run in phantomjs

@jonahkagan

This comment has been minimized.

Show comment Hide comment
@jonahkagan

jonahkagan Oct 29, 2014

@Verneri I found that explicitly passing in -test-ctx to timeout-helper solves the issue you're facing.

(deftest ^:async timeout
  (timeout-helper -test-ctx 2000))

Perhaps the example in the README was supposed to look like this originally?

@Verneri I found that explicitly passing in -test-ctx to timeout-helper solves the issue you're facing.

(deftest ^:async timeout
  (timeout-helper -test-ctx 2000))

Perhaps the example in the README was supposed to look like this originally?

@cemerick

This comment has been minimized.

Show comment Hide comment
@cemerick

cemerick Dec 11, 2014

Owner

Does this still happen under ClojureScript 2411? #70 is no longer a problem under it (and maybe other more recent compiler versions?).

Owner

cemerick commented Dec 11, 2014

Does this still happen under ClojureScript 2411? #70 is no longer a problem under it (and maybe other more recent compiler versions?).

@cemerick cemerick removed this from the 0.3.2 milestone Dec 11, 2014

@fredericlb

This comment has been minimized.

Show comment Hide comment
@fredericlb

fredericlb Dec 13, 2014

Yes it's fixed now ! Thanks

Yes it's fixed now ! Thanks

@fredericlb fredericlb closed this Dec 13, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment