Skip to content

Commit

Permalink
Add kaocha for unit testing cljs code
Browse files Browse the repository at this point in the history
  • Loading branch information
heralden committed Aug 28, 2019
1 parent fefc679 commit 2ede8e5
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ package-lock.json
prepros.cfg
/env/
/.clj-kondo/
/.cljs_node_repl/
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ build-and-ui-test:
script:
# setup dependencies
- npm install
# Run unit tests
- lein kaocha
# Build CSS
- lein less once
# ensure a minified build completes without error
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ before_script:
script:
# setup dependencies
- npm install
# Run unit tests
- lein kaocha
# Build CSS
- lein with-profile +java9 less once
# ensure a minified build completes without error
Expand Down
2 changes: 2 additions & 0 deletions bin/kaocha
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
lein kaocha "$@"
6 changes: 6 additions & 0 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ By default, the web server will be started on http://localhost:5000/. To change

## Running tests

### Unit tests

lein kaocha

### Cypress integration tests

Make sure BlueGenes is running by using `lein dev` or `lein prod`. (Preferably make sure they pass in *prod*, but *dev* can be useful for stack traces.)

Run all the Cypress tests:
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"dependencies": {
"@cljs-oss/module-deps": "^1.1.1",
"bootstrap": "^3.3.7",
"bootstrap-material-design": "git+https://github.com/intermine/bootstrap-material-design.git#im-0.0.2"
"bootstrap-material-design": "git+https://github.com/intermine/bootstrap-material-design.git#im-0.0.2",
"isomorphic-ws": "^4.0.1",
"ws": "^7.1.2"
},
"devDependencies": {
"cypress": "^3.4.0"
Expand Down
11 changes: 8 additions & 3 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,15 @@
["cljsbuild" "once" "min"]
["less" "once"]]
"prod" ["do" "build" ["pdo" ["run"]]]
"format" ["cljfmt" "fix"]}
"format" ["cljfmt" "fix"]
"kaocha" ["with-profile" "+kaocha" "run" "-m" "kaocha.runner"]}

:min-lein-version "2.8.1"

:source-paths ["src/clj" "src/cljs" "src/cljc" "src/workers" "script/"]

:test-paths ["test/cljs"]

:clean-targets ^{:protect false} ["resources/public/js/compiled" "target"
"resources/public/css"
"test/js"]
Expand All @@ -111,8 +114,10 @@
[cider/piggieback "0.4.1"]]
:resource-paths ["config/dev" "tools" "config/defaults"]
:plugins [[lein-figwheel "0.5.19"]
[lein-doo "0.1.8"]]
:source-paths ["env/dev"]}
[lein-doo "0.1.8"]]}
:kaocha {:dependencies [[lambdaisland/kaocha "0.0-529"]
[lambdaisland/kaocha-cljs "0.0-40"]]}
:repl {:source-paths ["env/dev"]}
:prod {:dependencies []
:resource-paths ["config/prod" "tools" "config/defaults"]
:plugins []}
Expand Down
5 changes: 5 additions & 0 deletions test/cljs/bluegenes/events_test.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(ns bluegenes.events-test
(:require [cljs.test :refer-macros [deftest is testing run-tests]]))

(deftest sample-test
(is (= 1 1)))
3 changes: 3 additions & 0 deletions tests.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#kaocha/v1
{:tests [{:id :unit-cljs
:type :kaocha.type/cljs}]}

0 comments on commit 2ede8e5

Please sign in to comment.