UNPKG

821 Bapplication/x-shView Raw
1#!/bin/bash
2
3set -e
4
5RED='\033[0;31m'
6YELLOW='\033[0;33m'
7NC='\033[0m' # No Color
8
9ENV=${NODE_ENV:-test}
10if [[ $ENV != "test" ]]; then
11 echo -e "${RED}ERROR${NC}: Cannot run unit tests out of the test environment"
12 exit 1
13fi
14
15TEST_COUNT=${1:-}
16
17STATUS_RESPONSE=$(git status)
18NOT_STAGED_FOR_COMMIT="^.*not staged for commit.*$"
19UNTRACKED_FILES="^.*Untracked files.*$"
20if [[ $TEST_COUNT != "watch" && ($STATUS_RESPONSE =~ $NOT_STAGED_FOR_COMMIT || $STATUS_RESPONSE =~ $UNTRACKED_FILES) ]]; then
21 echo -e "${YELLOW}WARNING${NC}: You have unstaged changes. These tests might not have correct results."
22fi
23
24if [[ $TEST_COUNT == "watch" ]]; then
25 node_modules/.bin/mocha-typescript-watch -p tsconfig.json "dist/**/*.spec.js"
26else
27 node_modules/.bin/mocha --require ts-node/register "src/**/*.spec.ts"
28fi
29
30exit 0