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; | |
}()); |
Alternative
// move to projects folder
git clone git://github.com/coveraje/coveraje.git
cd coveraje
git submodule update --init
npm link
Add this gist into ./tests folder of jshint and run it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get https://github.com/coveraje/coveraje
don't forget the submodules
add it to node_modules
Add this gist into ./tests folder of jshint and run it... ;)