reagent-project / reagent-template

A Leiningen template for projects using Reagent.
MIT License
394 stars 55 forks source link

unable to run tests (compiling fails) #60

Closed murtaza52 closed 8 years ago

murtaza52 commented 9 years ago

Hi,

I created a new project using lein new reagent hello-world +test. (The below is on a virgin project created using the template).

When I run lein cljsbuild test unit it throws the following error while compiling test.js -

Compiling ClojureScript. Compiling "target/test.js" from ["src/cljs"]... Compiling "target/test.js" failed. java.lang.NullPointerException at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:301) at cljs.closure$load_externs$load_js3229$fn3230.invoke(closure.clj:223)

I get the same error while even doing a lein cljsbuild once. However lein fighweel compiles the code and does not throw an error.

Is some figwheel dependency causing a problem ? Can you please help, this is driving me crazy. Is there an alternate way to just run my tests ?

yogthos commented 9 years ago

I can reproduce this, and it appears that it's related to figwheel, where the build is unable to find the namespace that it inject:

Caused by: clojure.lang.ExceptionInfo: No such namespace: figwheel.client, could not locate figwheel/client.cljs or figwheel/client.cljc at line 1 env/dev/cljs/hello_world/dev.cljs {:file "env/dev/cljs/hello_world/dev.cljs", :line 1, :column 1, :tag :cljs/analysis-error}

Looks like adding it as a dependency explicitly fixes the issue. I'll push out a new version with the fix:

:profiles {:dev {:repl-options {:init-ns hello-world.repl
                                  :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}

                   :dependencies [[ring-mock "0.1.5"]
                                  [ring/ring-devel "1.3.2"]
                                  [weasel "0.6.0"]
                                  [leiningen-core "2.5.1"]
                  [lein-figwheel "0.3.3"]
                                  [com.cemerick/piggieback "0.2.1"]
                                  [org.clojure/tools.nrepl "0.2.10"]
                                  [pjstadig/humane-test-output "0.7.0"]]
yogthos commented 9 years ago

new template is up and test seems to work as expected:

hello-world> lein cljsbuild test
Compiling ClojureScript.
Compiling "target/test.js" from ["src/cljs" "test/cljs"]...
WARNING: Preamble resource file not found: react/react.js
Successfully compiled "target/test.js" in 8.471 seconds.
Running ClojureScript test: unit

Testing hello-world.core-test

Ran 1 tests containing 1 assertions.
Testing complete: 0 failures, 0 errors.
gadfly361 commented 9 years ago

Probably can remove the react preamble to silence the warning above.

gadfly ~/Desktop/hello-world $ lein cljsbuild test
Compiling ClojureScript.
Compiling "target/test.js" from ["src/cljs" "test/cljs"]...
Successfully compiled "target/test.js" in 3.319 seconds.
Compiling "resources/public/js/app.js" from ("src/cljs" "env/dev/cljs")...
Successfully compiled "resources/public/js/app.js" in 0.482 seconds.
Running ClojureScript test: unit

Testing hello-world.core-test 

Ran 1 tests containing 1 assertions.
Testing complete: 0 failures, 0 errors.
yogthos commented 9 years ago

yeah that makes sense :)

murtaza52 commented 9 years ago

Thanks for the prompt response. That saved my day !

How do you guys run your tests, if you never encountered the above problem ? Is there a better way to run them then lein cljsbuild test unit ?

yogthos commented 9 years ago

Figwheel allows reloading stuff on code change that's handy for automatically running the tests as seen here.

yogthos commented 9 years ago

@gadfly361 and just pushed out a new version without the preamble

yogthos commented 9 years ago

sounds like we can close this one then?

murtaza52 commented 9 years ago

Dmitri how do I have two figwheel builds - the :main and the :test running at the same time.

lein figwheel only starts the main build. Also where will see the results after the test have run ? Any sample configs you can point me to.

Appreciate the help.

On Wed, May 20, 2015 at 7:53 AM, Dmitri Sotnikov notifications@github.com wrote:

sounds like we can close this one then?

— Reply to this email directly or view it on GitHub https://github.com/reagent-project/reagent-template/issues/60#issuecomment-103729475 .

yogthos commented 9 years ago

I don't have a sample config handy, but it's probably easiest to just add the test path to the dev resource-paths and have figwheel run the tests. The results should show up in the repl, you can also switch the figwheel repl to the test ns and run the tests from there as well.

gadfly361 commented 9 years ago

I was about to open an issue on lein-figwheel, but it looks like @murtaza52 beat me to it. :)

For reference, that issue can be found here and the relevant clojure west talk can be found here.

murtaza52 commented 9 years ago

Dmitri, I included the test sources, in :dev build :src. Now whenever there is a compilation error in the tests, I do see it in the browser. However how do I also get the tests to run when the src changes ?

Do you keep them running from the repl ?

Thanks for the help.

On Wed, May 20, 2015 at 9:28 AM, Matthew Jaoudi notifications@github.com wrote:

I was about to open an issue on lein-figwheel, but it looks like @murtaza52 https://github.com/murtaza52 beat me to it. :)

For reference, that issue can be found here https://github.com/bhauman/lein-figwheel/issues/162 and the relevant clojure conj talk can be found here https://www.youtube.com/watch?v=j-kj2qwJa_E.

— Reply to this email directly or view it on GitHub https://github.com/reagent-project/reagent-template/issues/60#issuecomment-103747093 .

bhauman commented 9 years ago

I don't understand why the namespace lookup didn't work. But you should just add the client and not the whole plugin to the dependencies [figwheel "0.3.3"].

yogthos commented 9 years ago

Is this still an issue or can we close it?

yogthos commented 8 years ago

I'm closing this one and we can reopen it if it's still a problem