Search code examples
angulargithookshuskygit-husky

How to configure husky pre-push hook to run tests


I am trying to configure husky pre-push hook to run tests before push. Everything looks fine. After run git push origin hook is fired and tests are runing. Problem is that when tests are done and even if operation is successed, push is freezed and nothing else happened.

package.json

  "scripts": {
    ...
    "pre-commit": "npm run lint",
    "pre-push": "npm run test"
  }

.husky/pre-push

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run pre-push

enter image description here


Solution

  • By default unit tests run in watch mode. You can override this by doing ng test --watch=false