Skip to content

Commit

Permalink
Add test scripts - requires npm install
Browse files Browse the repository at this point in the history
  • Loading branch information
ggeoffrey committed Apr 15, 2022
1 parent f68af86 commit 7f58eb3
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 7 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: clojure -A:test -P

- name: Run tests
run: clojure -X:test :dirs "[\"src\" \"src-docs\" \"test\"]" :patterns "[\"hyperfiddle.photon-impl.*\" \"hyperfiddle.photon-test\"]"
run: ./ci/run_tests_jvm.sh

photon-nodejs:
# if: ${{ false }} # Disabled until we fix the cljs test suite locally
Expand Down Expand Up @@ -93,8 +93,5 @@ jobs:
- name: Install Shadow
run: npm install shadow-cljs

- name: Compile Tests
run: ./node_modules/.bin/shadow-cljs -A:test compile :test

- name: Run Tests
run: node out/node-tests.js
run: ./ci/run_tests_node.sh
4 changes: 4 additions & 0 deletions ci/run_tests_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

./run_tests_jvm.sh
./run_tests_node.sh
5 changes: 5 additions & 0 deletions ci/run_tests_browser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

echo "Running Browser tests"
./node_modules/.bin/shadow-cljs -A:test compile :browser-test
./node_modules/.bin/karma start --single-run
1 change: 1 addition & 0 deletions run_tests.sh → ci/run_tests_jvm.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash

echo "Running JVM tests"
clojure -X:test :dirs "[\"src\" \"src-docs\" \"test\"]" :patterns "[\"hyperfiddle.photon-impl.*\" \"hyperfiddle.photon-test\"]"
5 changes: 5 additions & 0 deletions ci/run_tests_node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

echo "Running NodeJS tests"
./node_modules/.bin/shadow-cljs -A:test compile :test
node out/node-tests.js
8 changes: 8 additions & 0 deletions ci/running_dom_tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# How to run tests in a browser during dev time

## Running once
Use the `run_tests_browser.sh` script.

## Live reloading
1. Start a watch build for `:browser-test` (either in shadow ui, or `shadow-cljs -A:test watch :browser-test`)
2. Run `./node_modules/.bin/karma start --browsers Chrome`
18 changes: 18 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
process.env.CHROMIUM_BIN = require('puppeteer').executablePath()
module.exports = function (config) {
config.set({
browsers: ['ChromiumHeadless'],
// The directory where the output file lives
basePath: 'out',
// The file itself
files: ['karma-tests.js'],
frameworks: ['cljs-test'],
plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
colors: true,
logLevel: config.LOG_INFO,
client: {
args: ["shadow.test.karma.init"],
singleRun: true
}
});
};
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
"postcss": "^8.2.13",
"postcss-cli": "^8.3.1",
"tailwindcss": "^2.1.2",
"typescript": "^4.2.4"
"typescript": "^4.2.4",
"karma": "6.3.17",
"karma-chrome-launcher": "3.1.1",
"karma-cljs-test": "0.1.0",
"puppeteer": "13.5.2",
"shadow-cljs": "2.16.4"
}
}
9 changes: 8 additions & 1 deletion shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@
:build-options {:cache-level :off}
:modules {:main {:entries [hyperfiddle.photon hyperfiddle.photon-test]}}
:dev {:closure-defines {hyperfiddle.dev.logger/LEVEL "debug"}}
:compiler-options {:warnings {:redef-in-file false}}}}}
:compiler-options {:warnings {:redef-in-file false}}}
:browser-test {:target :karma
:output-to "out/karma-tests.js"
:ns-regexp "^hyperfiddle.photon-.*$"
:build-options {:cache-level :off}
:modules {:main {:entries [hyperfiddle.photon hyperfiddle.photon-test]}}
:dev {:closure-defines {hyperfiddle.dev.logger/LEVEL "debug"}}
:compiler-options {:warnings {:redef-in-file false}}}}}

0 comments on commit 7f58eb3

Please sign in to comment.