bensu / doo

doo is a library and lein plugin to run cljs.test on different js environments.
Eclipse Public License 1.0
324 stars 63 forks source link

Expose the running runner? #70

Closed arichiardi closed 8 years ago

arichiardi commented 8 years ago

Hi @bensu,

I wanted to ask you if there is a way to know which runner is currently executed in order to pass it to my tests. For instance to execute node-specific configuration as test fixture.

If this is not exposed, I could work on doing it and submit a PR ;)

danielcompton commented 8 years ago

Another option for node specific code would be to include it in your build config section, say something like :source-paths ["src" "test" "platform/node"].

bensu commented 8 years ago

@arichiardi I'm not sure I understand. Do you want to know inside the cljs test what is currently running? If so, you can look at https://github.com/bensu/maxwell

You can do this:

(ns some.tests
  (:require [cljs.test :refer :all]
            [maxwell.spy :as spy]))

(deftest runner-dependent-test
  (cond 
    (spy/chrome?) (test-in-chrome)
    (spy/safari?) (test-in-safari)
    :else (test-everywhere-else)))

If that doesn't solve your problem, please explain further so we can figure it out.

bensu commented 8 years ago

I think @arohner was doing something similar.

arichiardi commented 8 years ago

Basically I have tests here: https://github.com/ScalaConsultants/replumb/blob/master/test/cljs/replumb/repl_test.cljs

I would like to change the target options (at runtime) based on the build I'd, if it's nodejs I would like to pass :target :nodejs to my read-eval-call.

bensu commented 8 years ago

If that is all you want then you can use doo.runner/node? from inside your tests. You can see it's implementation here

arichiardi commented 8 years ago

Oh great I did not see it, sorry about this, I even skimmed through the source...but too quickly it seems :)

bensu commented 8 years ago

No problem! I'm closing this then.