我試圖運行與我不能運行基本clojurescript.test樣品
https://github.com/cemerick/clojurescript.test
一個基本的測試我創建了一個簡單的項目,如:
(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"]}}
)
因爲我打算把我所有的clojurescript文件放在那裏,所以兩個文件夾src-js和test-js都存在。
在我測試JS/sampleproj文件夾複製我的文檔中的樣品測試:
(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)))))
現在,如果我嘗試運行測試
-> % 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
我是相當新clojurescript所以可能我錯過了一些東西。
更新:
我的環境
-> % 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)
我試圖重現,但所有的測試用例運行成功,沒有任何錯誤。 Lein版本2.3.4,phantomjs版本1.9.2和java版本1.7.0。幻影在路徑中? http://phantomjs.org/ – jittakal
看起來我的環境和你的環境完全一樣。我更新了這個問題。這很奇怪。 –
我只是想說,我有完全相同的問題。版本信息:$ lein -v Leiningen 2.3.4在Java 1.6.0_27上OpenJDK 64位服務器VM $ phantomjs -v 1.9.7 – user1500409