Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

TestContext fails on async call #69

Closed
fredericlb opened this Issue · 5 comments

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
Owner

Perhaps a dupe of #70. Queued, thanks.

@cemerick cemerick added this to the 0.3.2 milestone
@Verneri

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

@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
Owner

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
@fredericlb

Yes it's fixed now ! Thanks

@fredericlb fredericlb closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.