Skip to content

Instantly share code, notes, and snippets.

@leongaban
Created February 27, 2018 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leongaban/1cc5ab7c84013ab879b9dad028d21ead to your computer and use it in GitHub Desktop.
Save leongaban/1cc5ab7c84013ab879b9dad028d21ead to your computer and use it in GitHub Desktop.
Script to limit your tests coverage check to specific directories
#!/usr/bin/env bash
JEST=node_modules/jest/bin/jest.js
HELP_TEXT="\n\n\tPass a target with '-t' or '--target'.\n"
RED='\033[0;31m'
NC='\033[0m' # No Color
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-t|--target)
TARGET="$2"
shift # past argument
shift # past value
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
if [ -z ${TARGET+x} ]; then
echo -e "${RED}Give me a target${NC}$HELP_TEXT"
exit 1
fi
if [ -z ${TARGET} ]; then
echo -e "${RED}You gave me a flag... but no data?${NC}$HELP_TEXT"
exit 1
fi
$JEST --coverage $TARGET
exit 0
1 CommentCollapse 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment