Remove expected and actual properties of expectation results
This commit is contained in:
@@ -2529,20 +2529,11 @@ getJasmineRequireObj().buildExpectationResult = function(j$) {
|
|||||||
/**
|
/**
|
||||||
* Describes the result of evaluating an expectation
|
* 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
|
* @typedef ExpectationResult
|
||||||
* @property {String} matcherName - The name of the matcher that was executed for this expectation.
|
* @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} message - The failure message for the expectation.
|
||||||
* @property {String} stack - The stack trace for the failure if available.
|
* @property {String} stack - The stack trace for the failure if available.
|
||||||
* @property {Boolean} passed - Whether the expectation passed or failed.
|
* @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
|
* @property {String|undefined} globalErrorType - The type of an error that
|
||||||
* is reported on the top suite. Valid values are undefined, "afterAll",
|
* is reported on the top suite. Valid values are undefined, "afterAll",
|
||||||
* "load", "lateExpectation", and "lateError".
|
* "load", "lateExpectation", and "lateError".
|
||||||
@@ -2555,21 +2546,12 @@ getJasmineRequireObj().buildExpectationResult = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!result.passed) {
|
if (!result.passed) {
|
||||||
result.expected = options.expected;
|
|
||||||
result.actual = options.actual;
|
|
||||||
|
|
||||||
if (options.error && !j$.isString_(options.error)) {
|
if (options.error && !j$.isString_(options.error)) {
|
||||||
if ('code' in options.error) {
|
if ('code' in options.error) {
|
||||||
result.code = options.error.code;
|
result.code = options.error.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (options.error.code === 'ERR_ASSERTION') {
|
||||||
options.error.code === 'ERR_ASSERTION' &&
|
|
||||||
options.expected === '' &&
|
|
||||||
options.actual === ''
|
|
||||||
) {
|
|
||||||
result.expected = options.error.expected;
|
|
||||||
result.actual = options.error.actual;
|
|
||||||
result.matcherName = 'assert ' + options.error.operator;
|
result.matcherName = 'assert ' + options.error.operator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -337,8 +337,6 @@ describe('Spec', function() {
|
|||||||
message: 'foo thrown',
|
message: 'foo thrown',
|
||||||
matcherName: '',
|
matcherName: '',
|
||||||
passed: false,
|
passed: false,
|
||||||
expected: '',
|
|
||||||
actual: '',
|
|
||||||
stack: null
|
stack: null
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -63,50 +63,28 @@ describe('buildExpectationResult', function() {
|
|||||||
expect(result.matcherName).toBe('some-value');
|
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() {
|
it('handles nodejs assertions', function() {
|
||||||
if (typeof require === 'undefined') {
|
if (typeof require === 'undefined') {
|
||||||
pending('This test only runs in Node');
|
pending('This test only runs in Node');
|
||||||
}
|
}
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const value = 8421;
|
|
||||||
const expectedValue = 'JasmineExpectationTestValue';
|
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
assert.equal(value, expectedValue);
|
assert.equal('a', 'b');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(error.code).toEqual('ERR_ASSERTION');
|
expect(error.code).toEqual('ERR_ASSERTION');
|
||||||
expect(error.actual).toEqual(value);
|
|
||||||
expect(error.expected).toEqual(expectedValue);
|
|
||||||
expect(error.operator).toEqual('==');
|
expect(error.operator).toEqual('==');
|
||||||
|
|
||||||
const result = jasmineUnderTest.buildExpectationResult({
|
const result = jasmineUnderTest.buildExpectationResult({
|
||||||
passed: false,
|
passed: false,
|
||||||
matcherName: '',
|
matcherName: '',
|
||||||
expected: '',
|
|
||||||
actual: '',
|
|
||||||
error: error
|
error: error
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result.code).toEqual('ERR_ASSERTION');
|
expect(result.code).toEqual('ERR_ASSERTION');
|
||||||
expect(result.actual).toEqual(value);
|
|
||||||
expect(result.expected).toEqual(expectedValue);
|
|
||||||
expect(result.matcherName).toEqual('assert ==');
|
expect(result.matcherName).toEqual('assert ==');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,20 +6,11 @@ getJasmineRequireObj().buildExpectationResult = function(j$) {
|
|||||||
/**
|
/**
|
||||||
* Describes the result of evaluating an expectation
|
* 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
|
* @typedef ExpectationResult
|
||||||
* @property {String} matcherName - The name of the matcher that was executed for this expectation.
|
* @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} message - The failure message for the expectation.
|
||||||
* @property {String} stack - The stack trace for the failure if available.
|
* @property {String} stack - The stack trace for the failure if available.
|
||||||
* @property {Boolean} passed - Whether the expectation passed or failed.
|
* @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
|
* @property {String|undefined} globalErrorType - The type of an error that
|
||||||
* is reported on the top suite. Valid values are undefined, "afterAll",
|
* is reported on the top suite. Valid values are undefined, "afterAll",
|
||||||
* "load", "lateExpectation", and "lateError".
|
* "load", "lateExpectation", and "lateError".
|
||||||
@@ -32,21 +23,12 @@ getJasmineRequireObj().buildExpectationResult = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!result.passed) {
|
if (!result.passed) {
|
||||||
result.expected = options.expected;
|
|
||||||
result.actual = options.actual;
|
|
||||||
|
|
||||||
if (options.error && !j$.isString_(options.error)) {
|
if (options.error && !j$.isString_(options.error)) {
|
||||||
if ('code' in options.error) {
|
if ('code' in options.error) {
|
||||||
result.code = options.error.code;
|
result.code = options.error.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (options.error.code === 'ERR_ASSERTION') {
|
||||||
options.error.code === 'ERR_ASSERTION' &&
|
|
||||||
options.expected === '' &&
|
|
||||||
options.actual === ''
|
|
||||||
) {
|
|
||||||
result.expected = options.error.expected;
|
|
||||||
result.actual = options.error.actual;
|
|
||||||
result.matcherName = 'assert ' + options.error.operator;
|
result.matcherName = 'assert ' + options.error.operator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user