Skip to content

michaeljacobdavis/jscoverage

 
 

Repository files navigation

jscoverage

logo

jscoverage tool, both node.js or javascript support

Build Status NPM version

install

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! jscoverage can run with mocha, even with mocha's html-cov reporter. since mocha's html-cov dose not display branch cov info, jscoverage supply a new html-cov reporter

get source code

git clone git://github.com/fishbar/jscoverage.git

using jscoverage with mocha

let mocha load jscoverage using -r options, like:

mocha -r jscoverage --covignore .covignore --covout=html --covinject=true --coverage=50,85,90 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 is told that: 50% coverage is terrible, 85%+ is ok, 90%+ is greate

jscoverage can recognise all options below:

--covignore [filepath] # like gitignore, tell jscoverage to ignore these files

--covout [output report] # can be: summary, detail, json, html, lcov, default summary

--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, _replace, _reset), default is false

default jscoverage will search .covignore in the project root

using jscoverage as cli command

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 jscoverage programmatically

comming soon

using inject api for node.js test

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

  /* @covignore */

mocha global leaks detect

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

  • _$jscoverage
  • _$jscmd

About

jscoverage tool, written in pure js, both node or javascript support

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%