Indent multiline failure messages in the output of withContext
This makes it easier to see where each failure message begins and ends.
Before:
Some context: a
multiline
message
After:
Some context:
a
multiline
message
This commit is contained in:
@@ -176,9 +176,19 @@ getJasmineRequireObj().Expectation = function(j$) {
|
||||
}
|
||||
|
||||
ContextAddingFilter.prototype.modifyFailureMessage = function(msg) {
|
||||
return this.message + ': ' + msg;
|
||||
var nl = msg.indexOf('\n');
|
||||
|
||||
if (nl === -1) {
|
||||
return this.message + ': ' + msg;
|
||||
} else {
|
||||
return this.message + ':\n' + indent(msg);
|
||||
}
|
||||
};
|
||||
|
||||
function indent(s) {
|
||||
return s.replace(/^/gm, ' ');
|
||||
}
|
||||
|
||||
return {
|
||||
factory: function(options) {
|
||||
return new Expectation(options || {});
|
||||
|
||||
Reference in New Issue
Block a user