Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Latest commit

 

History

History
30 lines (26 loc) · 1.27 KB

testing_workflow.md

File metadata and controls

30 lines (26 loc) · 1.27 KB

Husky hooks

You can configure your project to run linting and tests prior for certain git actions with husky. That way you can ensure your quality checks pass before you, for instance, commit or push.

Setup

... is done quickly.

Make sure your project already has a Git repository. Otherwise just create one with:

git init

Install husky using npm and save it as a dev-dependency:

npm install husky --save-dev

Extend the scripts property of your package.json with all the hooks you want:

{
  "scripts": {
    // ...
    "precommit": "gulp linting-throw",
    "prepush": "gulp linting-throw && gulp karma && gulp protractor",
  }
}

The above example will run ESLint and JSONLint checks when you git commit and additionally Karma tests when you git push.

Additional information on gulp tasks

gulp linting-throw

The gulp linting-throw task will run linting checks and throw an error on failed checks. The gulp linting on the other hand will perform checks, report errors on the command line but not throw an error. Thus it would successfully pass the hook even when there's linting issues.