Skip to content

Commit 5f415df

Browse files
author
cloudhead
committed
output function name in AssertionError, if {expected} is a function
1 parent 0b32f54 commit 5f415df

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/assert/error.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ require('assert').AssertionError.prototype.toString = function () {
77

88
function parse(str) {
99
return str.replace(/{actual}/g, inspect(that.actual)).
10-
replace(/{expected}/g, inspect(that.expected)).
11-
replace(/{operator}/g, stylize(that.operator, 'bold'));
10+
replace(/{operator}/g, stylize(that.operator, 'bold')).
11+
replace(/{expected}/g, (that.expected instanceof Function)
12+
? that.expected.name
13+
: inspect(that.expected));
1214
}
1315

1416
if (this.message) {

0 commit comments

Comments
 (0)