habitica/test/run_tests.sh
Kevin Gisi f41933b7a1 Repair Broken Test Suite - Full Passing Tests
* Repair broken e2e test introduced in 8d03cfc (copywriting change was not
  reflected in the spec)

* Updated i18n.coffee code to be more cautious (it expected the 'en' locale
  would always be available, but provides appropriate error handling as-is).

* Extended timeout duration for protractor, as registration was slightly above
  30s.

* Added karma-mocha-reporter as a dev dependency to ensure test visibility.
2015-03-24 21:39:03 -04:00

46 lines
1.2 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:dev
# Launch Node server and Selenium
echo "= Recreating test database"
mongo "$TEST_DB" --eval "db.dropDatabase()"
if [ -z "$TRAVIS" ]; 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
NODE_DB_URI="$TEST_DB_URI" PORT=$TEST_SERVER_PORT node ./website/src/server.js > /dev/null &
NODE_PID=$!
trap "kill $NODE_PID" EXIT
echo "= Running mocha specs"
NODE_ENV=testing mocha || exit $?
if [ -z "$TRAVIS" ]; then
echo "= Running protractor specs"
NODE_ENV=testing ./node_modules/protractor/bin/protractor protractor.conf.js || exit $?
fi
echo "= Running karma specs"
NODE_ENV=testing grunt karma:continuous