Add execution time elapsed to JsApiReporter
Since this information is desired in ConsoleReporter, HtmlReporter, and now JsApiReporter, the executionTime is passed through in jasmineDone from Env instead of making each reporter compute it. Fixes #30, [Finishes #45659879]
This commit is contained in:
@@ -30,11 +30,10 @@ jasmineRequire.HtmlReporter = function() {
|
||||
function HtmlReporter(options) {
|
||||
var env = options.env || {},
|
||||
getContainer = options.getContainer,
|
||||
now = options.now || function() { return new Date().getTime();},
|
||||
createElement = options.createElement,
|
||||
createTextNode = options.createTextNode,
|
||||
onRaiseExceptionsClick = options.onRaiseExceptionsClick,
|
||||
results = [],
|
||||
startTime,
|
||||
specsExecuted = 0,
|
||||
failureCount = 0,
|
||||
pendingSpecCount = 0,
|
||||
@@ -61,7 +60,6 @@ jasmineRequire.HtmlReporter = function() {
|
||||
var totalSpecsDefined;
|
||||
this.jasmineStarted = function(options) {
|
||||
totalSpecsDefined = options.totalSpecsDefined || 0;
|
||||
startTime = now();
|
||||
};
|
||||
|
||||
var summary = createDom("div", {className: "summary"});
|
||||
@@ -122,11 +120,9 @@ jasmineRequire.HtmlReporter = function() {
|
||||
}
|
||||
};
|
||||
|
||||
this.jasmineDone = function() {
|
||||
var elapsed = now() - startTime;
|
||||
|
||||
this.jasmineDone = function(options) {
|
||||
var banner = find(".banner");
|
||||
banner.appendChild(createDom("span", {className: "duration"}, "finished in " + elapsed / 1000 + "s"));
|
||||
banner.appendChild(createDom("span", {className: "duration"}, "finished in " + options.executionTime / 1000 + "s"));
|
||||
|
||||
var alert = find(".alert");
|
||||
|
||||
@@ -141,7 +137,7 @@ jasmineRequire.HtmlReporter = function() {
|
||||
var checkbox = find("input");
|
||||
|
||||
checkbox.checked = !env.catchingExceptions();
|
||||
checkbox.onclick = options.onRaiseExceptionsClick;
|
||||
checkbox.onclick = onRaiseExceptionsClick;
|
||||
|
||||
if (specsExecuted < totalSpecsDefined) {
|
||||
var skippedMessage = "Ran " + specsExecuted + " of " + totalSpecsDefined + " specs - run all";
|
||||
|
||||
@@ -307,7 +307,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
function Env(options) {
|
||||
options = options || {};
|
||||
var self = this;
|
||||
var global = options.global || j$.getGlobal();
|
||||
var global = options.global || j$.getGlobal(),
|
||||
now = options.now || function() { return new Date().getTime(); };
|
||||
|
||||
var catchExceptions = true;
|
||||
|
||||
@@ -497,10 +498,13 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
};
|
||||
|
||||
this.execute = function() {
|
||||
var startTime = now();
|
||||
this.reporter.jasmineStarted({
|
||||
totalSpecsDefined: totalSpecsDefined
|
||||
});
|
||||
this.topSuite.execute(this.reporter.jasmineDone);
|
||||
this.topSuite.execute(function() {
|
||||
self.reporter.jasmineDone({executionTime: now() - startTime});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -655,8 +659,11 @@ getJasmineRequireObj().JsApiReporter = function() {
|
||||
status = 'started';
|
||||
};
|
||||
|
||||
this.jasmineDone = function() {
|
||||
var executionTime;
|
||||
|
||||
this.jasmineDone = function(options) {
|
||||
this.finished = true;
|
||||
executionTime = options.executionTime;
|
||||
status = 'done';
|
||||
};
|
||||
|
||||
@@ -697,6 +704,10 @@ getJasmineRequireObj().JsApiReporter = function() {
|
||||
return specs;
|
||||
};
|
||||
|
||||
this.executionTime = function() {
|
||||
return executionTime;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
return JsApiReporter;
|
||||
|
||||
Reference in New Issue
Block a user