blanket
blanket copied to clipboard
Testing of reporters, and reporter API
Is there any particular reason the reporters aren't tested? They should be able to be tested outside of blanket entirely, by just passing some mock data and asserting they correctly report it.
We could also abstract the reporting a bit, by having blanket provide a DOM element into which results are written, or even having something like:
blanket.writeHtmlResult = function (result) {
var div = document.createElement('div');
div.className = "blanket_lcov_reporter";
div.innerText = result;
whereverBlanketWantsToWriteStuff.appendChild(div);
}
and:
blanket.writeTextResult = function (result) {
blanket.textResult.push(result);
// or
blanket.textResult += result;
}
This also gives consumers a sanctioned place for locating blanket results from the command line, rather than relying on window._$blanket_LCOV
or whatever it's called. Otherwise, every reporter can write stuff to a different place in the DOM, or to different properties on the window.
Alternatively:
var textResult = [];
function writeTextResult (result) { textResult.push(result); }
blanket.getTextResult = function () { return textResult.join(''); }
This time, a method to get the text result is specified, and the reporter can use a private variable to store the result.