I have seen Angular projects in which the unit tests are run every time a build is executed and also when running the git push command. If any tests fail during either command, the process does not execute until all your unit tests pass or unless you bypass. I would like to have this kind of set up for my project as best practice. Please help :)
To run builds, unit tests, etc before a commit or a push you can use a tool like Husky.
Git provides a methodology to hook it's events using .git/hooks
you can add a folder to your project called .git/hooks
and within that folder add a subfolder called pre-commit
and within that you may place scripts that are to be ran. This being whatever your test command is.
For example test.sh would contain: ng test
More documentation about hooking git events can be found here: https://git-scm.com/docs/githooks
Let me know if you have any questions, I would be happy to revise my answer!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With