Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Fixing clojurescript.test Failing with "ReferenceError: Can't find variable: cemerick"

DZone's Guide to

Fixing clojurescript.test Failing with "ReferenceError: Can't find variable: cemerick"

· Java Zone ·
Free Resource

The CMS developers love. Open Source, API-first and Enterprise-grade. Try BloomReach CMS for free.

ClojureScript.test (0.3.0; cemerick.cljs.test) may fail with this confusing exception:

ReferenceError: Can't find variable: cemerick

due to couple of reasons:

  1. Your test namespaces do not require cemerick.cljs.test (and thus it is missing from the compiled .js; requiring macros is not enough)
  2. cljsbuild has not included any of your test files (due to wrong setup etc.; this is essentially another form of #1)
  3. You are trying to test with the node runner but have built with :optimizations :none or :whitespace (for node you need to concatenate everything into a single file, which only happens if you use :simple or :advanced optimizations)

There is a pull request to provide a better error message but until then you have to be aware of these problems.

Example failures from all the runners:

Successfully compiled "target/cljs/testable.js" in 18.207 seconds.
Running ClojureScript test: rhino
js: "/var/folders/k0/2842tm752zv1dh4q77_gmgdr0000gn/T/rhino-runner8958189739208289289.js", line 50: uncaught JavaScript runtime exception: ReferenceError: "cemerick" is not defined.
at /var/folders/k0/2842tm752zv1dh4q77_gmgdr0000gn/T/rhino-runner8958189739208289289.js:50
Running ClojureScript test: node
/private/var/folders/k0/2842tm752zv1dh4q77_gmgdr0000gn/T/node-runner9185102801545573161.js:26
cemerick.cljs.test.set_print_fn_BANG_(function(x) {
^
ReferenceError: cemerick is not defined
at Object.<anonymous> (/private/var/folders/k0/2842tm752zv1dh4q77_gmgdr0000gn/T/node-runner9185102801545573161.js:26:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
Subprocess failed
Running ClojureScript test: phantom
ReferenceError: Can't find variable: cemerick
phantomjs://webpage.evaluate():2
phantomjs://webpage.evaluate():5
phantomjs://webpage.evaluate():5
ReferenceError: Can't find variable: cemerick
phantomjs://webpage.evaluate():2
phantomjs://webpage.evaluate():8
phantomjs://webpage.evaluate():8
# phantomjs freezes here

BloomReach CMS: the API-first CMS of the future. Open-source & enterprise-grade. - As a Java developer, you will feel at home using Maven builds and your favorite IDE (e.g. Eclipse or IntelliJ) and continuous integration server (e.g. Jenkins). Manage your Java objects using Spring Framework, write your templates in JSP or Freemarker. Try for free.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}