Created
October 27, 2011 23:34
-
-
Save WolfgangKluge/1321202 to your computer and use it in GitHub Desktop.
jshint code coverage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
(function () { | |
"use strict"; | |
var coveraje = require("coveraje").coveraje, | |
fs = require("fs"), | |
path = require("path"), | |
jshfilePath = path.resolve("../jshint.js"); | |
fs.readFile(jshfilePath, 'utf-8', function (err, data) { | |
function runTests(file) { | |
return function (context) { | |
// hack: set cache value | |
require.cache[jshfilePath] = { | |
id: jshfilePath, | |
exports: context, | |
loaded: true | |
}; | |
return coveraje.runHelper("expresso").run(file); | |
}; | |
} | |
if (err) throw err; | |
var tests = {}; | |
fs.readdir('./', function (err, files) { | |
files.forEach(function (f) { | |
if (f.length > 2 && f.substr(f.length - 3, 3) === ".js") { | |
tests[f] = runTests('./' + f); | |
} | |
}); | |
coveraje.cover(data, tests, { | |
useServer: true | |
}); | |
}); | |
}); | |
return this; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternative
Add this gist into ./tests folder of jshint and run it.