Permalink
Browse files

Initial commit for node-cover

  • Loading branch information...
0 parents commit 120c87c5f9dfbc5dd9c4ac952065d905330d648d @itay committed Nov 26, 2011
Showing with 1,530 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +56 −0 README.markdown
  3. +16 −0 bin/.coverrc
  4. +554 −0 bin/cover
  5. +396 −0 index.js
  6. +42 −0 package.json
  7. +20 −0 reporters/cli.js
  8. +60 −0 reporters/html.js
  9. +9 −0 reporters/json.js
  10. +46 −0 reporters/plain.js
  11. +49 −0 test/format/index.js
  12. +59 −0 test/format/src/test1.js
  13. +8 −0 test/format/src/test2.js
  14. +1 −0 test/index.js
  15. +50 −0 test/interface.js
  16. +77 −0 test/src/coverage.js
  17. +6 −0 test/test.js
  18. +77 −0 utils/console.js
@@ -0,0 +1,4 @@
+**/format/html/*
+.coverage_data/*
+node_modules/*
+.coverignore
@@ -0,0 +1,56 @@
+runforcover
+======
+
+Runforcover is a require-hook library that uses node-bunker to provide code coverage data
+for your unit test library, whatever it might be.
+
+methods
+=======
+var runforcover = require('runforcover');
+
+var coverage = runforcover.cover([RegExp | path]);
+-------
+
+Attach runforcover to the global `require` object and patch `require.extensions['.js']` to
+provide coverage metadata for all files required after this point. Returns a function
+object that can be called to obtain a object keying files to `CoverageData` objects, with
+a method for releasing control back to vanilla `require`. Usage:
+
+````javascript
+
+var coverage = runforcover.cover(/.*/g);
+
+require('some/library');
+
+coverage(function(coverageData) {
+ // coverageData is an object keyed by filename.
+ var stats = coverageData['/full/path/to/file.js'].stats()
+
+ // the percentage of lines run versus total lines in file
+ console.log(stats.percentage);
+
+ // the number of missing lines
+ console.log(stats.missing);
+
+ // the number of lines run (seen)
+ console.log(stats.seen);
+
+ // an array of line objects representing 'missed' lines
+ stats.lines;
+
+ stats.lines.forEach(function(line) {
+ // the line number of the line:
+ console.log(line.number);
+
+ // returns a string containing the source data for the line:
+ console.log(line.source());
+ });
+
+ // return control back to the original require function
+ coverage.release();
+});
+````
+
+license
+=======
+new BSD.
@@ -0,0 +1,16 @@
+{
+ "formatter": "cli",
+ "ignore": ".coverignore",
+
+ "prefix": "coveragefile_", // Prefix for coverage data files
+ "dataDirectory": ".coverage_data", // Directory to put coverage files in
+
+ // Formatter-specific info
+ "html" : {
+ "directory": "cover_html", // Directory to write HTML files too
+ "generateIndex": true // Whether to generate an index.html file
+ },
+
+ "json": {
+ }
+}
Oops, something went wrong.

0 comments on commit 120c87c

Please sign in to comment.