Refactor suite timing out of Env and into each Reporter
[finishes #45659879]
This commit is contained in:
@@ -73,8 +73,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
clearTimeout: env.clock.clearTimeout,
|
||||
setInterval: env.clock.setInterval,
|
||||
clearInterval: env.clock.clearInterval,
|
||||
|
||||
jsApiReporter: new jasmine.JsApiReporter(jasmine)
|
||||
jsApiReporter: new jasmine.JsApiReporter({
|
||||
timer: new jasmine.Timer()
|
||||
})
|
||||
};
|
||||
|
||||
if (typeof window == "undefined" && typeof exports == "object") {
|
||||
@@ -97,7 +98,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
|
||||
getContainer: function() { return document.body; },
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
||||
timer: new jasmine.Timer()
|
||||
});
|
||||
|
||||
env.addReporter(jasmineInterface.jsApiReporter);
|
||||
|
||||
@@ -51,8 +51,9 @@
|
||||
clearTimeout: env.clock.clearTimeout,
|
||||
setInterval: env.clock.setInterval,
|
||||
clearInterval: env.clock.clearInterval,
|
||||
|
||||
jsApiReporter: new jasmine.JsApiReporter(jasmine)
|
||||
jsApiReporter: new jasmine.JsApiReporter({
|
||||
timer: new jasmine.Timer()
|
||||
})
|
||||
};
|
||||
|
||||
if (typeof window == "undefined" && typeof exports == "object") {
|
||||
@@ -75,7 +76,8 @@
|
||||
onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
|
||||
getContainer: function() { return document.body; },
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
||||
timer: new jasmine.Timer()
|
||||
});
|
||||
|
||||
env.addReporter(jasmineInterface.jsApiReporter);
|
||||
|
||||
@@ -27,12 +27,19 @@ jasmineRequire.html = function(j$) {
|
||||
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
||||
};
|
||||
jasmineRequire.HtmlReporter = function() {
|
||||
|
||||
var noopTimer = {
|
||||
start: function(){},
|
||||
elapsed: function(){ return 0; }
|
||||
};
|
||||
|
||||
function HtmlReporter(options) {
|
||||
var env = options.env || {},
|
||||
getContainer = options.getContainer,
|
||||
createElement = options.createElement,
|
||||
createTextNode = options.createTextNode,
|
||||
onRaiseExceptionsClick = options.onRaiseExceptionsClick,
|
||||
timer = options.timer || noopTimer,
|
||||
results = [],
|
||||
specsExecuted = 0,
|
||||
failureCount = 0,
|
||||
@@ -60,6 +67,7 @@ jasmineRequire.HtmlReporter = function() {
|
||||
var totalSpecsDefined;
|
||||
this.jasmineStarted = function(options) {
|
||||
totalSpecsDefined = options.totalSpecsDefined || 0;
|
||||
timer.start();
|
||||
};
|
||||
|
||||
var summary = createDom("div", {className: "summary"});
|
||||
@@ -120,9 +128,9 @@ jasmineRequire.HtmlReporter = function() {
|
||||
}
|
||||
};
|
||||
|
||||
this.jasmineDone = function(options) {
|
||||
this.jasmineDone = function() {
|
||||
var banner = find(".banner");
|
||||
banner.appendChild(createDom("span", {className: "duration"}, "finished in " + options.executionTime / 1000 + "s"));
|
||||
banner.appendChild(createDom("span", {className: "duration"}, "finished in " + timer.elapsed() / 1000 + "s"));
|
||||
|
||||
var alert = find(".alert");
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ getJasmineRequireObj().core = function(jRequire) {
|
||||
j$.Spec = jRequire.Spec();
|
||||
j$.Spy = jRequire.Spy(j$);
|
||||
j$.Suite = jRequire.Suite();
|
||||
j$.Timer = jRequire.Timer();
|
||||
j$.version = jRequire.version();
|
||||
|
||||
j$.matchers = jRequire.requireMatchers(jRequire, j$);
|
||||
@@ -648,23 +649,30 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
};
|
||||
|
||||
getJasmineRequireObj().JsApiReporter = function() {
|
||||
function JsApiReporter(jasmine) { // TODO: this doesn't appear to be used
|
||||
this.jasmine = jasmine || {};
|
||||
|
||||
var noopTimer = {
|
||||
start: function(){},
|
||||
elapsed: function(){ return 0; }
|
||||
};
|
||||
|
||||
function JsApiReporter(options) {
|
||||
var timer = options.timer || noopTimer,
|
||||
status = "loaded";
|
||||
|
||||
this.started = false;
|
||||
this.finished = false;
|
||||
|
||||
var status = 'loaded';
|
||||
|
||||
this.jasmineStarted = function() {
|
||||
this.started = true;
|
||||
status = 'started';
|
||||
timer.start();
|
||||
};
|
||||
|
||||
var executionTime;
|
||||
|
||||
this.jasmineDone = function(options) {
|
||||
this.jasmineDone = function() {
|
||||
this.finished = true;
|
||||
executionTime = options.executionTime;
|
||||
executionTime = timer.elapsed();
|
||||
status = 'done';
|
||||
};
|
||||
|
||||
@@ -1567,6 +1575,24 @@ if (typeof window == void 0 && typeof exports == "object") {
|
||||
exports.Suite = jasmineRequire.Suite;
|
||||
}
|
||||
|
||||
getJasmineRequireObj().Timer = function() {
|
||||
function Timer(options) {
|
||||
options = options || {};
|
||||
|
||||
var now = options.now || function() { return new Date().getTime(); },
|
||||
startTime;
|
||||
|
||||
this.start = function() {
|
||||
startTime = now();
|
||||
};
|
||||
|
||||
this.elapsed = function() {
|
||||
return now() - startTime;
|
||||
};
|
||||
}
|
||||
|
||||
return Timer;
|
||||
};
|
||||
getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
// TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user