ClojureScript + boot: make non-CLJSJS libs available to test code?

133 Views Asked by At

When using boot for ClojureScript projects, how does one make external non-CLJSJS JavaScript libraries available to test code (vs application code)?

Application code can get access when it's included on the same HTML page as the library.

(With leiningen + figwheel, the test code ran in the same context as the application code -- on my index.html page -- so the test code was aware of the third party js library.)

Is there a similar page context in boot for test code? Or is there a way to conj something like ["resources/third-party/library.js"] onto a source or resource path, such that unit tests can refer to the same library that application code does?

When I run boot auto-test it says #object[ReferenceError ReferenceError: Can't find variable: CodeMirror]. CodeMirror is the third party library in my case. My unit tests need a CodeMirror instance so they can .setValue, then call a bunch of CodeMirror methods to tell the instance what to do, then verify the instance's new value and cursor position. I'm testing whether my ClojureScript comes up with the right calls to CodeMirror in order to have the intended effects.

I've been able to use the latest CLJSJS version of CodeMirror but it doesn't pass my unit tests whereas the most recent non-CLJSJS version directly from CodeMirror does pass. So I'm guessing I need the latest CodeMirror, which isn't yet offered via CLJSJS yet.

Here's part of my build.boot file:

(deftask testing []
  (set-env! :source-paths #(conj % "test/cljs"))
  identity)

(deftask test []
  (comp (testing)
        (test-cljs :js-env :phantom
                   :exit?  true)))

(deftask auto-test []
  (comp (testing)
        (watch)
        (test-cljs :js-env :phantom)))
0

There are 0 best solutions below