Tizen 2.1 base
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.2.0 / node_modules / grunt / node_modules / nodeunit / node_modules / tap / node_modules / runforcover / README.markdown
1 runforcover
2 ======
3
4 Runforcover is a require-hook library that uses node-bunker to provide code coverage data
5 for your unit test library, whatever it might be.
6
7 methods
8 =======
9 var runforcover = require('runforcover');
10
11 var coverage = runforcover.cover([RegExp | path]);
12 -------
13
14 Attach runforcover to the global `require` object and patch `require.extensions['.js']` to
15 provide coverage metadata for all files required after this point. Returns a function
16 object that can be called to obtain a object keying files to `CoverageData` objects, with 
17 a method for releasing control back to vanilla `require`. Usage:
18
19 ````javascript
20
21 var coverage = runforcover.cover(/.*/g);
22
23 require('some/library');
24
25 coverage(function(coverageData) {
26     // coverageData is an object keyed by filename.
27     var stats = coverageData['/full/path/to/file.js'].stats()
28
29     // the percentage of lines run versus total lines in file
30     console.log(stats.percentage);
31
32     // the number of missing lines
33     console.log(stats.missing);
34
35     // the number of lines run (seen)
36     console.log(stats.seen);
37
38     // an array of line objects representing 'missed' lines
39     stats.lines;
40
41     stats.lines.forEach(function(line) {
42         // the line number of the line:
43         console.log(line.number);
44
45         // returns a string containing the source data for the line:
46         console.log(line.source());   
47     }); 
48    
49     // return control back to the original require function
50     coverage.release(); 
51 });
52 ````
53
54 license
55 =======
56 new BSD.