Refactor suite timing out of Env and into each Reporter
[finishes #45659879]
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
getJasmineRequireObj().ConsoleReporter = function() {
|
||||
|
||||
var noopTimer = {
|
||||
start: function(){},
|
||||
elapsed: function(){ return 0; }
|
||||
};
|
||||
|
||||
function ConsoleReporter(options) {
|
||||
var print = options.print,
|
||||
showColors = options.showColors || false,
|
||||
onComplete = options.onComplete || function() {},
|
||||
timer = options.timer || noopTimer,
|
||||
specCount,
|
||||
failureCount,
|
||||
failedSpecs = [],
|
||||
@@ -20,9 +27,10 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
||||
pendingCount = 0;
|
||||
print("Started");
|
||||
printNewline();
|
||||
timer.start();
|
||||
};
|
||||
|
||||
this.jasmineDone = function(options) {
|
||||
this.jasmineDone = function() {
|
||||
printNewline();
|
||||
for (var i = 0; i < failedSpecs.length; i++) {
|
||||
specFailureDetails(failedSpecs[i]);
|
||||
@@ -39,7 +47,7 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
||||
print(specCounts);
|
||||
|
||||
printNewline();
|
||||
var seconds = options.executionTime / 1000;
|
||||
var seconds = timer.elapsed() / 1000;
|
||||
print("Finished in " + seconds + " " + plural("second", seconds));
|
||||
|
||||
printNewline();
|
||||
|
||||
@@ -34,10 +34,17 @@ getJasmineRequireObj().console = function(jRequire, j$) {
|
||||
};
|
||||
|
||||
getJasmineRequireObj().ConsoleReporter = function() {
|
||||
|
||||
var noopTimer = {
|
||||
start: function(){},
|
||||
elapsed: function(){ return 0; }
|
||||
};
|
||||
|
||||
function ConsoleReporter(options) {
|
||||
var print = options.print,
|
||||
showColors = options.showColors || false,
|
||||
onComplete = options.onComplete || function() {},
|
||||
timer = options.timer || noopTimer,
|
||||
specCount,
|
||||
failureCount,
|
||||
failedSpecs = [],
|
||||
@@ -55,9 +62,10 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
||||
pendingCount = 0;
|
||||
print("Started");
|
||||
printNewline();
|
||||
timer.start();
|
||||
};
|
||||
|
||||
this.jasmineDone = function(options) {
|
||||
this.jasmineDone = function() {
|
||||
printNewline();
|
||||
for (var i = 0; i < failedSpecs.length; i++) {
|
||||
specFailureDetails(failedSpecs[i]);
|
||||
@@ -74,7 +82,7 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
||||
print(specCounts);
|
||||
|
||||
printNewline();
|
||||
var seconds = options.executionTime / 1000;
|
||||
var seconds = timer.elapsed() / 1000;
|
||||
print("Finished in " + seconds + " " + plural("second", seconds));
|
||||
|
||||
printNewline();
|
||||
|
||||
@@ -1,21 +1,28 @@
|
||||
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';
|
||||
};
|
||||
|
||||
|
||||
18
src/core/Timer.js
Normal file
18
src/core/Timer.js
Normal file
@@ -0,0 +1,18 @@
|
||||
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;
|
||||
};
|
||||
@@ -28,6 +28,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$);
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
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,
|
||||
@@ -32,6 +39,7 @@ jasmineRequire.HtmlReporter = function() {
|
||||
var totalSpecsDefined;
|
||||
this.jasmineStarted = function(options) {
|
||||
totalSpecsDefined = options.totalSpecsDefined || 0;
|
||||
timer.start();
|
||||
};
|
||||
|
||||
var summary = createDom("div", {className: "summary"});
|
||||
@@ -92,9 +100,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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user