consolidating scripts
[dygraphs.git] / scripts / run-tests.sh
diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh
new file mode 100755 (executable)
index 0000000..4b1c77f
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+# Starts the http-server and runs mocha-phantomjs-based tests
+# Note that you must run `npm run build` or `npm run watch` before running this.
+set -o errexit
+
+# Run http-server and save its PID
+http-server -p 8081 > /dev/null &
+SERVER_PID=$!
+function finish() {
+  kill -TERM $SERVER_PID
+}
+trap finish EXIT
+
+# the following sleep step is not really necessary
+# as http-server starts almost instantenously;
+# but letting the server settle might help prevent
+# possible racing conditions
+sleep 1
+
+# Start the tests
+mocha-phantomjs http://localhost:8081/auto_tests/runner.html