GITHook Husky Angular

727 views Asked by At

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.

1

There are 1 answers

1
cagcak On

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" } }