Switch to using CircleCI and automated testing with Karma

- Remove travis config
- Add CircleCI config and badge
- Add docs on running the tests
- Create a test runner
- Add npm dependencies and gitignore
This commit is contained in:
Daniel Compton 2015-12-10 17:26:06 +13:00
parent 8c01555a6a
commit 3334297f23
10 changed files with 80 additions and 39 deletions

1
.gitignore vendored
View File

@ -18,3 +18,4 @@ misc/
/examples/simple/resources/public/js/ /examples/simple/resources/public/js/
.floo .floo
.flooignore .flooignore
node_modules/

View File

@ -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"

View File

@ -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. **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 ## Pull requests for bugs
If possible provide: If possible provide:

View File

@ -1,5 +1,6 @@
# re-frame: Derived Values, Flowing # 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, > 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 sometimes it needed a new blade. And sometimes it has required a new handle, new designs on the

14
circle.yml Normal file
View File

@ -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

1
examples/todomvc/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
resources/public/js

24
karma.conf.js Normal file
View File

@ -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
}
})
};

View File

@ -6,39 +6,34 @@
[org.clojure/clojurescript "1.7.170"] [org.clojure/clojurescript "1.7.170"]
[reagent "0.5.1"]] [reagent "0.5.1"]]
:profiles {:debug {:debug true} :profiles {:debug {:debug true}
:dev {:plugins [[lein-cljsbuild "1.1.1"] :dev {:dependencies [[karma-reporter "0.3.0"]]
[lein-figwheel "0.3.8"] :plugins [[lein-cljsbuild "1.1.1"]
[com.cemerick/clojurescript.test "0.3.3"]]}} [lein-npm "0.6.1"]
[lein-figwheel "0.3.8"]]}}
:clean-targets [:target-path :clean-targets [:target-path
"run/compiled/demo"] "run/compiled/demo"]
:resource-paths ["run/resources"] :resource-paths ["run/resources"]
:jvm-opts ["-Xmx1g" "-XX:+UseConcMarkSweepGC"] ;; :jvm-opts ["-Xmx1g" "-XX:+UseConcMarkSweepGC"]
:source-paths ["src"] :source-paths ["src"]
:test-paths ["test"] :test-paths ["test"]
:deploy-repositories [["releases" :clojars] :deploy-repositories [["releases" :clojars]
["snapshots" :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 :cljsbuild {:builds [{:id "test"
:source-paths ["test"] :source-paths ["test"]
:compiler {:output-to "run/compiled/test.js" :compiler {:output-to "run/compiled/test.js"
:source-map "run/compiled/test.js.map" :source-map "run/compiled/test.js.map"
:output-dir "run/compiled/test" :output-dir "run/compiled/test"
:optimizations :simple :optimizations :simple
:pretty-print true}}] :pretty-print true}}]}
:test-commands {"rhino" ["rhino" "-opt" "-1" :rhino-runner :aliases {"auto" ["do" "clean," "cljsbuild" "auto" "test,"]
"run/compiled/test.js"] "once" ["do" "clean," "cljsbuild" "once" "test,"] })
"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"] })

View File

@ -1,6 +1,5 @@
(ns re-frame.test.middleware (ns re-frame.test.middleware
(:require-macros [cemerick.cljs.test :refer (is deftest)]) (:require [cljs.test :refer-macros [is deftest]]
(:require [cemerick.cljs.test :as t]
[reagent.ratom :refer [atom]] [reagent.ratom :refer [atom]]
[re-frame.middleware :as middleware])) [re-frame.middleware :as middleware]))

View File

@ -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))