Skip to content

Commit db35496

Browse files
committed
fix: avoid killing all java processes + trap ctrl+c and kill mockserver + run nightwatch locally (remove requirements of global nightwatch)
1 parent 5f8814d commit db35496

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

runTests.sh

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,42 @@
11
#!/usr/bin/env bash
22

3-
if ! which nightwatch ; then
4-
echo "Nightwatch not installed globally. This is necessary for running tests"
5-
echo "npm install nightwatch -g"
3+
if [ ! -f ./node_modules/.bin/nightwatch ]; then
4+
echo "Nightwatch not installed. This is necessary for running tests"
5+
echo "Run `npm install` to install it locally"
66
exit 1
77
fi
88

99
NIGHTWATCH_ENV=${NIGHTWATCH_ENV:-default}
1010

1111
#Run background jobs
12+
echo "Starting mockserver..."
1213
java -Droot.logLevel=OFF -Dmockserver.logLevel=OFF -jar tests/mockserver-netty-3.9.17-jar-with-dependencies.jar -serverPort 9999 > /dev/null 2>&1 &
14+
MOCKSERVER_PID=$!
1315
sleep 3
1416

17+
trap ctrl_c INT
18+
function ctrl_c() {
19+
echo "Killing mockserver..."
20+
kill $MOCKSERVER_PID > /dev/null 2>&1
21+
wait
22+
23+
exit 1
24+
}
25+
1526
cd tests
1627

1728
#Set the urls of the mockserver
29+
echo "Creating mocks..."
1830
node setMocks.js
1931

2032
#Run tests
21-
nightwatch --test --env "$NIGHTWATCH_ENV"
33+
../node_modules/.bin/nightwatch --test --env "$NIGHTWATCH_ENV"
2234
status_nightwatch=$?
2335

2436
cd ..
2537

26-
#Kill background jobs
27-
killall java
38+
echo "Killing mockserver..."
39+
kill $MOCKSERVER_PID > /dev/null 2>&1
2840
wait
2941

3042
if [[ ${status_nightwatch} != 0 ]] ; then

0 commit comments

Comments
 (0)