Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yamadapc/mocha-spec-cov-alt

A Mocha reporter, which extends the spec runner to display and (optionally) enforce blanket Code Coverage metrics
https://github.com/yamadapc/mocha-spec-cov-alt

Last synced: 3 months ago
JSON representation

A Mocha reporter, which extends the spec runner to display and (optionally) enforce blanket Code Coverage metrics

Awesome Lists containing this project

README

        

mocha-spec-cov-alt
==================
[![Gitter chat](https://badges.gitter.im/yamadapc/mocha-spec-cov-alt.png)](https://gitter.im/yamadapc/mocha-spec-cov-alt)
[![peerDependency Status](https://david-dm.org/yamadapc/mocha-spec-cov-alt/peer-status.svg)](https://david-dm.org/yamadapc/mocha-spec-cov-alt#info=peerDependencies)
[![Analytics](https://ga-beacon.appspot.com/UA-54450544-1/mocha-spec-cov-alt/README)](https://github.com/igrigorik/ga-beacon)
- - -

A Mocha reporter, which extends the `spec` runner to display and (optionally)
enforce blanket Code Coverage metrics. Applying it to other runners, should
be as simple as replacing the `.super_` `SpecCov` property.

I wrote a [blog post about it](http://blog.yamadapc.com.br/code-coverage-enforcement-for-nodejs)
a while back.

![screenshot](screenshot.png)

This was heavily inspired by Alex Seville's work on the
[`travis-cov`](https://github.com/alex-seville/travis-cov).

Install it with:
```
npm install mocha-spec-cov-alt
```

## Simple usage
The easiest way to set this up, right now, is to run:
```bash
$ npm i -g mocha-spec-cov-alt
# ...
/usr/local/bin/mocha-spec-cov-alt -> /usr/local/lib/node_modules/mocha-spec-cov-alt/bin/index.js
[email protected] /usr/local/lib/node_modules/mocha-spec-cov-alt
$ mocha-spec-cov-alt
Adding mocha-spec-cov-alt to your package.json... OK
Adding `mocha`, `mocha-spec-cov-alt` and `blanket` through npm:
[email protected] node_modules/mocha
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected], [email protected])

[email protected] node_modules/blanket
├── [email protected]
├── [email protected]
└── [email protected] ([email protected])
```

This will automatically add all the required nodes to your `package.json` file,
install the dependencies and quit. You can then run tests with `npm test`.

## Usage

To use it, add the key `"spec-cov"` to the `"config": { "blanket": {} }` node
in your `package.json` file. Currently supported options are:

- `threshold` - A global threshold to enforce. (defaults to 80)
- `localThreshold` - A local threshold to enforce.
- `lcovOutput` - A path to a file to output `lcov` data to, for use with
CodeClimate or CoverAlls. (by default, the file won't be generated)

You should then run mocha with:
```
mocha --require blanket -R mocha-spec-cov-alt
```

For more info on setting-up blanket, see: https://github.com/alex-seville/blanket

The annotated source is avaible at https://yamadapc.github.io/mocha-spec-cov-alt
and was generated with docco.

## License
Copyright (c) 2014 Pedro Tacla Yamada. Licensed under the MIT license.
Please refer to the [LICENSE](LICENSE) file for more info.

## Donations
Would you like to buy me a beer? Send bitcoin to 3JjxJydvoJjTrhLL86LGMc8cNB16pTAF3y