1 | # jscov [![Build Status](https://secure.travis-ci.org/jakobmattsson/jscov.png)](http://travis-ci.org/jakobmattsson/jscov)
|
2 |
|
3 | JSCoverage, implemented in JavaScript
|
4 |
|
5 |
|
6 |
|
7 | ## Installing
|
8 |
|
9 | `npm install -g jscov`
|
10 |
|
11 |
|
12 |
|
13 | ## Using
|
14 |
|
15 | Start with `jscov --help` on the command line and the rest should be obvious.
|
16 |
|
17 | You can also use it programmatically. It has two functions and can be used like this:
|
18 |
|
19 | ```javascript
|
20 | var jscov = require('jscov');
|
21 |
|
22 | // Transforming source code
|
23 | //
|
24 | // Pass in some javascript code as a string and get a new string back,
|
25 | // containing the same program but with code coverage support added.
|
26 | //
|
27 | // A filename has to be passed in as well, since the code coverage bits requires one.
|
28 |
|
29 | var coveredSource = jscov.rewriteSource("var a = 1 + 2; console.log(a);", "myfilename.js");
|
30 |
|
31 | // Transforming directories of code (like the command line client)
|
32 | //
|
33 | // This is simply the programmatic version of the command line client.
|
34 | // Pass in a source directory and a target directory and all JavaScript (and CoffeeScript)
|
35 | // found in source diriectory will be processed using `rewriteSource` and written to the target directory.
|
36 | jscov.rewriteFolder("src", "src-cov", function(err) {
|
37 | // err will indicate if something went wrong.
|
38 | });
|
39 | ```
|
40 |
|
41 |
|
42 | ## Developing
|
43 |
|
44 | Pull request are welcome obviously!
|
45 |
|
46 | Running the tests requires jscoverage to be installed. This is because the main part of the tests compares the output of jscov to jscoverage. Get it here http://siliconforks.com/jscoverage or do what `.travis.yml` does to get it up and running.
|
47 |
|
48 |
|
49 |
|
50 | ## Todo
|
51 |
|
52 | * Test using empty blocks in some different contexts. Are they removed?
|
53 | * Write a test for testing the actual code-coverage with and without using the expander
|
54 | * Attempt to instrument code that has already been instrumented (seems like jscoverage prevents that)
|
55 | * Branches current attempting to solve:
|
56 | * Float precision
|
57 | * Encodings
|
58 | * Octal-looking decimals
|
59 | * JS v1.6
|
60 | * Implement the following features from JSCoverage:
|
61 | * encoding
|
62 | * exclude
|
63 | * js-version
|
64 | * no-highlight
|
65 | * no-instrument
|
66 | * verbose
|
67 | * codeExpander should be tested to confirm that the program before and after does the exact same thing (could the AST's be reduced or should test programs be run?)
|
68 | * Look into the parse parameters "source" and "tokens"; might be helpful for simplying keeping source code and solivng the octal bug
|
69 | * Make jscoverage and jscov run with the same default parameters (for example encoding and js-version)
|