From a980ae6bf2923bc33d221966d612736d7963ac31 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 23 Aug 2025 08:30:56 -0700 Subject: [PATCH] Extract spec state management out of Spec#execute --- lib/jasmine-core/jasmine.js | 30 +++++++++++++++++++----------- src/core/Spec.js | 30 +++++++++++++++++++----------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index d4269af1..9a528ddd 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -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' diff --git a/src/core/Spec.js b/src/core/Spec.js index bc5d8573..223b561f 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -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'