#!/bin/bash
set -o pipefail

MYDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ROOT=$MYDIR/..

pushd "$ROOT" >/dev/null
trap "popd >/dev/null" EXIT

OPTIONS=""
if [[ $MOBIFY_DEBUG = "true" ]]; then
    OPTIONS="--remote-debugger-port=9000 --debug=true --remote-debugger-autorun=true"
fi

# Returns the number of failed tests
"$ROOT/node_modules/.bin/phantomjs" $OPTIONS \
    "$ROOT/node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js" \
    "$ROOT/js/tests/index.html" \
    spec \
    "{ \"ignoreResourceErrors\": true }"


