Skip to content

Instantly share code, notes, and snippets.

@stollcri
Created December 9, 2015 14:47
Show Gist options
  • Save stollcri/f33a8e9651cf75d2ca28 to your computer and use it in GitHub Desktop.
Save stollcri/f33a8e9651cf75d2ca28 to your computer and use it in GitHub Desktop.
Start Node.js and wait for it to be running, then run Mocha.js tests
# start node, silence output, and send to the background
npm start > /dev/null &
# give node a chance to start
if [ -f "$(which curl)" ]; then
LOOP_PASS=0
TEST_STAT="999"
# wait (maximum 15 seconds) until node is ready
while [ "$TEST_STAT" != "200" -a $LOOP_PASS -lt 15 ]; do
CURL_STAT=$(curl -sI http://localhost)
TEST_STAT=$(echo $CURL_STAT | head -n1 | awk '{print $2}')
((LOOP_PASS++))
sleep 1
done
else
sleep 5
fi
# run the test suite
npm run mocha-test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment