2

I'm trying to run a basic test with

https://github.com/cemerick/clojurescript.test

I've created a simple project such as:

(defproject sampleproj "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                  [org.clojure/clojurescript "0.0-2014"]
                  ]
  :plugins [[lein-cljsbuild "1.0.0"]
          [com.cemerick/clojurescript.test "0.2.2"]]
  :cljsbuild {:builds [{:source-paths ["src-js" "test-js"]
                      :compiler {:output-to "target/cljs/testable.js"
                                 :optimizations :whitespace
                                 :pretty-print true}}]
            :test-commands {"unit-tests" ["phantomjs" :runner
                                          "this.literal_js_was_evaluated=true"
                                          "target/cljs/testable.js"]}}
  )

Both folders src-js and test-js exist since I intend to put all my clojurescript files there.

In my test-js/sampleproj folder I copied the sample test in the documentation:

(ns sampleproj.sampletest
  (:require-macros [cemerick.cljs.test
                    :refer (is deftest with-test run-tests testing test-var)])
  (:require [cemerick.cljs.test :as t]))

(deftest somewhat-less-wat
  (is (= "{}[]" (+ {} []))))

(deftest javascript-allows-div0
  (is (= js/Infinity (/ 1 0) (/ (int 1) (int 0)))))

(with-test
  (defn pennies->dollar-string
    [pennies]
    {:pre [(integer? pennies)]}
    (str "$" (int (/ pennies 100)) "." (mod pennies 100)))
  (testing "assertions are nice"
    (is (thrown-with-msg? js/Error #"integer?" (pennies->dollar-string 564.2)))))

Now if I try to run the tests

-> % lein cljsbuild test
Compiling ClojureScript.
Running ClojureScript test: unit-tests
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():5
  phantomjs://webpage.evaluate():5
Subprocess failed

I'm fairly new to clojurescript so probably I'm missing something.

Update:

My environment

-> % lein -v
Leiningen 2.3.4 on Java 1.7.0_06 Java HotSpot(TM) 64-Bit Server VM

-> % phantomjs -v
1.9.2

-> % java -version
java version "1.7.0_06"
Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)
Rafa de Castro
  • 2,474
  • 1
  • 24
  • 44
  • I tried to reproduce but all the test cases run successfully without any error. Lein version 2.3.4, phantomjs version 1.9.2 and java version 1.7.0. phantomjs is in path? http://phantomjs.org/ – jittakal Feb 08 '14 at 18:13
  • Looks like my environment is exactly the same as yours. I updated the question. This is odd. – Rafa de Castro Feb 09 '14 at 17:59
  • I just wanted to chime in saying that I'm having the exact same issue. Version info: $ lein -v Leiningen 2.3.4 on Java 1.6.0_27 OpenJDK 64-Bit Server VM $ phantomjs -v 1.9.7 – user1500409 Feb 09 '14 at 21:56
  • Same thing with me Leiningen 2.3.4 phantomjs 1.9.1 java 1.8.0-b132 – Niki Tonsky Apr 22 '14 at 04:35
  • It could be errors of parsing or executing of `testtable.js` before variable `cemerick` was defined and it was never defined as effect of error. Test-runner or PhantomJS may cut errors or completely hide them and we don't se a real reason which might be not connected with cemerick. – chivorotkiv Aug 16 '15 at 13:51

2 Answers2

0

Are macros located right into clj sources ? After that th compiler shoud compiler you cemeric macros to javascript.

You propably have dependencies right in project.clj

markus
  • 1
  • 1
0

This hasn't been answered, so I will. You need to specify your dependency for clojurescript.test : [com.cemerick/clojurescript.test "0.3.1"]

Julian Leviston
  • 1,646
  • 10
  • 21