Skip to content

Instantly share code, notes, and snippets.

@viruschidai
Last active August 30, 2016 10:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viruschidai/31e4d2208d8a44b80a36 to your computer and use it in GitHub Desktop.
Save viruschidai/31e4d2208d8a44b80a36 to your computer and use it in GitHub Desktop.
git pre-commit hook to check if '.skip' or '.only' is used in mocha tests
filelist=$(git diff --cached --name-only --diff-filter=ACMR)
testfiles=$(echo "${filelist[@]}" | grep -E 'test\/.*\.coffee$' | grep -v node_modules)
if [[ ${testfiles[@]} ]]
then
echo
echo 'Checking if there are skipped tests ...'
echo
echo ${testfiles[@]} | xargs cat | grep -E '\.only|\.skip' && echo 'Error: contains skipped tests' && exit 1 || exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment