magomimmo / modern-cljs

A series of tutorials on ClojureScript
2.92k stars 288 forks source link

IFDE and CLJS TDD devleopment environment #359

Open learningcljs opened 8 years ago

learningcljs commented 8 years ago

I wanted to start applying learnings from working through this very helpful tutorial series. So the first thing I wanted to do was pull out the immediate feedback development environment as well as the test driven development components that can be started up with boot dev and boot tdd.

I wanted it without all the other libraries and just a simple minimalist hello-world to see that the unit test were working. I also went for the test driven development just for CLJS because I am interested in using CLJS on the backend instead of CLJ.

This would be a fresh development environment that I could use to get started with CLJS projects. I also thought that it could potentially be a good contribution to this tutorial series as a branch that others could checkout as they may also want this development environment to start projects with.

So I have put together a first attempt which has boot dev working as well as the stand alone boot tdd which is not combined with boot dev. When I try combining boot dev and boot tdd I am running across an issue.

Here is what the working boot dev looks like:

(deftask dev
  "Launch Immediate Feedback Development Environment"
  []
  (comp 
   (serve :dir "target")
   (watch)
   (reload)
   (cljs-repl) ;; before cljs task
   (cljs)
   (target :dir #{"target"})))

Here is what the stand alone working boot tdd looks like.

(deftask tdd
  "Launch a TDD Environment"
  []
  (comp
   (testing)
   (watch)
   (test-cljs :update-fs? true :js-env :phantom :namespaces '#{modern-cljs.core-test})
   (target :dir #{"target"})))

My attempt at combining these looks like this:

(deftask tdd
  "Launch a IFDE and TDD Environment"
  []
  (comp
   (serve :dir "target"
          :reload true)
   (testing)
   (watch)
   (reload)
   (cljs-repl)
   (test-cljs 
              :out-file "js/main.js"
              :js-env :phantom
              :namespaces '#{modern-cljs.core-test}
              :update-fs? true)
   (target :dir #{"target"})))

Which gives me this error message when I run boot tdd:

ClojureScript could not load :main, did you forget to specify :asset-path?

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

It is working in the browser.

I have pushed this as a branch to my fork of the repository here.

Any suggestions on how to fix this?

magomimmo commented 8 years ago

Just back from a brief vacation. I do not understand why you want to put together the IFDE with the TDD. TDD already includes the immediate feedback. If you really want to create a new project based on TDD we should crete a leiningen template or a boot template (i.e. https://github.com/seancorfield/boot-new).

You could eventually create a new cljs based project using https://github.com/martinklepsch/tenzing as well. HIH.

learningcljs commented 8 years ago

https://github.com/seancorfield/boot-new https://github.com/martinklepsch/tenzing

Thanks for sharing these links. I prefer the looks of tenzing because of its:

I do not understand why you want to put together the IFDE with the TDD. TDD already includes the immediate feedback.

I revisited the tutorials on TDD. In the TDD task section of tutorial 15 the TDD task is setup to do the automated unit testing without the IFDE. I have this working fine. It is like tenzing's +test option.

In the next section A single JVM instance, multiple tasks the IFDE and automated unit testing are combined. It is my attempt at combining these that I am getting that error message with. It would be nice to have both of these running in the same task. tenzing does not currently offer this.

If you really want to create a new project based on TDD we should crete a leiningen template or a boot template

The idea of a boot template is interesting. When this boot tdd task is working I think it has potential as a contribution to the tenzing project.

The only unfortunate part is that tenzing requires lein which is not a dependency in the second edition of this tutorial series. So this makes me curious about creating a boot template without a lein dependency. When I skim boot's README and wiki I do not see any references to templates.

So maybe as a Docker image like pull request #349 which is a development environment with:

I still have to figure out the issue I had for that pull request.