summaryrefslogtreecommitdiffstats
path: root/autotest-js.sh
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-01-12 18:57:53 +0100
committerVincent Petry <pvince81@owncloud.com>2014-01-16 17:12:29 +0100
commit350214c6093bbd300102a364f20caa91d23d5fb9 (patch)
tree90ebee0447a2bd667f2afe18bc6f234e831db726 /autotest-js.sh
parent85e00ad35a63d2d728140f3ece685d79d7a6140c (diff)
downloadnextcloud-server-350214c6093bbd300102a364f20caa91d23d5fb9.tar.gz
nextcloud-server-350214c6093bbd300102a364f20caa91d23d5fb9.zip
Added Javascript unit tests
- added karma utility to run jasmine unit tests - added Sinon library (for stubs/mocks/fakeserver) - added a few unit tests for core and files - added autotest-js.sh script
Diffstat (limited to 'autotest-js.sh')
-rwxr-xr-xautotest-js.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/autotest-js.sh b/autotest-js.sh
new file mode 100755
index 00000000000..78f4948e7ad
--- /dev/null
+++ b/autotest-js.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# ownCloud
+#
+# Run JS tests
+#
+# @author Vincent Petry
+# @copyright 2014 Vincent Petry <pvince81@owncloud.com>
+#
+NPM="$(which npm 2>/dev/null)"
+PREFIX="build"
+
+if test -z "$NPM"
+then
+ echo 'Node JS >= 0.8 is required to run the JavaScript tests' >&2
+ exit 1
+fi
+
+# update/install test packages
+mkdir -p "$PREFIX" && $NPM install --link --prefix "$PREFIX" || exit 3
+
+KARMA="$(which karma 2>/dev/null)"
+
+# If not installed globally, try local version
+if test -z "$KARMA"
+then
+ KARMA="$PREFIX/node_modules/karma/bin/karma"
+fi
+
+if test -z "$KARMA"
+then
+ echo 'Karma module executable not found' >&2
+ exit 2
+fi
+
+KARMA_TESTSUITE="$1" $KARMA start tests/karma.config.js --single-run
+