Giter Club home page Giter Club logo

node-coverage-badge's Introduction

Generate fancy code coverage badges! Does what it says on the tin.

100% coverage 95% coverage 85% coverage

Works like this:

$ node coverage-badge 95 coverage.png

... or like this:

var fs = require('fs');
var badge = require('coverage-badge');

var coverage = /* read coverage from JSON or whatever */;
var file = fs.createWriteStream('coverage.png');

badge(coverage).pipe(file);

Tie it in with build tool and let your continuous integration tool call that build step and archive the image.

Example

An example: node-aether uses Drone.io as CI server and slake as build tool. The relevant build step runs jscoverage to instrument, then runs mocha to generate a JSON code coverage report, and then uses that to generate the coverage badge. That last bit looks like this (rewritten from the original LiveScript):

var badge = require('coverage-badge');

task 'cov-badge', function() {
  /* [run jscoverage...] */
  /* [run mocha...] */
  mocha.on('close'), function() {
    var json = require('./coverage.json');
    var file = fs.createWriteStream('./coverage.png');
    badge(json.coverage).pipe(file);
  }
}

At each build, Drone.io runs these commands:

sudo apt-get install jscoverage
slake cov-badge

... and then saves ./coverage.png as a build artefact. The image can then be found under the Downloads tab. The result: Code Coverage for node-aether

Visual theme

Currently it pretty much mimics the look of the Drone.io badge. Other styles may be added in the future.

Installation

npm install coverage-badge

License

Simplified BSD (2-clause).

node-coverage-badge's People

Contributors

ppvg avatar ashaffer avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.