diff --git a/.gitignore b/.gitignore index d67897d..4c26e3d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ misc/ /examples/simple/resources/public/js/ .floo .flooignore +node_modules/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cc43f08..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: clojure -lein: lein2 -script: "lein2 test-slimer" -sudo: false -env: - - SLIMERJSLAUNCHER=$(which firefox) DISPLAY=:99.0 PATH=$TRAVIS_BUILD_DIR/slimerjs:$PATH -addons: - firefox: "34.0" -before_script: - - "echo 'Installing Slimer'" - - "wget http://download.slimerjs.org/releases/0.9.4/slimerjs-0.9.4.zip" - - "unzip slimerjs-0.9.4.zip" - - "mv slimerjs-0.9.4 ./slimerjs" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ce7cc6a..f16f783 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,6 +24,16 @@ Use your best judgement on what is needed here. **Create pull requests to the develop branch**, work will merged onto master when it is ready to be released. +## Running the tests + +To run the tests: + +``` +lein deps # will run lein-npm and install Karma and other node dependencies. Only needed the first time. +lein once # or lein auto # to build re-frame +karma start # to run the tests with an auto watcher +``` + ## Pull requests for bugs If possible provide: diff --git a/README.md b/README.md index 646e8d9..afd7f54 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # re-frame: Derived Values, Flowing +[![Circle CI](https://circleci.com/gh/Day8/re-frame.svg?style=svg)](https://circleci.com/gh/Day8/re-frame) > This, milord, is my family's axe. We have owned it for almost nine hundred years, see. Of course, sometimes it needed a new blade. And sometimes it has required a new handle, new designs on the diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..8afbe8f --- /dev/null +++ b/circle.yml @@ -0,0 +1,14 @@ +dependencies: + pre: + - npm install karma-cli -g + # To install Chrome 47. Remove once a new build environment comes out with this built in. + - curl -L -o google-chrome.deb https://s3.amazonaws.com/circle-downloads/google-chrome-stable_current_amd64_47.0.2526.73-1.deb + - sudo dpkg -i google-chrome.deb + - sudo sed -i 's|HERE/chrome\"|HERE/chrome\" --disable-setuid-sandbox|g' /opt/google/chrome/google-chrome + - rm google-chrome.deb + cache_directories: + - node_modules +test: + override: + - lein once + - karma start --single-run --reporters junit,dots diff --git a/examples/todomvc/.gitignore b/examples/todomvc/.gitignore new file mode 100644 index 0000000..0247ec9 --- /dev/null +++ b/examples/todomvc/.gitignore @@ -0,0 +1 @@ +resources/public/js diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000..ee994f7 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,24 @@ +module.exports = function (config) { + var root = 'run/compiled/test'; // same as :output-dir + var junitOutputDir = process.env.CIRCLE_TEST_REPORTS || "run/compiled/test/junit"; + + config.set({ + frameworks: ['cljs-test'], + browsers: ['Chrome'], + files: [ + root + '/../test.js', // same as :output-to + {pattern: root + '/../test.js.map', included: false} + ], + + client: { + args: ['re_frame.test.runner.run'] + }, + + // the default configuration + junitReporter: { + outputDir: junitOutputDir + '/karma', // results will be saved as $outputDir/$browserName.xml + outputFile: undefined, // if included, results will be saved as $outputDir/$browserName/$outputFile + suite: '' // suite will become the package name attribute in xml testsuite element + } + }) +}; diff --git a/project.clj b/project.clj index c05f8b8..6fe0011 100644 --- a/project.clj +++ b/project.clj @@ -6,39 +6,34 @@ [org.clojure/clojurescript "1.7.170"] [reagent "0.5.1"]] - :profiles {:debug {:debug true} - :dev {:plugins [[lein-cljsbuild "1.1.1"] - [lein-figwheel "0.3.8"] - [com.cemerick/clojurescript.test "0.3.3"]]}} - + :profiles {:debug {:debug true} + :dev {:dependencies [[karma-reporter "0.3.0"]] + :plugins [[lein-cljsbuild "1.1.1"] + [lein-npm "0.6.1"] + [lein-figwheel "0.3.8"]]}} :clean-targets [:target-path "run/compiled/demo"] :resource-paths ["run/resources"] - :jvm-opts ["-Xmx1g" "-XX:+UseConcMarkSweepGC"] ;; + :jvm-opts ["-Xmx1g" "-XX:+UseConcMarkSweepGC"] :source-paths ["src"] :test-paths ["test"] :deploy-repositories [["releases" :clojars] ["snapshots" :clojars]] + :npm {:dependencies [[karma "https://github.com/danielcompton/karma/archive/v0.13.15.tar.gz"] + [karma-cljs-test "0.1.0"] + [karma-chrome-launcher "0.2.0"] + [karma-junit-reporter "0.3.8"]]} - :cljsbuild {:builds [{:id "test" ;; currently bogus, there is no demo or tests - :source-paths ["test"] - :compiler {:output-to "run/compiled/test.js" - :source-map "run/compiled/test.js.map" - :output-dir "run/compiled/test" - :optimizations :simple - :pretty-print true}}] + :cljsbuild {:builds [{:id "test" + :source-paths ["test"] + :compiler {:output-to "run/compiled/test.js" + :source-map "run/compiled/test.js.map" + :output-dir "run/compiled/test" + :optimizations :simple + :pretty-print true}}]} - :test-commands {"rhino" ["rhino" "-opt" "-1" :rhino-runner - "run/compiled/test.js"] - "slimer" ["xvfb-run" "-a" "slimerjs" :runner - "run/compiled/test.js"] - "phantom" ["phantomjs" ; doesn't work with phantomjs < 2.0.0 - :runner "run/compiled/test.js"]}} - - :aliases {"auto" ["do" "clean," "cljsbuild" "clean," "cljsbuild" "auto" "demo,"] - "once" ["do" "clean," "cljsbuild" "clean," "cljsbuild" "once" "demo,"] - "test-rhino" ["do" "clean," "cljsbuild" "once," "cljsbuild" "test" "rhino"] - "test-slimer" ["do" "clean," "cljsbuild" "once," "cljsbuild" "test" "slimer"] }) + :aliases {"auto" ["do" "clean," "cljsbuild" "auto" "test,"] + "once" ["do" "clean," "cljsbuild" "once" "test,"] }) diff --git a/test/re-frame/middleware.cljs b/test/re-frame/test/middleware.cljs similarity index 92% rename from test/re-frame/middleware.cljs rename to test/re-frame/test/middleware.cljs index 12f07ab..8176ac6 100644 --- a/test/re-frame/middleware.cljs +++ b/test/re-frame/test/middleware.cljs @@ -1,6 +1,5 @@ (ns re-frame.test.middleware - (:require-macros [cemerick.cljs.test :refer (is deftest)]) - (:require [cemerick.cljs.test :as t] + (:require [cljs.test :refer-macros [is deftest]] [reagent.ratom :refer [atom]] [re-frame.middleware :as middleware])) diff --git a/test/re-frame/test/test_runner.cljs b/test/re-frame/test/test_runner.cljs new file mode 100644 index 0000000..dc06e66 --- /dev/null +++ b/test/re-frame/test/test_runner.cljs @@ -0,0 +1,9 @@ +(ns re-frame.test.runner + (:require [jx.reporter.karma :as karma :include-macros true] + [re-frame.test.middleware])) + + +(defn ^:export run [karma] + (karma/run-tests + karma + 're-frame.test.middleware))