Correctly report spec and suite duration
Previously, suite duration was always reported as 0 and spec duration was always reported as null. Suites always used a no-op timer, and specs set their result.duration after the result had already been sent to reporters. Fixes #1676.
This commit is contained in:
@@ -952,6 +952,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
id: getNextSuiteId(),
|
||||
description: description,
|
||||
parentSuite: currentDeclarationSuite,
|
||||
timer: new j$.Timer(),
|
||||
expectationFactory: expectationFactory,
|
||||
asyncExpectationFactory: suiteAsyncExpectationFactory,
|
||||
expectationResultFactory: expectationResultFactory,
|
||||
|
||||
@@ -6,7 +6,7 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
|
||||
* @hideconstructor
|
||||
*/
|
||||
function JsApiReporter(options) {
|
||||
var timer = options.timer || j$.noopTimer,
|
||||
var timer = options.timer || new j$.Timer(),
|
||||
status = 'loaded';
|
||||
|
||||
this.started = false;
|
||||
|
||||
@@ -31,7 +31,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
return true;
|
||||
};
|
||||
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
||||
this.timer = attrs.timer || j$.noopTimer;
|
||||
this.timer = attrs.timer || new j$.Timer();
|
||||
|
||||
if (!this.queueableFn.fn) {
|
||||
this.pend();
|
||||
@@ -96,6 +96,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
fn: function(done) {
|
||||
self.queueableFn.fn = null;
|
||||
self.result.status = self.status(excluded, failSpecWithNoExp);
|
||||
self.result.duration = self.timer.elapsed();
|
||||
self.resultCallback(self.result, done);
|
||||
}
|
||||
};
|
||||
@@ -111,7 +112,6 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
self.onException.apply(self, arguments);
|
||||
},
|
||||
onComplete: function() {
|
||||
self.result.duration = self.timer.elapsed();
|
||||
onComplete(
|
||||
self.result.status === 'failed' &&
|
||||
new j$.StopExecutionError('spec failed')
|
||||
|
||||
@@ -14,7 +14,7 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
this.beforeAllFns = [];
|
||||
this.afterAllFns = [];
|
||||
|
||||
this.timer = attrs.timer || j$.noopTimer;
|
||||
this.timer = attrs.timer || new j$.Timer();
|
||||
|
||||
this.children = [];
|
||||
|
||||
|
||||
@@ -22,12 +22,3 @@ getJasmineRequireObj().Timer = function() {
|
||||
|
||||
return Timer;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().noopTimer = function() {
|
||||
return {
|
||||
start: function() {},
|
||||
elapsed: function() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -49,7 +49,6 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
|
||||
j$.Expector = jRequire.Expector(j$);
|
||||
j$.Expectation = jRequire.Expectation(j$);
|
||||
j$.buildExpectationResult = jRequire.buildExpectationResult(j$);
|
||||
j$.noopTimer = jRequire.noopTimer();
|
||||
j$.JsApiReporter = jRequire.JsApiReporter(j$);
|
||||
j$.asymmetricEqualityTesterArgCompatShim = jRequire.asymmetricEqualityTesterArgCompatShim(
|
||||
j$
|
||||
|
||||
Reference in New Issue
Block a user