Skip to content

Commit

Permalink
Check for fit, fdescribe or .only in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kmaschta committed Jan 9, 2017
1 parent 808e645 commit 0ac5e55
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ build:
cp -Rf build examples/blog/
@echo "Files build/ng-admin.min.css and build/ng-admin.min.js updated (with minification)"

test: test-unit test-e2e
test: check-only-in-tests test-unit test-e2e

check-only-in-tests:
bash ./scripts/check-only-in-tests.sh

test-unit:
./node_modules/.bin/karma start src/javascripts/test/karma.conf.js --single-run
Expand Down
20 changes: 20 additions & 0 deletions scripts/check-only-in-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
SRC=$(git rev-parse --show-toplevel)
EXCLUDE="--exclude-dir 'node_modules' --exclude-dir '.git'"

#==========================================================
# Check if I forgot to remove 'only' keyword from tests.
# To make sure that before commit run all tests
only_command="grep -c -h -r $EXCLUDE -E \"(describe|it)\.only\" $SRC | awk -F ':' '{x +=\$0}; END {print x}'"
fonly_command="grep -c -h -r $EXCLUDE -E \"f(it|describe)\(\" $SRC | awk -F ':' '{x +=\$0}; END {print x}'"
only=`eval $only_command`
fonly=`eval $fonly_command`

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

0 comments on commit 0ac5e55

Please sign in to comment.