Files
habitica/test/run_tests.sh
T
Kevin Gisi 7bed1efb21 Revised Grunt translations task to use build:test
* Added build:test task to generate translation JS for tests.

* Removed test/spec/translations.js from the repository, added to .gitignore.

* Updated test/run_tests.sh to run build:test, and accept an optional argument
  to run a particular test suite.
2015-03-24 21:39:03 -04:00

60 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Configuration
TEST_DB=habitrpg_test
TEST_DB_URI="mongodb://localhost/$TEST_DB"
TEST_SERVER_PORT=3001
# Build assets
grunt build:test
# Launch Node server and Selenium
echo "= Recreating test database"
mongo "$TEST_DB" --eval "db.dropDatabase()"
if [ -z "$TRAVIS" ]; then
if [ -z "$1" ] || [ "$1" == "protractor" ]; then
./node_modules/protractor/bin/webdriver-manager update
./node_modules/protractor/bin/webdriver-manager start > /dev/null &
trap "curl http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer" EXIT
# Wait for selenium
MAX_WAIT=30
WAITED=0
until nc -z localhost 4444; do
if [ $WAITED -ge $MAX_WAIT ]; then
echo "Waited $MAX_WAIT seconds, but Selenium never responded" >&2
kill $NODE_PID
exit 1
fi
sleep 1
let 'WAITED+=1'
done
fi
fi
NODE_DB_URI="$TEST_DB_URI" PORT=$TEST_SERVER_PORT node ./website/src/server.js > /dev/null &
NODE_PID=$!
trap "kill $NODE_PID" EXIT
if [ -z "$1" ] || [ "$1" == "mocha" ]; then
echo "= Running mocha specs"
NODE_ENV=testing mocha || exit $?
fi
# If we're only running protractor, we need to let the server spin up.
if [ "$1" == "protractor" ]; then
sleep 2
fi
if [ -z "$TRAVIS" ]; then
if [ -z "$1" ] || [ "$1" == "protractor" ]; then
echo "= Running protractor specs"
NODE_ENV=testing ./node_modules/protractor/bin/protractor protractor.conf.js || exit $?
fi
fi
if [ -z "$1" ] || [ "$1" == "karma" ]; then
echo "= Running karma specs"
NODE_ENV=testing grunt karma:continuous || exit $?
fi