Git hooks are basically scripts fired before an important action occurs, eg: before a commit is made, before code is pushed to a repo after a commit is made, etc. You can learn more about Git Hooks and the different kinds of hooks over here
We will use mocha and chai for testing. We will write a single test case for each of our functions. To learn more about mocha and chai in-depth, refer to this article.
You will get a bunch of questions, answer them based on your project. Finally, we will add a new command inside ‘scripts’ in ‘package.json’ You can add this under the ‘test’ command we added in the previous section.
If the linter returns an error or one of the test cases fails, the commit will be unsuccessful and your files will remain in the staging area and not be committed.