From 1cefaada58656b50d6c300d17059605c28115720 Mon Sep 17 00:00:00 2001 From: Varun Varada Date: Fri, 12 Jun 2020 19:30:53 -0500 Subject: [PATCH] fix: fix unit test script This commit fixes an issue with the unit test script where it could not be run without Mocha installed globally since there was a bug where the alias wasn't working, but if Mocha was installed globally, it would use that instance to run the tests. However, if Mocha is not installed globally, then it would fail because it pointed to the local instance of Mocha using a relative path that was in direct conflict with the relative path used to run the local instance of pm2. The npx command fixes these issues by finding the local instance of a npm binary regardless of what the current directory is. --- test/unit.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit.sh b/test/unit.sh index 66778ae9..0b25436a 100644 --- a/test/unit.sh +++ b/test/unit.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -alias mocha='../node_modules/.bin/mocha' +mocha="npx mocha" pm2="`type -P node` `pwd`/bin/pm2" function reset { @@ -12,7 +12,7 @@ function reset { function runUnitTest { echo "[~] Starting test $1" START=$(date +%s) - mocha --exit --bail $1 + $mocha --exit --bail $1 RET=$? if [ $RET -ne 0 ]; @@ -22,7 +22,7 @@ function runUnitTest { echo $STR >> unit_time reset - mocha --bail --exit $1 + $mocha --bail --exit $1 RET=$? if [ $RET -ne 0 ];