Created
January 17, 2013 02:25
-
-
Save alex-seville/4553003 to your computer and use it in GitHub Desktop.
A Blanket.js adapter for use in Brackets.
This file contains 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
(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, "&") | |
.replace(/</g, "<") | |
.replace(/\>/g, ">") | |
.replace(/\"/g, """) | |
.replace(/\'/g, "'"); | |
} | |
/** | |
* 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