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

Error trying to use rhino #44

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi,

I'm trying to use rhino with doo 0.1.6-SNAPSHOT. I installed nodejs and karma but when running lein doo rhino test I get the following output:

ERROR: doo was not loaded from the compiled script.

Make sure you start your tests using doo-tests or doo-all-tests and that you include that file in your build

;; ====================================================================== ;; Testing with :

Though, I do include and use (doo-tests 'foo.runner).

Any idea on what I am doing wrong?

bensu commented 8 years ago

Hi @agremm,

Can you include the compiler options? Are you using :optimizations :none?

Rhino is completely unrelated to Node.js and Karma. Having installed them (or not) should make no difference. Are you saying that it worked with node/kama?

Thanks for your feedback.

ghost commented 8 years ago

I'm using

:compiler {:main 'reacl-tutorial.test-run :asset-path "js/test-out" :output-to "resources/public/js/test.js" :output-dir "resources/public/js/test-out" :source-map-timestamp true :optimizations :simple} as options.

I guess I was just trying to narrow down possible sources of the error when I mentioned Node.js and Karma. I haven't tried using any other JS engine as I only care about Rhino at the moment.

Thanks for your help!

bensu commented 8 years ago

Thanks for the config.

After looking at the reacl-tutorial I see two problems:

  1. The test setup is set up to be used in Figwheel. This means that the call to (run-tests 'reacl-tutorial.core-test) is hidden under a run function. In doo it must be a top level declaration (Now documented in the README with 1f582ed)
  2. The project is very much DOM oriented. React after all is being used for DOM manipulations. Rhino has no DOM, so React can't be required into Rhino.

Here are the minimal changes I've made to successfully test with Slimer, running lein doo slimer test. If you'd rather test with Karma let me know and I'll guide you to set it up.

If you would like to test non-DOM functions in Rhino, you'll need a profile that doesn't have reacl as a dependency so it doesn't pull React in.

mikesperber commented 8 years ago

Hi there,

I work with @agremm and am the primary author of Reacl:

Thanks for the quick reply and the help!

A few comments:

Yes, React can access the DOM, but the code @agremm is trying to run is carefully engineered to not get that point. (We made an earlier version of this run on Nashorn.)

We really, really want to avoid dragging in complicated dependencies like Slimer - making it run on a JVM-based JavaScript is a primary consideration for us. Any help with this is much appreciated!

ghost commented 8 years ago

To clarify on the Karma situation: When I ran lein doo rhino test I got an error because doo could not find Karma. I just tried replicating the error but was unable to. I assume there were some other mistakes on my side.

bensu commented 8 years ago

@agremm the Karma error was not your mistake, it was #45, which I fixed and pushed yesterday.

@agremm have you tried using the changes that I proposed in the example project on your code? When I ran it, it stops because it can't find React, due to this line. I'm exposing Rhino errors in b7327b3 so that you can reproduce this.

@mikesperber if you have code that works under Nashorn, then we should start by having an example repository that also works with Rhino, without involving doo. Then we would now that what you want is in fact possible. After that, I can help you set up the tests hooks around your scripts. Otherwise the issue is: "Running React related code in Rhino" which is not doo related. On that front, I would first try to figure out how does React attempt to load itself in Rhino, since there are no modules, define, window, require, or process objects.

bensu commented 8 years ago

Closed by #58