Extract spec state management out of Spec#execute

This commit is contained in:
Steve Gravrock
2025-08-23 08:30:56 -07:00
parent 56ac8f5505
commit a980ae6bf2
2 changed files with 38 additions and 22 deletions

View File

@@ -841,6 +841,23 @@ getJasmineRequireObj().Spec = function(j$) {
this.result.properties[key] = value;
};
Spec.prototype.executionStarted = function() {
this.timer.start();
};
Spec.prototype.executionFinished = function(excluded, failSpecWithNoExp) {
if (this.autoCleanClosures) {
this.queueableFn.fn = null;
}
this.result.status = this.status(excluded, failSpecWithNoExp);
this.result.duration = this.timer.elapsed();
if (this.result.status !== 'failed') {
this.result.debugLogs = null;
}
};
Spec.prototype.execute = function(
runQueue,
globalErrors,
@@ -854,23 +871,14 @@ getJasmineRequireObj().Spec = function(j$) {
) {
const start = {
fn: done => {
this.timer.start();
this.executionStarted();
onStart(done);
}
};
const complete = {
fn: done => {
if (this.autoCleanClosures) {
this.queueableFn.fn = null;
}
this.result.status = this.status(excluded, failSpecWithNoExp);
this.result.duration = this.timer.elapsed();
if (this.result.status !== 'failed') {
this.result.debugLogs = null;
}
this.executionFinished(excluded, failSpecWithNoExp);
resultCallback(this.result, done);
},
type: 'specCleanup'

View File

@@ -69,6 +69,23 @@ getJasmineRequireObj().Spec = function(j$) {
this.result.properties[key] = value;
};
Spec.prototype.executionStarted = function() {
this.timer.start();
};
Spec.prototype.executionFinished = function(excluded, failSpecWithNoExp) {
if (this.autoCleanClosures) {
this.queueableFn.fn = null;
}
this.result.status = this.status(excluded, failSpecWithNoExp);
this.result.duration = this.timer.elapsed();
if (this.result.status !== 'failed') {
this.result.debugLogs = null;
}
};
Spec.prototype.execute = function(
runQueue,
globalErrors,
@@ -82,23 +99,14 @@ getJasmineRequireObj().Spec = function(j$) {
) {
const start = {
fn: done => {
this.timer.start();
this.executionStarted();
onStart(done);
}
};
const complete = {
fn: done => {
if (this.autoCleanClosures) {
this.queueableFn.fn = null;
}
this.result.status = this.status(excluded, failSpecWithNoExp);
this.result.duration = this.timer.elapsed();
if (this.result.status !== 'failed') {
this.result.debugLogs = null;
}
this.executionFinished(excluded, failSpecWithNoExp);
resultCallback(this.result, done);
},
type: 'specCleanup'