| 1 | #!/bin/bash |
| 2 | # Starts the http-server and runs mocha-phantomjs-based tests |
| 3 | # Note that you must run `npm run build` or `npm run watch` before running this. |
| 4 | # Additional arguments are passed to mocha-phantomjs, e.g. |
| 5 | # run-tests.sh --grep interaction-model |
| 6 | set -o errexit |
| 7 | |
| 8 | # Run http-server and save its PID |
| 9 | http-server -p 8081 > /dev/null & |
| 10 | SERVER_PID=$! |
| 11 | function finish() { |
| 12 | kill -TERM $SERVER_PID |
| 13 | } |
| 14 | trap finish EXIT |
| 15 | |
| 16 | # the following sleep step is not really necessary |
| 17 | # as http-server starts almost instantenously; |
| 18 | # but letting the server settle might help prevent |
| 19 | # possible racing conditions |
| 20 | sleep 1 |
| 21 | |
| 22 | # Start the tests |
| 23 | mocha-phantomjs http://localhost:8081/auto_tests/runner.html "$@" |