Troubleshooting build issues

swannodette edited this page Mar 24, 2012 · 2 revisions

Test Builds

A lot of ClojureScript code does not need the browser in order to be tested. In these cases it's often useful to be able to test a ClojureScript library with V8, Node.js or any other JavaScript runtime that suits your fancy. lein-cljsbuild augments the classpath with all the :source-path references in :builds. Here's an example:

(defproject my-awesome-cljs-lib "0.1.0" 
  :cljsbuild {:builds [{:source-path "src/main/cljs"
                        :compiler {:output-to "main.js"}}
                       {:source-path "src/test/cljs"
                        :optimizations :advanced
                        :compiler {:output-to "tests.js"}}]})

In order for the test build to properly resolve libraries referenced in the test code the :source-path for your library must be precise - the namespace segments of your library must match up to the directory structure.