0

In our angular application we want to run "ng test" before we push the code to GIT. So do this we integrated with husky for GIT hook.

{ "hooks": { "pre-push": "npm run git-hook" } }

In package.json, below is mentioned "git-hook": "npm run test-headless".

I want to push the code to the rep only if all the test cases execute successfully but currently even if the test cases fail the code push is happening.

jmd_dk
  • 12,125
  • 9
  • 63
  • 94
Kiran
  • 1
  • 1

1 Answers1

0

you may want to accomplish that in pre-commit so if there are any failing tests, they would not be recorded in history until you resolve them. then you can try this;

"git-hook": "npm run test-headless"

{ "hooks": { "pre-commit": "CI=true npm run git-hook" } }

cagcak
  • 3,894
  • 2
  • 21
  • 22
  • Thank you for the reply, below is the error I am getting, husky > pre-push (node v6.10.3) 'CI' is not recognized as an internal or external command, operable program or batch file. husky > pre-push hook failed (add --no-verify to bypass) – Kiran Oct 18 '20 at 11:01