From 4d3f6b272a2b3975b7c40f8e0c3a4866259a878f Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 14 Sep 2025 09:48:01 -0700 Subject: [PATCH] Remove expected and actual properties of expectation results --- lib/jasmine-core/jasmine.js | 20 +------------------- spec/core/SpecSpec.js | 2 -- spec/core/buildExpectationResultSpec.js | 24 +----------------------- src/core/buildExpectationResult.js | 20 +------------------- 4 files changed, 3 insertions(+), 63 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 3d254bae..7c847732 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -2529,20 +2529,11 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { /** * Describes the result of evaluating an expectation * - * Note: The expected and actual properties are deprecated and may be removed - * in a future release. In many Jasmine configurations they are passed - * through JSON serialization and deserialization, which is inherently - * lossy. In such cases, the expected and actual values may be placeholders - * or approximations of the original objects. jasmine-browser-runner 3.0 and - * later omits them entirely. - * * @typedef ExpectationResult * @property {String} matcherName - The name of the matcher that was executed for this expectation. * @property {String} message - The failure message for the expectation. * @property {String} stack - The stack trace for the failure if available. * @property {Boolean} passed - Whether the expectation passed or failed. - * @property {Object} expected - Deprecated. If the expectation failed, what was the expected value. - * @property {Object} actual - Deprecated. If the expectation failed, what actual value was produced. * @property {String|undefined} globalErrorType - The type of an error that * is reported on the top suite. Valid values are undefined, "afterAll", * "load", "lateExpectation", and "lateError". @@ -2555,21 +2546,12 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { }; if (!result.passed) { - result.expected = options.expected; - result.actual = options.actual; - if (options.error && !j$.isString_(options.error)) { if ('code' in options.error) { result.code = options.error.code; } - if ( - options.error.code === 'ERR_ASSERTION' && - options.expected === '' && - options.actual === '' - ) { - result.expected = options.error.expected; - result.actual = options.error.actual; + if (options.error.code === 'ERR_ASSERTION') { result.matcherName = 'assert ' + options.error.operator; } } diff --git a/spec/core/SpecSpec.js b/spec/core/SpecSpec.js index 3bc41ede..664cc092 100644 --- a/spec/core/SpecSpec.js +++ b/spec/core/SpecSpec.js @@ -337,8 +337,6 @@ describe('Spec', function() { message: 'foo thrown', matcherName: '', passed: false, - expected: '', - actual: '', stack: null } ]); diff --git a/spec/core/buildExpectationResultSpec.js b/spec/core/buildExpectationResultSpec.js index a47ff1cb..88b4cc19 100644 --- a/spec/core/buildExpectationResultSpec.js +++ b/spec/core/buildExpectationResultSpec.js @@ -63,50 +63,28 @@ describe('buildExpectationResult', function() { expect(result.matcherName).toBe('some-value'); }); - it('expected returns passed expected', function() { - const result = jasmineUnderTest.buildExpectationResult({ - expected: 'some-value' - }); - expect(result.expected).toBe('some-value'); - }); - - it('actual returns passed actual', function() { - const result = jasmineUnderTest.buildExpectationResult({ - actual: 'some-value' - }); - expect(result.actual).toBe('some-value'); - }); - it('handles nodejs assertions', function() { if (typeof require === 'undefined') { pending('This test only runs in Node'); } const assert = require('assert'); - const value = 8421; - const expectedValue = 'JasmineExpectationTestValue'; let error; try { - assert.equal(value, expectedValue); + assert.equal('a', 'b'); } catch (e) { error = e; } expect(error.code).toEqual('ERR_ASSERTION'); - expect(error.actual).toEqual(value); - expect(error.expected).toEqual(expectedValue); expect(error.operator).toEqual('=='); const result = jasmineUnderTest.buildExpectationResult({ passed: false, matcherName: '', - expected: '', - actual: '', error: error }); expect(result.code).toEqual('ERR_ASSERTION'); - expect(result.actual).toEqual(value); - expect(result.expected).toEqual(expectedValue); expect(result.matcherName).toEqual('assert =='); }); }); diff --git a/src/core/buildExpectationResult.js b/src/core/buildExpectationResult.js index b62d1d8d..12f17b77 100644 --- a/src/core/buildExpectationResult.js +++ b/src/core/buildExpectationResult.js @@ -6,20 +6,11 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { /** * Describes the result of evaluating an expectation * - * Note: The expected and actual properties are deprecated and may be removed - * in a future release. In many Jasmine configurations they are passed - * through JSON serialization and deserialization, which is inherently - * lossy. In such cases, the expected and actual values may be placeholders - * or approximations of the original objects. jasmine-browser-runner 3.0 and - * later omits them entirely. - * * @typedef ExpectationResult * @property {String} matcherName - The name of the matcher that was executed for this expectation. * @property {String} message - The failure message for the expectation. * @property {String} stack - The stack trace for the failure if available. * @property {Boolean} passed - Whether the expectation passed or failed. - * @property {Object} expected - Deprecated. If the expectation failed, what was the expected value. - * @property {Object} actual - Deprecated. If the expectation failed, what actual value was produced. * @property {String|undefined} globalErrorType - The type of an error that * is reported on the top suite. Valid values are undefined, "afterAll", * "load", "lateExpectation", and "lateError". @@ -32,21 +23,12 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { }; if (!result.passed) { - result.expected = options.expected; - result.actual = options.actual; - if (options.error && !j$.isString_(options.error)) { if ('code' in options.error) { result.code = options.error.code; } - if ( - options.error.code === 'ERR_ASSERTION' && - options.expected === '' && - options.actual === '' - ) { - result.expected = options.error.expected; - result.actual = options.error.actual; + if (options.error.code === 'ERR_ASSERTION') { result.matcherName = 'assert ' + options.error.operator; } }