exogenesick / istanbul-coverage-slack

Sends tests coverage reports on Slack webhook
3 stars 1 forks source link

istanbul-coverage-slack

Sends coverage reports on Slack webhook.

Build Status Coverage Status

Install

npm i --save-dev istanbul-coverage-slack

Before You run

Make sure You configure webhook on Your Slack team https://api.slack.com/incoming-webhooks

Put file shout.json (example below) into root directory of Your project.

{
  "reports": {
    "files": ["coverage/coverage.json"]
  },
  "slack": {
    "username": "Chuck Norris",
    "channel": "reports",
    "icon": "https://s3-us-west-2.amazonaws.com/slack-files2/bot_icons/2016-06-16/51472942259_48.png",
    "timeout": 5000
  },
  "thresholds": [
    {
      "percent": 100,
      "words": "excellent",
      "color": "good"
    },
    {
      "percent": 80,
      "words": "nice",
      "color": "warning"
    },
    {
      "percent": 50,
      "words": "do it better",
      "color": "warning"
    },
    {
      "percent": 40,
      "words": "mad",
      "color": "danger"
    },
    {
      "percent": 0,
      "words": "crap",
      "color": "danger"
    }
  ]
}

Notice: Coverage report for You project must be generated. If not generate coverage report via istanbul. This coverage report should correspond with reports.files section located in shout.json.

Run

Inside Your project root directory You can use on of following run sequence.

Via arguments

./node_modules/.bin/shout --SLACK_WEBHOOK_URL=https://hooks.slack.com/...

Via env variables

export SLACK_WEBHOOK_URL=https://hooks.slack.com/... && ./node_modules/.bin/shout

Via npm task

...
"shout": "./node_modules/.bin/shout",
...
export SLACK_WEBHOOK_URL=https://hooks.slack.com/... && npm run shout

Additional parameters

You can also override shout.json factors

This will send coverage report into Slack webhook and Your message should look like below

Message example

Debug

If You have troubles with receiving messages launch for more information about any issues.

./node_modules/.bin/shout --LOG=debug