diff --git a/package.json b/package.json
index eb37601921af595d15a0c773c4070a767327e4e3..1a9eee6fa06f1e5bae24e1b08b09ea804e8fc874 100644
--- a/package.json
+++ b/package.json
@@ -28,6 +28,7 @@
     , "jwcrypto": "https://github.com/lloyd/jwcrypto/tarball/ace101"
   }
   , "scripts": {
-    "postinstall": "./scripts/generate_ephemeral_keys.sh"
+    "postinstall": "./scripts/generate_ephemeral_keys.sh",
+    "test": "./scripts/run_all_tests.sh"
   }
 }
diff --git a/scripts/run_all_tests.sh b/scripts/run_all_tests.sh
new file mode 100755
index 0000000000000000000000000000000000000000..ed6ab62f2f1afaa86b8cfe1974258dddb0e0d0bc
--- /dev/null
+++ b/scripts/run_all_tests.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
+BASEDIR=$(dirname $SCRIPT_DIR)
+export PATH=$PATH:$SCRIPT_DIR/../node_modules/.bin
+
+VOWS=`which vows 2> /dev/null`
+if [ ! -x "$VOWS" ]; then
+    echo "vows not found in your path.  try:  npm install"
+    exit 1
+fi
+
+# vows hates absolute paths.  sheesh.
+cd $BASEDIR
+
+for env in test_json test_mysql ; do
+  export NODE_ENV=$env
+  $SCRIPT_DIR/test_db_connectivity.js
+  if [ $? = 0 ] ; then 
+      echo "Testing with NODE_ENV=$env"
+      for file in browserid/tests/*.js ; do
+          echo $file
+          vows $file
+          if [[ $? != 0 ]] ; then
+              exit 1
+          fi
+      done
+  else
+      echo "CANNOT TEST '$env' ENVIRONMENT: can't connect to the database"
+  fi
+done
diff --git a/test.sh b/test.sh
index 7dec3f2b6fedfd6b8b16035156f1f5ff732ac050..b41801ed1cbc80f3f397258f877b52aa5a4e0910 100755
--- a/test.sh
+++ b/test.sh
@@ -1,23 +1,3 @@
-#!/bin/bash
+#!/bin/sh
 
-VOWS=`which vows 2> /dev/null`
-if [ ! -x "$VOWS" ]; then
-    echo "vows not found in your path.  try:  npm install -g vows"
-    exit 1
-fi
-
-for env in test_json test_mysql ; do
-  export NODE_ENV=$env
-  ./scripts/test_db_connectivity.js
-  if [ $? = 0 ] ; then 
-      echo "Testing with NODE_ENV=$env"
-      for file in browserid/tests/*.js ; do
-          vows $file
-          if [[ $? != 0 ]] ; then
-              exit 1
-          fi
-      done
-  else
-      echo "CANNOT TEST '$env' ENVIRONMENT: can't connect to the database"
-  fi
-done
+npm test