Merge branch 'johnjbarton-duration'

- Merges #1660 from @johnjbarton
- Fixes #1646
This commit is contained in:
Gregg Van Hove
2019-03-14 19:11:24 -07:00
7 changed files with 80 additions and 11 deletions

View File

@@ -557,6 +557,7 @@ getJasmineRequireObj().Spec = function(j$) {
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
this.timer = attrs.timer || j$.noopTimer;
if (!this.queueableFn.fn) {
this.pend();
@@ -572,6 +573,7 @@ getJasmineRequireObj().Spec = function(j$) {
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred during execution this spec.
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
*/
this.result = {
id: this.id,
@@ -580,7 +582,8 @@ getJasmineRequireObj().Spec = function(j$) {
failedExpectations: [],
passedExpectations: [],
deprecationWarnings: [],
pendingReason: ''
pendingReason: '',
duration: null,
};
}
@@ -610,6 +613,7 @@ getJasmineRequireObj().Spec = function(j$) {
var onStart = {
fn: function(done) {
self.timer.start();
self.onStart(self, done);
}
};
@@ -633,6 +637,7 @@ 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'));
},
userContext: this.userContext()
@@ -1290,6 +1295,7 @@ getJasmineRequireObj().Env = function(j$) {
currentlyExecutingSuites.push(suite);
defaultResourcesForRunnable(suite.id, suite.parentSuite.id);
reporter.suiteStarted(suite.result, next);
suite.startTimer();
},
nodeComplete: function(suite, result, next) {
if (suite !== currentSuite()) {
@@ -1302,7 +1308,7 @@ getJasmineRequireObj().Env = function(j$) {
if (result.status === 'failed') {
hasFailures = true;
}
suite.endTimer();
reporter.suiteDone(result, next);
},
orderChildren: function(node) {
@@ -1582,9 +1588,9 @@ getJasmineRequireObj().Env = function(j$) {
fn: fn,
timeout: timeout || 0
},
throwOnExpectationFailure: config.oneFailurePerSpec
throwOnExpectationFailure: config.oneFailurePerSpec,
timer: new j$.Timer(),
});
return spec;
function specResultCallback(result, next) {
@@ -6582,6 +6588,8 @@ getJasmineRequireObj().Suite = function(j$) {
this.beforeAllFns = [];
this.afterAllFns = [];
this.timer = attrs.timer || j$.noopTimer;
this.children = [];
/**
@@ -6592,13 +6600,15 @@ getJasmineRequireObj().Suite = function(j$) {
* @property {Expectation[]} failedExpectations - The list of expectations that failed in an {@link afterAll} for this suite.
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred on this suite.
* @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
* @property {number} duration - The time in ms for Suite execution, including any before/afterAll, before/afterEach.
*/
this.result = {
id: this.id,
description: this.description,
fullName: this.getFullName(),
failedExpectations: [],
deprecationWarnings: []
deprecationWarnings: [],
duration: null,
};
}
@@ -6640,6 +6650,14 @@ getJasmineRequireObj().Suite = function(j$) {
this.afterAllFns.unshift(fn);
};
Suite.prototype.startTimer = function() {
this.timer.start();
};
Suite.prototype.endTimer = function() {
this.result.duration = this.timer.elapsed();
};
function removeFns(queueableFns) {
for(var i = 0; i < queueableFns.length; i++) {
queueableFns[i].fn = null;