Skip to content

Instantly share code, notes, and snippets.

@johndaley-me
Last active January 29, 2016 19:48
Show Gist options
  • Save johndaley-me/ff23422df539c44a596a to your computer and use it in GitHub Desktop.
Save johndaley-me/ff23422df539c44a596a to your computer and use it in GitHub Desktop.
Run Mocha and Istanbul for node tests on Bamboo
echo 'Running server tests with coverage'
node server/testing/load_test_fixtures.js
# Refer to https://github.com/gotwarlost/istanbul/issues/44#issuecomment-16093330
# for issues around specific command syntax to run mocha with istanbul
# mocha -R xunit -O output=test-reports/mocha.xml 'server/testing/tests/**/*.js'
istanbul cover --report lcov --report clover _mocha -- -R xunit -O output=test-reports/mocha.xml 'tests/**/*.js'
# ensure that non-zero is returned for any failures
# because istanbul may return 0 even in case of a test failure
if [ -r test-reports/mocha.xml ]; then
# check results for failures
failures=$(grep --count '<failure' ./test-reports/mocha.xml)
if [ $failures -eq 0 ]; then
echo 'Server tests ran successfully'
else
echo 'Server tests failed. Test results are available.'
exit 1
fi
else
echo 'Server tests failed. No test results are available.'
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment