# node-jscover

> node version of JSCover

Latest version **0.6.13** (published 2016-04-18) · 0 weekly downloads

## Install

```sh
npm install node-jscover
pnpm add node-jscover
yarn add node-jscover
bun add node-jscover
```

Provides the command `jscover`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.13 |
| Published | 2016-04-18 |
| First published | 2014-05-21 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 6 |
| Author | yiminghe |
| Maintainers | yiminghe |

## Links

- npm: https://www.npmjs.com/package/node-jscover
- Repository: https://github.com/yiminghe/node-jscover
- Homepage: https://github.com/yiminghe/node-jscover#readme
- Issues: https://github.com/yiminghe/node-jscover/issues
- npm.io page: https://npm.io/package/node-jscover

## Dependencies (10)

- [ncp](https://npm.io/package/ncp.md) ~0.5.1
- [walk](https://npm.io/package/walk.md) ~2.3.3
- [debug](https://npm.io/package/debug.md) ~0.8.1
- [mkdirp](https://npm.io/package/mkdirp.md) ~0.5.0
- [esprima](https://npm.io/package/esprima.md) ~1.2.2
- [fs-extra](https://npm.io/package/fs-extra.md) ~0.8.1
- [commander](https://npm.io/package/commander.md) ~2.2.0
- [escodegen](https://npm.io/package/escodegen.md) ~1.3.3
- [estraverse](https://npm.io/package/estraverse.md) ~1.5.0
- [modulex-util](https://npm.io/package/modulex-util.md) ^1.0.1

## Recent versions

- 0.6.13 (latest) — 2016-04-18
- 0.6.12 — 2015-09-23
- 0.6.11 — 2015-05-11
- 0.6.10 — 2015-01-06
- 0.6.9 — 2014-12-03
- 0.6.8 — 2014-08-14
- 0.6.7 — 2014-08-14
- 0.6.6 — 2014-08-14
- 0.6.5 — 2014-08-14
- 0.6.4 — 2014-08-14
- 0.6.2 — 2014-08-14
- 0.6.1 — 2014-08-12
- 0.6.0 — 2014-08-12
- 0.5.1 — 2014-08-12
- 0.5.0 — 2014-07-04
- … 13 more at https://npm.io/package/node-jscover/versions

## README

## node-jscover - - A JavaScript code coverage measurement tool

[![NPM version](https://nodei.co/npm/node-jscover.png)](https://npmjs.org/package/node-jscover)
[![NPM downloads](http://img.shields.io/npm/dm/node-jscover.svg)](https://npmjs.org/package/node-jscover)
[![Build Status](https://travis-ci.org/yiminghe/node-jscover.svg?branch=master)](https://travis-ci.org/yiminghe/node-jscover)
[![Coverage Status](https://coveralls.io/repos/yiminghe/node-jscover/badge.png?branch=master)](https://coveralls.io/r/yiminghe/node-jscover?branch=master)

node version of [JSCover](https://github.com/tntim96/JSCover).  only support file system instrument.

### use command line tools

* install jscover globally

    ``` javascript
    npm install node-jscover -g
    ```

* instrument supplied directory of javascript files(**/lib**) and save result to another directory(**/out**)

    ```
    jscover -d /lib -o /out
    ```

  similar to java version:

  ```
  java -jar JSCover-all.jar -fs /lib /out
  ```

* all arguments

<table class="table table-bordered table-striped">
    <thead>
    <tr>
        <th style="width: 100px;">short name</th>
        <th style="width: 100px;">full name</th>
        <th style="width: 50px;">type</th>
        <th style="width: 50px;">default</th>
        <th>description</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td>-d</td>
        <td>--dir</td>
        <td>String</td>
        <td></td>
        <td>directory of javascript source files</td>
    </tr>
    <tr>
        <td>-o</td>
        <td>--out</td>
        <td>String</td>
        <td></td>
        <td>destination directory of instrumented javascript source files</td>
    </tr>
    <tr>
        <td>-f</td>
        <td>--front</td>
        <td>Boolean</td>
        <td>false</td>
        <td>whether output JSCover front-end files to destination directory</td>
    </tr>
    </tbody>
</table>

### usage doc

[https://github.com/yiminghe/node-jscover/blob/master/docs/usage.md](https://github.com/yiminghe/node-jscover/blob/master/docs/usage.md)

### use api

* install jscover locally

    ``` javascript
    npm install node-jscover
    ```

* get jscover

    ``` javascript
    var jscover = require('node-jscover');
    ```

#### method

##### String instrument(String code, String fileName): return instrumented code

<table class="table table-bordered table-striped">
    <thead>
    <tr>
        <th style="width: 100px;">name</th>
        <th style="width: 50px;">type</th>
        <th>description</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td>code</td>
        <td>String</td>
        <td>code to be instrumented</td>
    </tr>
    <tr>
            <td>fileName</td>
            <td>String</td>
            <td>fileName of code</td>
        </tr>
    </tbody>
</table>

example

``` javascript
var jscover = require('node-jscover');
console.log(jscover.instrument('var x=1;','test.js'));
// ->  _$jscoverage['test.js'].lineData[0]++;
// ->  var x = 1;
```

### example

![xtemplate coverage info](http://gtms02.alicdn.com/tps/i2/TB1hMCKFVXXXXXFXVXXR0b5GXXX-1133-615.png)

![xtemplate coverage info](http://gtms02.alicdn.com/tps/i2/TB1WxCNFVXXXXc_XpXXR0b5GXXX-1133-615.png)


### changelog

#### 0.6.0

* add console reporter for mocha and jasmine: /lib/reporters/...

#### 0.5.0

* change function count format: https://github.com/yiminghe/node-jscover/issues/1

#### 0.4.0

* compatible with [jscover](https://github.com/tntim96/JSCover)
* [support function count](https://github.com/yiminghe/node-jscover/issues/1)

---
_Source: https://npm.io/package/node-jscover · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
