Call buildExpectationResult directly from Suite and Spec

This removes quite a bit of indirection from result processing, at the
cost of making a few of the tests more awkward.
This commit is contained in:
Steve Gravrock
2022-06-01 09:41:38 -07:00
parent 8e58305b0a
commit 4cc8437f79
8 changed files with 85 additions and 179 deletions

View File

@@ -1,8 +1,7 @@
//TODO: expectation result may make more sense as a presentation of an expectation.
getJasmineRequireObj().buildExpectationResult = function(j$) {
function buildExpectationResult(options) {
const messageFormatter = options.messageFormatter || function() {};
const stackFormatter = options.stackFormatter || function() {};
const exceptionFormatter = new j$.ExceptionFormatter();
/**
* @typedef Expectation
@@ -52,7 +51,7 @@ getJasmineRequireObj().buildExpectationResult = function(j$) {
} else if (options.message) {
return options.message;
} else if (options.error) {
return messageFormatter(options.error);
return exceptionFormatter.message(options.error);
}
return '';
}
@@ -79,7 +78,7 @@ getJasmineRequireObj().buildExpectationResult = function(j$) {
}
// Omit the message from the stack trace because it will be
// included elsewhere.
return stackFormatter(error, { omitMessage: true });
return exceptionFormatter.stack(error, { omitMessage: true });
}
}