# jscoverage

> a javascript coverage tool, can be used in node dev, and browser side js dev

Latest version **0.6.0** (published 2015-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install jscoverage
pnpm add jscoverage
yarn add jscoverage
bun add jscoverage
```

Provides the command `jscoverage`.

## 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.0 |
| Published | 2015-08-04 |
| First published | 2012-02-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.8 |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+8 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 90 |
| Author | fish |
| Maintainers | kate.sf, fish, sunfang1cn, fishbar |
| Keywords | jscoverage, node, javascript, coverage, dev, tool |

## Links

- npm: https://www.npmjs.com/package/jscoverage
- Repository: https://github.com/fishbar/jscoverage
- Issues: https://github.com/fishbar/jscoverage/issues
- npm.io page: https://npm.io/package/jscoverage

## Dependencies (7)

- [ejs](https://npm.io/package/ejs.md) 1.0.0
- [xfs](https://npm.io/package/xfs.md) ~0.1.8
- [debug](https://npm.io/package/debug.md) ~1.0.3
- [optimist](https://npm.io/package/optimist.md) ^0.6.1
- [commander](https://npm.io/package/commander.md) ^2.6.0
- [uglify-js](https://npm.io/package/uglify-js.md) ~2.4.15
- [coffee-script](https://npm.io/package/coffee-script.md) *

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.6.0 (latest) — 2015-08-04
- 0.5.7 (0.5.7_beta) — 2014-10-26
- 0.5.9 — 2014-11-01
- 0.5.8 — 2014-10-26
- 0.5.6 — 2014-08-12
- 0.5.5 — 2014-07-13
- 0.5.4 — 2014-06-19
- 0.5.3 — 2014-05-29
- 0.5.2 — 2014-05-29
- 0.5.1 — 2014-05-20
- 0.5.0-rc2 — 2014-04-23
- 0.5.0-rc1 — 2014-04-10
- 0.5.0-pre — 2014-04-10
- 0.3.8 — 2013-08-28
- 0.3.7 — 2013-05-09
- … 37 more at https://npm.io/package/jscoverage/versions

## README

jscoverage
==========
![logo](https://raw.github.com/fishbar/jscoverage/master/logo.png)

jscoverage tool, both node.js or javascript support

[![Build Status](https://travis-ci.org/fishbar/jscoverage.svg)](https://travis-ci.org/fishbar/jscoverage)
[![NPM version](https://badge.fury.io/js/jscoverage.svg)](http://badge.fury.io/js/jscoverage)


### install

```sh
npm install jscoverage
```

### changelog

from v0.5.0， jscoverage start using uglify2, and enhance the coverage range.
now, jscoverage will find out which branch you missed!

### Get start

using mocha loading the jscoverage module, then it's work:
```sh
mocha -r jscoverage test/
```

jscoverage will append coverage info when you select `list` or `spec` or `tap` reporter in mocha
```sh
mocha -r jscoverage -R spec test/
```

besides, you can use `--covout` to specify the reporter， like `html`, `detail`.
the `detail` reporter will print the uncovered code in the console directly.

### using jscoverage with mocha

full modelł:
```sh
mocha -r jscoverage --covignore .covignore --covout=html --covinject=true --coverage=90,85,75 test
```
the cmd above means:
  * mocha run test case with jscoverage module
  * jscoverage will ignore files while list in .covignore file
  * jscoverage will output a report in html format
  * jscoverage will inject a group of function to your module.exports (_get, _set, _reset, _replace);
  * jscoverage will switch the colorful output:  90%+ is greate, 85%+ is ok, lower then 75% coverage is terrible

jscoverage can recognise all options below:

```
 --covignore [filepath] # like gitignore, tell jscoverage to ignore these files
 --overrideIgnore [boolean] # set if override the build-in ignore rules
 --covout [output report] # can be:  spec, list, tap, detail, html
 --coverage [high,middle,low] # coverage level, default is: 90,70,30 , means 90% is high, 30% is low
 --covinject [boolean] # switch if inject code for easytest(exports._get, exports._replace, exports._reset)
```

default jscoverage will search .covignore in the project root

### using jscoverage as cli command

```shell
jscoverage
# print help info
jscoverage source.js
# convert source.js to source-cov.js
jscoverage source.js dest.js
# convert source.js to dest.js
jscoverage sourcedir destdir --exclude a.js,b.js,c.js,*.min.js
# convert all files in sourcedir to destdir, exclude list will be ignored
```
jscoverage will copy exclude file from source dir to dest dir

### using inject api for node.js test

```js
var testMod = require('module/for/test.js');

testMod._get('name');
testMod._replace('name', value);
testMod._reset();
testMod._call();
```
### inline ignore annotation

using bellow comment, jscoverage will ignore the following block/statement

```js
  /* @covignore */
```

### using jscoverage programmatically

comming soon

### mocha global leaks detect

The follow object will be detected, all of them are created by jscoverage.

  * _$jscoverage
  * _$jscmd

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