Code Monkey home page Code Monkey logo

jscoverage's Introduction

jscoverage

jscoverage tool, both node or javascript support

install

npm install jscoverage -g

get source code

git clone git://github.com/fishbar/jscoverage.git
cd ./jscoverage
mocha -R list test --coverage

using 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
# convert all files in sourcedir to destdir, exclude list will be ignored

TODO, comming soon

jscoverage sourcedir destdir --no-instrument

using as node module

var jsc = require('jscoverage');
var abc = jsc.require(module, 'testmodule.js');
describe('test', function () {
    // TEST CODE HERE
});

==== or =====

var jsc = require('jscoverage');
require = jsc.mock(mo);
var abc = require('abc.js', true);
describe('test', function () {
    // TEST CODE HERE
});

env switchs

jscoverage do not process coverage by default, because when we writting test case in the begining, case always fail, and we need to fix problems by check the error stack, finding the exact line where error happened

using follow options, you can switch the functions

--coverage   enable coverage action, default nocoverage
--noinject   close inject action, default inject , sometimes you already using rewire module do the same thing

i.e when you run test code by mocha:

    mocha test/ --coverage  # open coverage instrument
    mocha test/ --noinject  # close inject when you are using rewire

or you can also do in this way:

var jsc = require('jscoverage');
jsc.enableCoverage(true);
jsc.enableInject(false);

run with mocha

output a html coverage reporter

mocha -R html-cov test/test.js --coverage > coverage.html

print coverage info in cli

you can just print the coverage info in cli , like this:

// add the following code to you test file
var jsc = require('jscoverage');
process.on('exit', function () {
  jsc.coverage(); // print summary info, cover percent
  jsc.coverageDetail(); // print uncovered lines
});

mocha global leaks detect

the follow object will be detected, all of them are create by jscoverage

_$jscoverage, _$jscoverage_done, _$jscoverage_init, _$jscoverage_cond

jscoverage's People

Contributors

fishbar avatar simonellistonball avatar christinerr avatar

Watchers

Michael Weibel avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.