Skip to content

Instantly share code, notes, and snippets.

@benhorst
Created December 13, 2017 19:53
Show Gist options
  • Save benhorst/8162949afb39d71fc55fa4389ee9daa9 to your computer and use it in GitHub Desktop.
Save benhorst/8162949afb39d71fc55fa4389ee9daa9 to your computer and use it in GitHub Desktop.
We use Mocha for 'describe' and 'it' blocks. Sometimes we use 'describe.only' locally, but we want to be sure not to push it! (also a good pre-commit hook)
#!/bin/sh
# README: remember to chmod +x this file, save the contents to `my-project/.git/hooks/pre-push`
echo "HOOK PRE-PUSH: Checking for describe.only in test files..."
count=$(grep describe.only src/**/*.test.js | wc -l)
if [ "$count" -eq 0 ]
then
echo "No describe.only blocks found.\n"
exit 0
fi
echo "Found $count describe.only blocks\n"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment