From 43710817631593f13946987c3a17e54d6d761994 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Fri, 28 Nov 2025 07:18:30 -0800 Subject: [PATCH] Deprecate jsApiReporter and remove it from boot1.js jsApiReporter was initially added as part of the pre-1.0 Ruby based browser runner. It looks like it was designed to resolve a race condition betweeen jasmine-core's startup in the browser and the Ruby runner's startup. Modern runners handle that either by buffering messages in a custom reporter (e.g. jasmine-browser-runner's BatchReporter) or by calling env.execute() after a communication channel has been set up (e.g. the old Jasmine ruby gem). In any other context, a custom reporter is easier to use than jsApiReporter because it doesn't require polling. Adding jsApiReporter to the env imposes small but measurable penalties in time and space, both of which are proportional to the size of the test suite. Other than jasmine-py and Testdouble's jasmine-rails gem, neither of which ever supported jasmine-core 4 or later, I can find scant evidence of interest and no evidence of usage after about 2012. --- lib/jasmine-core/boot1.js | 4 ---- lib/jasmine-core/jasmine.js | 2 ++ src/boot/boot1.js | 4 ---- src/core/JsApiReporter.js | 2 ++ 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/jasmine-core/boot1.js b/lib/jasmine-core/boot1.js index 86d9dbd9..c925df40 100644 --- a/lib/jasmine-core/boot1.js +++ b/lib/jasmine-core/boot1.js @@ -53,10 +53,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } }); - /** - * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript. - */ - env.addReporter(jsApiReporter); env.addReporter(htmlReporter); /** * Configures Jasmine based on the current set of query parameters. This diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 8c64b348..63b9ee84 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -2099,11 +2099,13 @@ getJasmineRequireObj().Env = function(j$) { getJasmineRequireObj().JsApiReporter = function(j$) { 'use strict'; + // TODO: remove in 7.0. /** * @name jsApiReporter * @classdesc {@link Reporter} added by default in `boot.js` to record results for retrieval in javascript code. An instance is made available as `jsApiReporter` on the global object. * @class * @hideconstructor + * @deprecated In most cases jsApiReporter can simply be removed. If necessary, it can be replaced with a {@link Reporter|custom reporter}. */ function JsApiReporter(options) { const timer = options.timer || new j$.Timer(); diff --git a/src/boot/boot1.js b/src/boot/boot1.js index 9502b917..b998aadc 100644 --- a/src/boot/boot1.js +++ b/src/boot/boot1.js @@ -29,10 +29,6 @@ } }); - /** - * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript. - */ - env.addReporter(jsApiReporter); env.addReporter(htmlReporter); /** * Configures Jasmine based on the current set of query parameters. This diff --git a/src/core/JsApiReporter.js b/src/core/JsApiReporter.js index 16c0d768..5e54c708 100644 --- a/src/core/JsApiReporter.js +++ b/src/core/JsApiReporter.js @@ -1,11 +1,13 @@ getJasmineRequireObj().JsApiReporter = function(j$) { 'use strict'; + // TODO: remove in 7.0. /** * @name jsApiReporter * @classdesc {@link Reporter} added by default in `boot.js` to record results for retrieval in javascript code. An instance is made available as `jsApiReporter` on the global object. * @class * @hideconstructor + * @deprecated In most cases jsApiReporter can simply be removed. If necessary, it can be replaced with a {@link Reporter|custom reporter}. */ function JsApiReporter(options) { const timer = options.timer || new j$.Timer();