Skip to content

Instantly share code, notes, and snippets.

@willmorgan
Created January 8, 2018 15:13
Show Gist options
  • Save willmorgan/89682dbebe3e5260a87a9a999d1f569b to your computer and use it in GitHub Desktop.
Save willmorgan/89682dbebe3e5260a87a9a999d1f569b to your computer and use it in GitHub Desktop.
Checks for accidental .only blocks inside tests
set +e
# Check for accidental `.only` blocks inside tests, and fail the tests if any are found:
ACCIDENTAL_ONLY=$(grep -R -m 1 --include="*.js" --exclude-dir=node_modules --exclude-dir=.git "\.only" . 2>&1)
HAS_ACCIDENTAL_ONLY=$?
set -e
if [ $HAS_ACCIDENTAL_ONLY == 0 ];
then
echo "Found a \`.only\` block inside the tests; failing CI build. Details below:"
echo ${ACCIDENTAL_ONLY}
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment