alexis-j
7/19/2016 - 7:14 AM

Pre-commit hook (warn if you have it.only, describe.only, fit or fdescribe)

Pre-commit hook (warn if you have it.only, describe.only, fit or fdescribe)

#!/bin/sh
SRC=$(git rev-parse --show-toplevel)
#==========================================================
# Check if I forgot to remove 'only' keyword from tests.
# To make sure that before commit run all tests
only=`grep -c -h -r --include "*.spec.js" -E "(describe|it)\.only" $SRC | awk -F ':' '{x +=$0}; END {print x}'`
fonly=`grep -c -h -r --include "*.spec.js" -E "f(it|describe)\(" $SRC | awk -F ':' '{x +=$0}; END {print x}'`

if (( $((only + fonly)) > 0 ))
then
  echo 'Remove ONLY from tests.'
  # Output list of found only entries
  grep -r -n --include "*.spec.js" -E "(describe|it)\.only" $SRC
  grep -r -n --include "*.spec.js" -E "f(it|describe)\(" $SRC
  exit 1
fi