autotest-js.sh 720 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. #
  3. # ownCloud
  4. #
  5. # Run JS tests
  6. #
  7. # @author Vincent Petry
  8. # @copyright 2014 Vincent Petry <pvince81@owncloud.com>
  9. #
  10. NPM="$(which npm 2>/dev/null)"
  11. PREFIX="build"
  12. if test -z "$NPM"
  13. then
  14. echo 'Node JS >= 0.8 is required to run the JavaScript tests' >&2
  15. exit 1
  16. fi
  17. # update/install test packages
  18. mkdir -p "$PREFIX" && $NPM install --link --prefix "$PREFIX" || exit 3
  19. KARMA="$(which karma 2>/dev/null)"
  20. # If not installed globally, try local version
  21. if test -z "$KARMA"
  22. then
  23. KARMA="$PREFIX/node_modules/karma/bin/karma"
  24. fi
  25. if test -z "$KARMA"
  26. then
  27. echo 'Karma module executable not found' >&2
  28. exit 2
  29. fi
  30. NODE_PATH='build/node_modules' KARMA_TESTSUITE="$1" $KARMA start tests/karma.config.js --single-run