Include function names in pretty printer output

This helps make matcher errors and spy strategy mismatch errors easier
to understand in cases where the difference involves expecting one
function but getting a different one.
This commit is contained in:
Steve Gravrock
2025-06-04 18:37:44 -07:00
parent 0183acc682
commit 63ed2b3948
4 changed files with 26 additions and 7 deletions

View File

@@ -35,7 +35,11 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
} else if (value instanceof RegExp) {
this.emitScalar(value.toString());
} else if (typeof value === 'function') {
this.emitScalar('Function');
if (value.name) {
this.emitScalar(`Function '${value.name}'`);
} else {
this.emitScalar('Function');
}
} else if (j$.isDomNode(value)) {
if (value.tagName) {
this.emitDomElement(value);