jscoverage: update
This commit is contained in:
parent
a4238ddcee
commit
3ee6f48ed2
|
@ -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
|
||||||
|
|
||||||
|
#### Install via npm
|
||||||
|
|
||||||
|
```bash
|
||||||
npm install --save-dev jscoverage
|
npm install --save-dev jscoverage
|
||||||
|
```
|
||||||
|
|
||||||
### Ignore output
|
#### Ignore output
|
||||||
|
|
||||||
|
```bash
|
||||||
echo coverage.html >> .gitignore
|
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}
|
||||||
|
|
||||||
|
```bash
|
||||||
/* directory */
|
/* directory */
|
||||||
"coverage": "mv lib lib~; (jscoverage lib~ lib; mocha -R html-cov > coverage.html); rm -rf lib; mv lib~ lib"
|
"coverage": "mv lib lib~; (jscoverage lib~ lib; mocha -R html-cov > coverage.html); rm -rf lib; mv lib~ lib"
|
||||||
|
```
|
||||||
|
{: .-hard-wrap}
|
||||||
|
|
||||||
|
```bash
|
||||||
/* single file */
|
/* 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"
|
"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
|
||||||
|
|
||||||
|
```bash
|
||||||
npm run coverage
|
npm run coverage
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
open coverage.html
|
open coverage.html
|
||||||
|
```
|
||||||
|
|
||||||
### Caveats
|
### Caveats
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue