jscoverage: update

This commit is contained in:
Rico Sta. Cruz 2017-10-29 20:03:37 +08:00
parent a4238ddcee
commit 3ee6f48ed2
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 30 additions and 11 deletions

View File

@ -1,32 +1,51 @@
--- ---
title: jscoverage title: jscoverage
category: JavaScript libraries category: JavaScript libraries
layout: 2017/sheet
intro: |
A small guide into installing [jscoverage](https://npmjs.com/package./jscoverage). Also see [mocha-blanket](./mocha-blanket).
--- ---
Also see [mocha-blanket](mocha-blanket.html).
### Install ### Install
npm install --save-dev jscoverage #### Install via npm
### Ignore output ```bash
npm install --save-dev jscoverage
```
echo coverage.html >> .gitignore #### Ignore output
```bash
echo coverage.html >> .gitignore
```
### package.json ### package.json
The `coverage` task injects your source files (`lib`) with jscoverage hooks, runs `mocha -R html-cov`, then restores later. The `coverage` task injects your source files (`lib`) with jscoverage hooks, runs `mocha -R html-cov`, then restores later.
{: .-setup}
/* directory */ ```bash
"coverage": "mv lib lib~; (jscoverage lib~ lib; mocha -R html-cov > coverage.html); rm -rf lib; mv lib~ lib" /* directory */
"coverage": "mv lib lib~; (jscoverage lib~ lib; mocha -R html-cov > coverage.html); rm -rf lib; mv lib~ lib"
```
{: .-hard-wrap}
/* single file */ ```bash
"coverage": "(cp index.js index.js~; jscoverage index.js; mv index-cov.js index.js; mocha -R html-cov > coverage.html); mv index.js~ index.js" /* single file */
"coverage": "(cp index.js index.js~; jscoverage index.js; mv index-cov.js index.js; mocha -R html-cov > coverage.html); mv index.js~ index.js"
```
{: .-hard-wrap}
### Run ### Run
npm run coverage ```bash
open coverage.html npm run coverage
```
```bash
open coverage.html
```
### Caveats ### Caveats