From 03006080d4ffb1e4ef09710091a0871833452f83 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Thu, 27 Nov 2025 11:22:27 -0800 Subject: [PATCH] rm deprecated jsApiReporter --- lib/jasmine-core/jasmine.js | 139 ------------------------ scripts/lib/buildDistribution.js | 1 - spec/core/JsApiReporterSpec.js | 179 ------------------------------- spec/support/jasmine-browser.js | 1 - src/core/JsApiReporter.js | 133 ----------------------- src/core/requireCore.js | 1 - src/core/requireInterface.js | 4 - 7 files changed, 458 deletions(-) delete mode 100644 spec/core/JsApiReporterSpec.js delete mode 100644 src/core/JsApiReporter.js diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index ced0b20d..08c41db5 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -71,7 +71,6 @@ var getJasmineRequireObj = (function() { j$.private.Expector = jRequire.Expector(j$); j$.private.Expectation = jRequire.Expectation(j$); j$.private.buildExpectationResult = jRequire.buildExpectationResult(j$); - j$.private.JsApiReporter = jRequire.JsApiReporter(j$); j$.private.makePrettyPrinter = jRequire.makePrettyPrinter(j$); j$.private.basicPrettyPrinter = j$.private.makePrettyPrinter(); j$.private.MatchersUtil = jRequire.MatchersUtil(j$); @@ -2075,140 +2074,6 @@ getJasmineRequireObj().Env = function(j$) { return Env; }; -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(); - let status = 'loaded'; - - this.started = false; - this.finished = false; - this.runDetails = {}; - - this.jasmineStarted = function() { - this.started = true; - status = 'started'; - timer.start(); - }; - - let executionTime; - - this.jasmineDone = function(runDetails) { - this.finished = true; - this.runDetails = runDetails; - executionTime = timer.elapsed(); - status = 'done'; - }; - - /** - * Get the current status for the Jasmine environment. - * @name jsApiReporter#status - * @since 2.0.0 - * @function - * @return {String} - One of `loaded`, `started`, or `done` - */ - this.status = function() { - return status; - }; - - const suites = [], - suites_hash = {}; - - this.suiteStarted = function(result) { - suites_hash[result.id] = result; - }; - - this.suiteDone = function(result) { - storeSuite(result); - }; - - /** - * Get the results for a set of suites. - * - * Retrievable in slices for easier serialization. - * @name jsApiReporter#suiteResults - * @since 2.1.0 - * @function - * @param {Number} index - The position in the suites list to start from. - * @param {Number} length - Maximum number of suite results to return. - * @return {SuiteResult[]} - */ - this.suiteResults = function(index, length) { - return suites.slice(index, index + length); - }; - - function storeSuite(result) { - suites.push(result); - suites_hash[result.id] = result; - } - - /** - * Get all of the suites in a single object, with their `id` as the key. - * @name jsApiReporter#suites - * @since 2.0.0 - * @function - * @return {Object} - Map of suite id to {@link SuiteResult} - */ - this.suites = function() { - return suites_hash; - }; - - const specs = []; - - this.specDone = function(result) { - specs.push(result); - }; - - /** - * Get the results for a set of specs. - * - * Retrievable in slices for easier serialization. - * @name jsApiReporter#specResults - * @since 2.0.0 - * @function - * @param {Number} index - The position in the specs list to start from. - * @param {Number} length - Maximum number of specs results to return. - * @return {SpecDoneEvent[]} - */ - this.specResults = function(index, length) { - return specs.slice(index, index + length); - }; - - /** - * Get all spec results. - * @name jsApiReporter#specs - * @since 2.0.0 - * @function - * @return {SpecDoneEvent[]} - */ - this.specs = function() { - return specs; - }; - - /** - * Get the number of milliseconds it took for the full Jasmine suite to run. - * @name jsApiReporter#executionTime - * @since 2.0.0 - * @function - * @return {Number} - */ - this.executionTime = function() { - return executionTime; - }; - } - - return JsApiReporter; -}; - getJasmineRequireObj().AllOf = function(j$) { 'use strict'; @@ -9367,10 +9232,6 @@ getJasmineRequireObj().interface = function(jasmine, env) { return env.spyOnAllFunctions(obj, includeNonEnumerable); }, - jsApiReporter: new jasmine.private.JsApiReporter({ - timer: new jasmine.Timer() - }), - /** *

Members of the jasmine global.

*

Note: The members of the diff --git a/scripts/lib/buildDistribution.js b/scripts/lib/buildDistribution.js index 43ef2296..7142f9be 100644 --- a/scripts/lib/buildDistribution.js +++ b/scripts/lib/buildDistribution.js @@ -51,7 +51,6 @@ function concatFiles() { 'src/core/Spec.js', 'src/core/Order.js', 'src/core/Env.js', - 'src/core/JsApiReporter.js', 'src/core/PrettyPrinter', 'src/core/Suite', 'src/core/**/*.js', diff --git a/spec/core/JsApiReporterSpec.js b/spec/core/JsApiReporterSpec.js deleted file mode 100644 index d2af65ce..00000000 --- a/spec/core/JsApiReporterSpec.js +++ /dev/null @@ -1,179 +0,0 @@ -describe('JsApiReporter', function() { - it('knows when a full environment is started', function() { - const reporter = new privateUnderTest.JsApiReporter({}); - - expect(reporter.started).toBe(false); - expect(reporter.finished).toBe(false); - - reporter.jasmineStarted(); - - expect(reporter.started).toBe(true); - expect(reporter.finished).toBe(false); - }); - - it('knows when a full environment is done', function() { - const reporter = new privateUnderTest.JsApiReporter({}); - - expect(reporter.started).toBe(false); - expect(reporter.finished).toBe(false); - - reporter.jasmineStarted(); - reporter.jasmineDone({}); - - expect(reporter.finished).toBe(true); - }); - - it("defaults to 'loaded' status", function() { - const reporter = new privateUnderTest.JsApiReporter({}); - - expect(reporter.status()).toEqual('loaded'); - }); - - it("reports 'started' when Jasmine has started", function() { - const reporter = new privateUnderTest.JsApiReporter({}); - - reporter.jasmineStarted(); - - expect(reporter.status()).toEqual('started'); - }); - - it("reports 'done' when Jasmine is done", function() { - const reporter = new privateUnderTest.JsApiReporter({}); - - reporter.jasmineDone({}); - - expect(reporter.status()).toEqual('done'); - }); - - it('tracks a suite', function() { - const reporter = new privateUnderTest.JsApiReporter({}); - - reporter.suiteStarted({ - id: 123, - description: 'A suite' - }); - - const suites = reporter.suites(); - - expect(suites).toEqual({ 123: { id: 123, description: 'A suite' } }); - - reporter.suiteDone({ - id: 123, - description: 'A suite', - status: 'passed' - }); - - expect(suites).toEqual({ - 123: { id: 123, description: 'A suite', status: 'passed' } - }); - }); - - describe('#specResults', function() { - let reporter, specResult1, specResult2; - beforeEach(function() { - reporter = new privateUnderTest.JsApiReporter({}); - specResult1 = { - id: 1, - description: 'A spec' - }; - specResult2 = { - id: 2, - description: 'Another spec' - }; - - reporter.specDone(specResult1); - reporter.specDone(specResult2); - }); - - it('should return a slice of results', function() { - expect(reporter.specResults(0, 1)).toEqual([specResult1]); - expect(reporter.specResults(1, 1)).toEqual([specResult2]); - }); - - describe('when the results do not exist', function() { - it('should return a slice of shorter length', function() { - expect(reporter.specResults(0, 3)).toEqual([specResult1, specResult2]); - expect(reporter.specResults(2, 3)).toEqual([]); - }); - }); - }); - - describe('#suiteResults', function() { - let reporter, suiteStarted1, suiteResult1, suiteResult2; - beforeEach(function() { - reporter = new privateUnderTest.JsApiReporter({}); - suiteStarted1 = { - id: 1 - }; - suiteResult1 = { - id: 1, - status: 'failed', - failedExpectations: [{ message: 'My After All Exception' }] - }; - suiteResult2 = { - id: 2, - status: 'passed' - }; - - reporter.suiteStarted(suiteStarted1); - reporter.suiteDone(suiteResult1); - reporter.suiteDone(suiteResult2); - }); - - it('should not include suite starts', function() { - expect(reporter.suiteResults(0, 3).length).toEqual(2); - }); - - it('should return a slice of results', function() { - expect(reporter.suiteResults(0, 1)).toEqual([suiteResult1]); - expect(reporter.suiteResults(1, 1)).toEqual([suiteResult2]); - }); - - it('returns nothing for out of bounds indices', function() { - expect(reporter.suiteResults(0, 3)).toEqual([suiteResult1, suiteResult2]); - expect(reporter.suiteResults(2, 3)).toEqual([]); - }); - }); - - describe('#executionTime', function() { - it('should start the timer when jasmine starts', function() { - const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), - reporter = new privateUnderTest.JsApiReporter({ - timer: timerSpy - }); - - reporter.jasmineStarted(); - expect(timerSpy.start).toHaveBeenCalled(); - }); - - it('should return the time it took the specs to run, in ms', function() { - const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), - reporter = new privateUnderTest.JsApiReporter({ - timer: timerSpy - }); - - timerSpy.elapsed.and.returnValue(1000); - reporter.jasmineDone(); - expect(reporter.executionTime()).toEqual(1000); - }); - - describe("when the specs haven't finished being run", function() { - it('should return undefined', function() { - const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), - reporter = new privateUnderTest.JsApiReporter({ - timer: timerSpy - }); - - expect(reporter.executionTime()).toBeUndefined(); - }); - }); - }); - - describe('#runDetails', function() { - it('should have details about the run', function() { - const reporter = new privateUnderTest.JsApiReporter({}); - reporter.jasmineDone({ some: { run: 'details' } }); - expect(reporter.runDetails).toEqual({ some: { run: 'details' } }); - }); - }); -}); diff --git a/spec/support/jasmine-browser.js b/spec/support/jasmine-browser.js index cce790f4..36b99cdc 100644 --- a/spec/support/jasmine-browser.js +++ b/spec/support/jasmine-browser.js @@ -7,7 +7,6 @@ module.exports = { 'core/util.js', 'core/Spec.js', 'core/Env.js', - 'core/JsApiReporter.js', 'core/PrettyPrinter.js', 'core/Suite.js', 'core/**/*.js', diff --git a/src/core/JsApiReporter.js b/src/core/JsApiReporter.js deleted file mode 100644 index 5e54c708..00000000 --- a/src/core/JsApiReporter.js +++ /dev/null @@ -1,133 +0,0 @@ -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(); - let status = 'loaded'; - - this.started = false; - this.finished = false; - this.runDetails = {}; - - this.jasmineStarted = function() { - this.started = true; - status = 'started'; - timer.start(); - }; - - let executionTime; - - this.jasmineDone = function(runDetails) { - this.finished = true; - this.runDetails = runDetails; - executionTime = timer.elapsed(); - status = 'done'; - }; - - /** - * Get the current status for the Jasmine environment. - * @name jsApiReporter#status - * @since 2.0.0 - * @function - * @return {String} - One of `loaded`, `started`, or `done` - */ - this.status = function() { - return status; - }; - - const suites = [], - suites_hash = {}; - - this.suiteStarted = function(result) { - suites_hash[result.id] = result; - }; - - this.suiteDone = function(result) { - storeSuite(result); - }; - - /** - * Get the results for a set of suites. - * - * Retrievable in slices for easier serialization. - * @name jsApiReporter#suiteResults - * @since 2.1.0 - * @function - * @param {Number} index - The position in the suites list to start from. - * @param {Number} length - Maximum number of suite results to return. - * @return {SuiteResult[]} - */ - this.suiteResults = function(index, length) { - return suites.slice(index, index + length); - }; - - function storeSuite(result) { - suites.push(result); - suites_hash[result.id] = result; - } - - /** - * Get all of the suites in a single object, with their `id` as the key. - * @name jsApiReporter#suites - * @since 2.0.0 - * @function - * @return {Object} - Map of suite id to {@link SuiteResult} - */ - this.suites = function() { - return suites_hash; - }; - - const specs = []; - - this.specDone = function(result) { - specs.push(result); - }; - - /** - * Get the results for a set of specs. - * - * Retrievable in slices for easier serialization. - * @name jsApiReporter#specResults - * @since 2.0.0 - * @function - * @param {Number} index - The position in the specs list to start from. - * @param {Number} length - Maximum number of specs results to return. - * @return {SpecDoneEvent[]} - */ - this.specResults = function(index, length) { - return specs.slice(index, index + length); - }; - - /** - * Get all spec results. - * @name jsApiReporter#specs - * @since 2.0.0 - * @function - * @return {SpecDoneEvent[]} - */ - this.specs = function() { - return specs; - }; - - /** - * Get the number of milliseconds it took for the full Jasmine suite to run. - * @name jsApiReporter#executionTime - * @since 2.0.0 - * @function - * @return {Number} - */ - this.executionTime = function() { - return executionTime; - }; - } - - return JsApiReporter; -}; diff --git a/src/core/requireCore.js b/src/core/requireCore.js index 59620525..387a560f 100644 --- a/src/core/requireCore.js +++ b/src/core/requireCore.js @@ -47,7 +47,6 @@ var getJasmineRequireObj = (function() { j$.private.Expector = jRequire.Expector(j$); j$.private.Expectation = jRequire.Expectation(j$); j$.private.buildExpectationResult = jRequire.buildExpectationResult(j$); - j$.private.JsApiReporter = jRequire.JsApiReporter(j$); j$.private.makePrettyPrinter = jRequire.makePrettyPrinter(j$); j$.private.basicPrettyPrinter = j$.private.makePrettyPrinter(); j$.private.MatchersUtil = jRequire.MatchersUtil(j$); diff --git a/src/core/requireInterface.js b/src/core/requireInterface.js index a8833bb1..a6e8af59 100644 --- a/src/core/requireInterface.js +++ b/src/core/requireInterface.js @@ -354,10 +354,6 @@ getJasmineRequireObj().interface = function(jasmine, env) { return env.spyOnAllFunctions(obj, includeNonEnumerable); }, - jsApiReporter: new jasmine.private.JsApiReporter({ - timer: new jasmine.Timer() - }), - /** *

Members of the jasmine global.

*

Note: The members of the