zulip/tools/test-js-with-node

29 lines
972 B
Bash
Executable File

#!/usr/bin/env bash
set -e
cd "$(dirname "$0")"/..
export NODE_PATH=/usr/lib/nodejs:static
export PATH=$PATH:node_modules/.bin
INDEX_JS=frontend_tests/zjsunit/index.js
NODEJS=$(which nodejs || which node)
if [ "$1" = "cover" ]; then
# Run a coverage test with Istanbul.
istanbul cover "$INDEX_JS" && echo "Test(s) passed. SUCCESS!" || (echo "FAIL - Test(s) failed"; exit 1)
elif [ "$1" = "-h" -o "$1" = "--help" ]; then
echo "Usage:
`basename $0` - to run all tests
`basename $0` util.js - to run tests from util.js
`basename $0` util.js activity.js - to run tests from util.js and activity.js
`basename $0` cover - to run tests and generate code coverage
"
exit 0
else
# Normal testing, no coverage analysis.
# Run the index.js test runner, which runs all the other tests.
"$NODEJS" --stack-trace-limit=100 "$INDEX_JS" $@ && echo "Test(s) passed. SUCCESS!" || (echo "FAIL - Test(s) failed"; exit 1)
fi