Skip to content

Instantly share code, notes, and snippets.

@alex-seville
Created January 17, 2013 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alex-seville/4553003 to your computer and use it in GitHub Desktop.
Save alex-seville/4553003 to your computer and use it in GitHub Desktop.
A Blanket.js adapter for use in Brackets.
(function () {
if (! jasmine) {
throw new Exception("jasmine library does not exist in global namespace!");
}
function elapsed(startTime, endTime) {
return (endTime - startTime)/1000;
}
function ISODateString(d) {
function pad(n) { return n < 10 ? '0'+n : n; }
return d.getFullYear() + '-' +
pad(d.getMonth()+1) + '-' +
pad(d.getDate()) + 'T' +
pad(d.getHours()) + ':' +
pad(d.getMinutes()) + ':' +
pad(d.getSeconds());
}
function trim(str) {
return str.replace(/^\s+/, "" ).replace(/\s+$/, "" );
}
function escapeInvalidXmlChars(str) {
return str.replace(/\&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/\>/g, "&gt;")
.replace(/\"/g, "&quot;")
.replace(/\'/g, "&apos;");
}
/**
* based on https://raw.github.com/larrymyers/jasmine-reporters/master/src/jasmine.junit_reporter.js
*/
var BlanketReporter = function(savePath, consolidate, useDotNotation) {
blanket.setupCoverage();
};
BlanketReporter.finished_at = null; // will be updated after all files have been written
BlanketReporter.prototype = {
reportSpecStarting: function(spec) {
blanket.onTestStart();
},
reportSpecResults: function(suite) {
var results = suite.results();
blanket.onTestDone(results.totalCount,results.passed());
},
reportRunnerResults: function(runner) {
blanket.onTestsDone();
},
log: function(str) {
var console = jasmine.getGlobal().console;
if (console && console.log) {
console.log(str);
}
}
};
// export public
jasmine.BlanketReporter = BlanketReporter;
jasmine.getEnv().addReporter(new jasmine.BlanketReporter());
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment